]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 May 2012 00:37:09 +0000 (17:37 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 May 2012 00:37:09 +0000 (17:37 -0700)
Pull scsi-target changes from Nicholas Bellinger:
 "There has been lots of work in existing code in a number of areas this
  past cycle.  The major highlights have been:

   * Removal of transport_do_task_sg_chain() from core + fabrics
     (Roland)
   * target-core: Removal of se_task abstraction from target-core and
     enforce hw_max_sectors for pSCSI backends (hch)
   * Re-factoring of iscsi-target tx immediate/response queues (agrover)
   * Conversion of iscsi-target back to using target core memory
     allocation logic (agrover)

  We've had one last minute iscsi-target patch go into for-next to
  address a nasty regression bug related to the target core allocation
  logic conversion from agrover that is not included in friday's
  linux-next build, but has been included in this series.

  On the new fabric module code front for-3.5, here is a brief status
  update for the three currently in flight this round:

   * usb-gadget target driver:

  Sebastian Siewior's driver for supporting usb-gadget target mode
  operation.  This will be going out as a separate PULL request from
  target-pending/usb-target-merge with subsystem maintainer ACKs.  There
  is one minor target-core patch in this series required to function.

   * sbp ieee-1394/firewire target driver:

  Chris Boot's driver for supportting the Serial Block Protocol (SBP)
  across IEEE-1394 Firewire hardware.  This will be going out as a
  separate PULL request from target-pending/sbp-target-merge with two
  additional drivers/firewire/ patches w/ subsystem maintainer ACKs.

   * qla2xxx LLD target mode infrastructure changes + tcm_qla2xxx:

  The Qlogic >= 24xx series HW target mode LLD infrastructure patch-set
  and tcm_qla2xxx fabric driver.  Support for FC target mode using
  qla2xxx LLD code has been officially submitted by Qlogic to James
  below, and is currently outstanding but not yet merged into
  scsi.git/for-next..

    [PATCH 00/22] qla2xxx: Updates for scsi "misc" branch
    http://www.spinics.net/lists/linux-scsi/msg59350.html

  Note there are *zero* direct dependencies upon this for-next series
  for the qla2xxx LLD target + tcm_qla2xxx patches submitted above, and
  over the last days the target mode team has been tracking down an
  tcm_qla2xxx specific active I/O shutdown bug that appears to now be
  almost squashed for 3.5-rc-fixes."

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (47 commits)
  iscsi-target: Fix iov_count calculation bug in iscsit_allocate_iovecs
  iscsi-target: remove dead code in iscsi_check_valuelist_for_support
  target: Handle ATA_16 passthrough for pSCSI backend devices
  target: Add MI_REPORT_TARGET_PGS ext. header + implict_trans_secs attribute
  target: Fix MAINTENANCE_IN service action CDB checks to use lower 5 bits
  target: add support for the WRITE_VERIFY command
  target: make target_put_session void
  target: cleanup transport_execute_tasks()
  target: Remove max_sectors device attribute for modern se_task less code
  target: lock => unlock typo in transport_lun_wait_for_tasks
  target: Enforce hw_max_sectors for SCF_SCSI_DATA_SG_IO_CDB
  target: remove the t_se_count field in struct se_cmd
  target: remove the t_task_cdbs_ex_left field in struct se_cmd
  target: remove the t_task_cdbs_left field in struct se_cmd
  target: remove struct se_task
  target: move the state and execute lists to the command
  target: simplify command to task linkage
  target: always allocate a single task
  target: replace ->execute_task with ->execute_cmd
  target: remove the task_sectors field in struct se_task
  ...

1  2 
drivers/infiniband/ulp/srpt/ib_srpt.c
drivers/target/target_core_file.c
drivers/target/target_core_pr.c
drivers/target/target_core_tpg.c

index daf21b8999998781bde4856415a542bef142707e,e2c8198020de04149c2116f46fe699e49a90efc8..5f6b7f63cdef28cf37ce3e350c3d5e099d273b16
@@@ -1099,9 -1099,8 +1099,8 @@@ static int srpt_map_sg_to_ib_sge(struc
        dir = cmd->data_direction;
        BUG_ON(dir == DMA_NONE);
  
-       transport_do_task_sg_chain(cmd);
-       ioctx->sg = sg = sg_orig = cmd->t_tasks_sg_chained;
-       ioctx->sg_cnt = sg_cnt = cmd->t_tasks_sg_chained_no;
+       ioctx->sg = sg = sg_orig = cmd->t_data_sg;
+       ioctx->sg_cnt = sg_cnt = cmd->t_data_nents;
  
        count = ib_dma_map_sg(ch->sport->sdev->device, sg, sg_cnt,
                              opposite_dma_dir(dir));
@@@ -1769,7 -1768,7 +1768,7 @@@ static int srpt_handle_cmd(struct srpt_
                kref_put(&send_ioctx->kref, srpt_put_send_ioctx_kref);
                goto send_sense;
        }
-       ret = transport_generic_allocate_tasks(cmd, srp_cmd->cdb);
+       ret = target_setup_cmd_from_cdb(cmd, srp_cmd->cdb);
        if (ret < 0) {
                kref_put(&send_ioctx->kref, srpt_put_send_ioctx_kref);
                if (cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) {
@@@ -3232,7 -3231,6 +3231,7 @@@ static void srpt_add_one(struct ib_devi
        srq_attr.attr.max_wr = sdev->srq_size;
        srq_attr.attr.max_sge = 1;
        srq_attr.attr.srq_limit = 0;
 +      srq_attr.srq_type = IB_SRQT_BASIC;
  
        sdev->srq = ib_create_srq(sdev->pd, &srq_attr);
        if (IS_ERR(sdev->srq))
@@@ -4004,9 -4002,6 +4003,6 @@@ static int __init srpt_init_module(void
  
        srpt_target->tf_ops = srpt_template;
  
-       /* Enable SG chaining */
-       srpt_target->tf_ops.task_sg_chaining = true;
        /*
         * Set up default attribute lists.
         */
index f286955331a2b0a28e37d247c209f13f4b1dbdca,bbcedcfc068aa3662eb7fb5cac6ce5d0c7232e85..686dba189f8eba7fac5bd9ab1d13e6833ec1e4b4
@@@ -133,15 -133,10 +133,10 @@@ static struct se_device *fd_create_virt
                ret = PTR_ERR(dev_p);
                goto fail;
        }
- #if 0
-       if (di->no_create_file)
-               flags = O_RDWR | O_LARGEFILE;
-       else
-               flags = O_RDWR | O_CREAT | O_LARGEFILE;
- #else
+       /* O_DIRECT too? */
        flags = O_RDWR | O_CREAT | O_LARGEFILE;
- #endif
- /*    flags |= O_DIRECT; */
        /*
         * If fd_buffered_io=1 has not been set explicitly (the default),
         * use O_SYNC to force FILEIO writes to disk.
        inode = file->f_mapping->host;
        if (S_ISBLK(inode->i_mode)) {
                struct request_queue *q;
 +              unsigned long long dev_size;
                /*
                 * Setup the local scope queue_limits from struct request_queue->limits
                 * to pass into transport_add_device_to_core_hba() as struct se_dev_limits.
                 * one (1) logical sector from underlying struct block_device
                 */
                fd_dev->fd_block_size = bdev_logical_block_size(inode->i_bdev);
 -              fd_dev->fd_dev_size = (i_size_read(file->f_mapping->host) -
 +              dev_size = (i_size_read(file->f_mapping->host) -
                                       fd_dev->fd_block_size);
  
                pr_debug("FILEIO: Using size: %llu bytes from struct"
                        " block_device blocks: %llu logical_block_size: %d\n",
 -                      fd_dev->fd_dev_size,
 -                      div_u64(fd_dev->fd_dev_size, fd_dev->fd_block_size),
 +                      dev_size, div_u64(dev_size, fd_dev->fd_block_size),
                        fd_dev->fd_block_size);
        } else {
                if (!(fd_dev->fbd_flags & FBDF_HAS_SIZE)) {
@@@ -249,53 -244,33 +244,33 @@@ static void fd_free_device(void *p
        kfree(fd_dev);
  }
  
- static inline struct fd_request *FILE_REQ(struct se_task *task)
- {
-       return container_of(task, struct fd_request, fd_task);
- }
- static struct se_task *
- fd_alloc_task(unsigned char *cdb)
+ static int fd_do_readv(struct se_cmd *cmd, struct scatterlist *sgl,
+               u32 sgl_nents)
  {
-       struct fd_request *fd_req;
-       fd_req = kzalloc(sizeof(struct fd_request), GFP_KERNEL);
-       if (!fd_req) {
-               pr_err("Unable to allocate struct fd_request\n");
-               return NULL;
-       }
-       return &fd_req->fd_task;
- }
- static int fd_do_readv(struct se_task *task)
- {
-       struct fd_request *req = FILE_REQ(task);
-       struct se_device *se_dev = req->fd_task.task_se_cmd->se_dev;
+       struct se_device *se_dev = cmd->se_dev;
        struct fd_dev *dev = se_dev->dev_ptr;
        struct file *fd = dev->fd_file;
-       struct scatterlist *sg = task->task_sg;
+       struct scatterlist *sg;
        struct iovec *iov;
        mm_segment_t old_fs;
-       loff_t pos = (task->task_lba *
+       loff_t pos = (cmd->t_task_lba *
                      se_dev->se_sub_dev->se_dev_attrib.block_size);
        int ret = 0, i;
  
-       iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL);
+       iov = kzalloc(sizeof(struct iovec) * sgl_nents, GFP_KERNEL);
        if (!iov) {
                pr_err("Unable to allocate fd_do_readv iov[]\n");
                return -ENOMEM;
        }
  
-       for_each_sg(task->task_sg, sg, task->task_sg_nents, i) {
+       for_each_sg(sgl, sg, sgl_nents, i) {
                iov[i].iov_len = sg->length;
                iov[i].iov_base = sg_virt(sg);
        }
  
        old_fs = get_fs();
        set_fs(get_ds());
-       ret = vfs_readv(fd, &iov[0], task->task_sg_nents, &pos);
+       ret = vfs_readv(fd, &iov[0], sgl_nents, &pos);
        set_fs(old_fs);
  
        kfree(iov);
         * block_device.
         */
        if (S_ISBLK(fd->f_dentry->d_inode->i_mode)) {
-               if (ret < 0 || ret != task->task_size) {
+               if (ret < 0 || ret != cmd->data_length) {
                        pr_err("vfs_readv() returned %d,"
                                " expecting %d for S_ISBLK\n", ret,
-                               (int)task->task_size);
+                               (int)cmd->data_length);
                        return (ret < 0 ? ret : -EINVAL);
                }
        } else {
        return 1;
  }
  
- static int fd_do_writev(struct se_task *task)
+ static int fd_do_writev(struct se_cmd *cmd, struct scatterlist *sgl,
+               u32 sgl_nents)
  {
-       struct fd_request *req = FILE_REQ(task);
-       struct se_device *se_dev = req->fd_task.task_se_cmd->se_dev;
+       struct se_device *se_dev = cmd->se_dev;
        struct fd_dev *dev = se_dev->dev_ptr;
        struct file *fd = dev->fd_file;
-       struct scatterlist *sg = task->task_sg;
+       struct scatterlist *sg;
        struct iovec *iov;
        mm_segment_t old_fs;
-       loff_t pos = (task->task_lba *
+       loff_t pos = (cmd->t_task_lba *
                      se_dev->se_sub_dev->se_dev_attrib.block_size);
        int ret, i = 0;
  
-       iov = kzalloc(sizeof(struct iovec) * task->task_sg_nents, GFP_KERNEL);
+       iov = kzalloc(sizeof(struct iovec) * sgl_nents, GFP_KERNEL);
        if (!iov) {
                pr_err("Unable to allocate fd_do_writev iov[]\n");
                return -ENOMEM;
        }
  
-       for_each_sg(task->task_sg, sg, task->task_sg_nents, i) {
+       for_each_sg(sgl, sg, sgl_nents, i) {
                iov[i].iov_len = sg->length;
                iov[i].iov_base = sg_virt(sg);
        }
  
        old_fs = get_fs();
        set_fs(get_ds());
-       ret = vfs_writev(fd, &iov[0], task->task_sg_nents, &pos);
+       ret = vfs_writev(fd, &iov[0], sgl_nents, &pos);
        set_fs(old_fs);
  
        kfree(iov);
  
-       if (ret < 0 || ret != task->task_size) {
+       if (ret < 0 || ret != cmd->data_length) {
                pr_err("vfs_writev() returned %d\n", ret);
                return (ret < 0 ? ret : -EINVAL);
        }
        return 1;
  }
  
- static void fd_emulate_sync_cache(struct se_task *task)
+ static void fd_emulate_sync_cache(struct se_cmd *cmd)
  {
-       struct se_cmd *cmd = task->task_se_cmd;
        struct se_device *dev = cmd->se_dev;
        struct fd_dev *fd_dev = dev->dev_ptr;
        int immed = (cmd->t_task_cdb[1] & 0x2);
         * for this SYNCHRONIZE_CACHE op
         */
        if (immed)
-               transport_complete_sync_cache(cmd, 1);
+               target_complete_cmd(cmd, SAM_STAT_GOOD);
  
        /*
         * Determine if we will be flushing the entire device.
        if (ret != 0)
                pr_err("FILEIO: vfs_fsync_range() failed: %d\n", ret);
  
-       if (!immed)
-               transport_complete_sync_cache(cmd, ret == 0);
+       if (immed)
+               return;
+       if (ret) {
+               cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
+               target_complete_cmd(cmd, SAM_STAT_CHECK_CONDITION);
+       } else {
+               target_complete_cmd(cmd, SAM_STAT_GOOD);
+       }
  }
  
- /*
-  * WRITE Force Unit Access (FUA) emulation on a per struct se_task
-  * LBA range basis..
-  */
- static void fd_emulate_write_fua(struct se_cmd *cmd, struct se_task *task)
+ static void fd_emulate_write_fua(struct se_cmd *cmd)
  {
        struct se_device *dev = cmd->se_dev;
        struct fd_dev *fd_dev = dev->dev_ptr;
-       loff_t start = task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
-       loff_t end = start + task->task_size;
+       loff_t start = cmd->t_task_lba *
+               dev->se_sub_dev->se_dev_attrib.block_size;
+       loff_t end = start + cmd->data_length;
        int ret;
  
        pr_debug("FILEIO: FUA WRITE LBA: %llu, bytes: %u\n",
-                       task->task_lba, task->task_size);
+               cmd->t_task_lba, cmd->data_length);
  
        ret = vfs_fsync_range(fd_dev->fd_file, start, end, 1);
        if (ret != 0)
                pr_err("FILEIO: vfs_fsync_range() failed: %d\n", ret);
  }
  
- static int fd_do_task(struct se_task *task)
+ static int fd_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl,
+               u32 sgl_nents, enum dma_data_direction data_direction)
  {
-       struct se_cmd *cmd = task->task_se_cmd;
        struct se_device *dev = cmd->se_dev;
        int ret = 0;
  
         * Call vectorized fileio functions to map struct scatterlist
         * physical memory addresses to struct iovec virtual memory.
         */
-       if (task->task_data_direction == DMA_FROM_DEVICE) {
-               ret = fd_do_readv(task);
+       if (data_direction == DMA_FROM_DEVICE) {
+               ret = fd_do_readv(cmd, sgl, sgl_nents);
        } else {
-               ret = fd_do_writev(task);
+               ret = fd_do_writev(cmd, sgl, sgl_nents);
  
                if (ret > 0 &&
                    dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 &&
                         * and return some sense data to let the initiator
                         * know the FUA WRITE cache sync failed..?
                         */
-                       fd_emulate_write_fua(cmd, task);
+                       fd_emulate_write_fua(cmd);
                }
  
        }
                cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
                return ret;
        }
-       if (ret) {
-               task->task_scsi_status = GOOD;
-               transport_complete_task(task, 1);
-       }
+       if (ret)
+               target_complete_cmd(cmd, SAM_STAT_GOOD);
        return 0;
  }
  
- /*    fd_free_task(): (Part of se_subsystem_api_t template)
-  *
-  *
-  */
- static void fd_free_task(struct se_task *task)
- {
-       struct fd_request *req = FILE_REQ(task);
-       kfree(req);
- }
  enum {
        Opt_fd_dev_name, Opt_fd_dev_size, Opt_fd_buffered_io, Opt_err
  };
@@@ -605,20 -570,10 +570,20 @@@ static u32 fd_get_device_type(struct se
  static sector_t fd_get_blocks(struct se_device *dev)
  {
        struct fd_dev *fd_dev = dev->dev_ptr;
 -      unsigned long long blocks_long = div_u64(fd_dev->fd_dev_size,
 -                      dev->se_sub_dev->se_dev_attrib.block_size);
 +      struct file *f = fd_dev->fd_file;
 +      struct inode *i = f->f_mapping->host;
 +      unsigned long long dev_size;
 +      /*
 +       * When using a file that references an underlying struct block_device,
 +       * ensure dev_size is always based on the current inode size in order
 +       * to handle underlying block_device resize operations.
 +       */
 +      if (S_ISBLK(i->i_mode))
 +              dev_size = (i_size_read(i) - fd_dev->fd_block_size);
 +      else
 +              dev_size = fd_dev->fd_dev_size;
  
 -      return blocks_long;
 +      return div_u64(dev_size, dev->se_sub_dev->se_dev_attrib.block_size);
  }
  
  static struct se_subsystem_api fileio_template = {
        .allocate_virtdevice    = fd_allocate_virtdevice,
        .create_virtdevice      = fd_create_virtdevice,
        .free_device            = fd_free_device,
-       .alloc_task             = fd_alloc_task,
-       .do_task                = fd_do_task,
+       .execute_cmd            = fd_execute_cmd,
        .do_sync_cache          = fd_emulate_sync_cache,
-       .free_task              = fd_free_task,
        .check_configfs_dev_params = fd_check_configfs_dev_params,
        .set_configfs_dev_params = fd_set_configfs_dev_params,
        .show_configfs_dev_params = fd_show_configfs_dev_params,
index c3148b10b4b38ef71d2516a0fad1a89408530df6,f5ba98693796adc159f228e292e3fada55a4c426..85564998500a5bc1330fefbd0860a5425fda5939
@@@ -193,9 -193,8 +193,8 @@@ static int target_check_scsi2_reservati
        return 0;
  }
  
- int target_scsi2_reservation_release(struct se_task *task)
+ int target_scsi2_reservation_release(struct se_cmd *cmd)
  {
-       struct se_cmd *cmd = task->task_se_cmd;
        struct se_device *dev = cmd->se_dev;
        struct se_session *sess = cmd->se_sess;
        struct se_portal_group *tpg = sess->se_tpg;
        if (dev->dev_reserved_node_acl != sess->se_node_acl)
                goto out_unlock;
  
 +      if (dev->dev_res_bin_isid != sess->sess_bin_isid)
 +              goto out_unlock;
 +
        dev->dev_reserved_node_acl = NULL;
        dev->dev_flags &= ~DF_SPC2_RESERVATIONS;
        if (dev->dev_flags & DF_SPC2_RESERVATIONS_WITH_ISID) {
  out_unlock:
        spin_unlock(&dev->dev_reservation_lock);
  out:
-       if (!ret) {
-               task->task_scsi_status = GOOD;
-               transport_complete_task(task, 1);
-       }
+       if (!ret)
+               target_complete_cmd(cmd, GOOD);
        return ret;
  }
  
- int target_scsi2_reservation_reserve(struct se_task *task)
+ int target_scsi2_reservation_reserve(struct se_cmd *cmd)
  {
-       struct se_cmd *cmd = task->task_se_cmd;
        struct se_device *dev = cmd->se_dev;
        struct se_session *sess = cmd->se_sess;
        struct se_portal_group *tpg = sess->se_tpg;
  out_unlock:
        spin_unlock(&dev->dev_reservation_lock);
  out:
-       if (!ret) {
-               task->task_scsi_status = GOOD;
-               transport_complete_task(task, 1);
-       }
+       if (!ret)
+               target_complete_cmd(cmd, GOOD);
        return ret;
  }
  
@@@ -503,11 -494,10 +497,10 @@@ static int core_scsi3_pr_seq_non_holder
         * statement.
         */
        if (!ret && !other_cdb) {
- #if 0
                pr_debug("Allowing explict CDB: 0x%02x for %s"
                        " reservation holder\n", cdb[0],
                        core_scsi3_pr_dump_type(pr_reg_type));
- #endif
                return ret;
        }
        /*
                         * as we expect registered non-reservation holding
                         * nexuses to issue CDBs.
                         */
- #if 0
                        if (!registered_nexus) {
                                pr_debug("Allowing implict CDB: 0x%02x"
                                        " for %s reservation on unregistered"
                                        " nexus\n", cdb[0],
                                        core_scsi3_pr_dump_type(pr_reg_type));
                        }
- #endif
                        return 0;
                }
        } else if ((reg_only) || (all_reg)) {
                         * For PR_*_REG_ONLY and PR_*_ALL_REG reservations,
                         * allow commands from registered nexuses.
                         */
- #if 0
                        pr_debug("Allowing implict CDB: 0x%02x for %s"
                                " reservation\n", cdb[0],
                                core_scsi3_pr_dump_type(pr_reg_type));
- #endif
                        return 0;
                }
        }
@@@ -1669,12 -1659,12 +1662,12 @@@ static int core_scsi3_decode_spec_i_por
                        ret = -EINVAL;
                        goto out;
                }
- #if 0
                pr_debug("SPC-3 PR SPEC_I_PT: Got %s data_length: %u tpdl: %u"
                        " tid_len: %d for %s + %s\n",
                        dest_tpg->se_tpg_tfo->get_fabric_name(), cmd->data_length,
                        tpdl, tid_len, i_str, iport_ptr);
- #endif
                if (tid_len > tpdl) {
                        pr_err("SPC-3 PR SPEC_I_PT: Illegal tid_len:"
                                " %u for Transport ID: %s\n", tid_len, ptr);
                        ret = -EINVAL;
                        goto out;
                }
- #if 0
                pr_debug("SPC-3 PR SPEC_I_PT: Located %s Node: %s"
                        " dest_se_deve mapped_lun: %u\n",
                        dest_tpg->se_tpg_tfo->get_fabric_name(),
                        dest_node_acl->initiatorname, dest_se_deve->mapped_lun);
- #endif
                /*
                 * Skip any TransportIDs that already have a registration for
                 * this target port.
@@@ -3476,10 -3466,10 +3469,10 @@@ static int core_scsi3_emulate_pro_regis
  
        buf = transport_kmap_data_sg(cmd);
        proto_ident = (buf[24] & 0x0f);
- #if 0
        pr_debug("SPC-3 PR REGISTER_AND_MOVE: Extracted Protocol Identifier:"
                        " 0x%02x\n", proto_ident);
- #endif
        if (proto_ident != dest_tf_ops->get_fabric_proto_ident(dest_se_tpg)) {
                pr_err("SPC-3 PR REGISTER_AND_MOVE: Received"
                        " proto_ident: 0x%02x does not match ident: 0x%02x"
@@@ -3578,11 -3568,11 +3571,11 @@@ after_iport_check
                ret = -EINVAL;
                goto out;
        }
- #if 0
        pr_debug("SPC-3 PR REGISTER_AND_MOVE: Found %s dest_node_acl:"
                " %s from TransportID\n", dest_tf_ops->get_fabric_name(),
                dest_node_acl->initiatorname);
- #endif
        /*
         * Locate the struct se_dev_entry pointer for the matching RELATIVE TARGET
         * PORT IDENTIFIER.
                ret = -EINVAL;
                goto out;
        }
- #if 0
        pr_debug("SPC-3 PR REGISTER_AND_MOVE: Located %s node %s LUN"
                " ACL for dest_se_deve->mapped_lun: %u\n",
                dest_tf_ops->get_fabric_name(), dest_node_acl->initiatorname,
                dest_se_deve->mapped_lun);
- #endif
        /*
         * A persistent reservation needs to already existing in order to
         * successfully complete the REGISTER_AND_MOVE service action..
@@@ -3802,9 -3792,8 +3795,8 @@@ static unsigned long long core_scsi3_ex
  /*
   * See spc4r17 section 6.14 Table 170
   */
- int target_scsi3_emulate_pr_out(struct se_task *task)
+ int target_scsi3_emulate_pr_out(struct se_cmd *cmd)
  {
-       struct se_cmd *cmd = task->task_se_cmd;
        unsigned char *cdb = &cmd->t_task_cdb[0];
        unsigned char *buf;
        u64 res_key, sa_res_key;
        }
  
  out:
-       if (!ret) {
-               task->task_scsi_status = GOOD;
-               transport_complete_task(task, 1);
-       }
+       if (!ret)
+               target_complete_cmd(cmd, GOOD);
        return ret;
  }
  
@@@ -4302,9 -4289,8 +4292,8 @@@ static int core_scsi3_pri_read_full_sta
        return 0;
  }
  
- int target_scsi3_emulate_pr_in(struct se_task *task)
+ int target_scsi3_emulate_pr_in(struct se_cmd *cmd)
  {
-       struct se_cmd *cmd = task->task_se_cmd;
        int ret;
  
        /*
                break;
        }
  
-       if (!ret) {
-               task->task_scsi_status = GOOD;
-               transport_complete_task(task, 1);
-       }
+       if (!ret)
+               target_complete_cmd(cmd, GOOD);
        return ret;
  }
  
index e320ec24aa1bf81f10a471d677f1363c187f9919,c672a40cbfe2c19b8f642063872ae2950139dc3e..8bd58e284185bab23b8df5d4a554eeae945c8b04
@@@ -60,6 -60,7 +60,6 @@@ static void core_clear_initiator_node_f
        int i;
        struct se_dev_entry *deve;
        struct se_lun *lun;
 -      struct se_lun_acl *acl, *acl_tmp;
  
        spin_lock_irq(&nacl->device_list_lock);
        for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) {
                core_update_device_list_for_node(lun, NULL, deve->mapped_lun,
                        TRANSPORT_LUNFLAGS_NO_ACCESS, nacl, tpg, 0);
  
 -              spin_lock(&lun->lun_acl_lock);
 -              list_for_each_entry_safe(acl, acl_tmp,
 -                                      &lun->lun_acl_list, lacl_list) {
 -                      if (!strcmp(acl->initiatorname, nacl->initiatorname) &&
 -                          (acl->mapped_lun == deve->mapped_lun))
 -                              break;
 -              }
 -
 -              if (!acl) {
 -                      pr_err("Unable to locate struct se_lun_acl for %s,"
 -                              " mapped_lun: %u\n", nacl->initiatorname,
 -                              deve->mapped_lun);
 -                      spin_unlock(&lun->lun_acl_lock);
 -                      spin_lock_irq(&nacl->device_list_lock);
 -                      continue;
 -              }
 -
 -              list_del(&acl->lacl_list);
 -              spin_unlock(&lun->lun_acl_lock);
 -
                spin_lock_irq(&nacl->device_list_lock);
 -              kfree(acl);
        }
        spin_unlock_irq(&nacl->device_list_lock);
  }
@@@ -153,10 -175,7 +153,7 @@@ void core_tpg_add_node_to_devs
                 * demo_mode_write_protect is ON, or READ_ONLY;
                 */
                if (!tpg->se_tpg_tfo->tpg_check_demo_mode_write_protect(tpg)) {
-                       if (dev->dev_flags & DF_READ_ONLY)
-                               lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
-                       else
-                               lun_access = TRANSPORT_LUNFLAGS_READ_WRITE;
+                       lun_access = TRANSPORT_LUNFLAGS_READ_WRITE;
                } else {
                        /*
                         * Allow only optical drives to issue R/W in default RO