summaryrefslogtreecommitdiff
path: root/drivers/target
AgeCommit message (Collapse)Author
2012-10-02target: simplify code around transport_get_sense_dataPaolo Bonzini
commit 27a2709912ac19c755d34c79fe11994b0bf8082b upstream. The error conditions in transport_get_sense_data are superfluous and complicate the code unnecessarily: * SCF_TRANSPORT_TASK_SENSE is checked in the caller; * it's simply part of the invariants of dev->transport->get_sense_buffer that it must be there if transport_complete ever returns 1, and that it must not return NULL. Besides, the entire callback will disappear with the next patch. * similarly in the caller we can expect that sense data is only sent for non-zero cmd->scsi_status. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-02target: Fix ->data_length re-assignment bug with SCSI overflowNicholas Bellinger
commit 4c054ba63ad47ef244cfcfa1cea38134620a5bae upstream. This patch fixes a long-standing bug with SCSI overflow handling where se_cmd->data_length was incorrectly being re-assigned to the larger CDB extracted allocation length, resulting in a number of fabric level errors that would end up causing a session reset in most cases. So instead now: - Only re-assign se_cmd->data_length durining UNDERFLOW (to use the smaller value) - Use existing se_cmd->data_length for OVERFLOW (to use the smaller value) This fix has been tested with the following CDB to generate an SCSI overflow: sg_raw -r512 /dev/sdc 28 0 0 0 0 0 0 0 9 0 Tested using iscsi-target, tcm_qla2xxx, loopback and tcm_vhost fabric ports. Here is a bit more detail on each case: - iscsi-target: Bug with open-iscsi with overflow, sg_raw returns -3584 bytes of data. - tcm_qla2xxx: Working as expected, returnins 512 bytes of data - loopback: sg_raw returns CHECK_CONDITION, from overflow rejection in transport_generic_map_mem_to_cmd() - tcm_vhost: Same as loopback Reported-by: Roland Dreier <roland@purestorage.com> Cc: Roland Dreier <roland@purestorage.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-14target: fix NULL pointer dereference bug alloc_page() fails to get memoryYi Zou
commit d0e27c88d795fb9647153063ec48051fd84e1731 upstream. I am hitting this bug when the target is low in memory that fails the alloc_page() for the newly submitted command. This is a sort of off-by-one bug causing NULL pointer dereference in __free_page() since 'i' here is really the counter of total pages that have been successfully allocated here. Signed-off-by: Yi Zou <yi.zou@intel.com> Cc: Andy Grover <agrover@redhat.com> Cc: Nicholas Bellinger <nab@linux-iscsi.org> Cc: Open-FCoE.org <devel@open-fcoe.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-15target: Check number of unmap descriptors against our limitRoland Dreier
commit 7409a6657aebf8be74c21d0eded80709b27275cb upstream. Fail UNMAP commands that have more than our reported limit on unmap descriptors. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> [bwh: Backported to 3.2: adjust filename] Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-15target: Fix possible integer underflow in UNMAP emulationRoland Dreier
commit b7fc7f3777582dea85156a821d78a522a0c083aa upstream. It's possible for an initiator to send us an UNMAP command with a descriptor that is less than 8 bytes; in that case it's really bad for us to set an unsigned int to that value, subtract 8 from it, and then use that as a limit for our loop (since the value will wrap around to a huge positive value). Fix this by making size be signed and only looping if size >= 16 (ie if we have at least a full descriptor available). Also remove offset as an obfuscated name for the constant 8. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> [bwh: Backported to 3.2: adjust filename, context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-15target: Fix reading of data length fields for UNMAP commandsRoland Dreier
commit 1a5fa4576ec8a462313c7516b31d7453481ddbe8 upstream. The UNMAP DATA LENGTH and UNMAP BLOCK DESCRIPTOR DATA LENGTH fields are in the unmap descriptor (the payload transferred to our data out buffer), not in the CDB itself. Read them from the correct place in target_emulated_unmap. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> [bwh: Backported to 3.2: adjust filename, context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-15target: Add range checking to UNMAP emulationRoland Dreier
commit 2594e29865c291db162313187612cd9f14538f33 upstream. When processing an UNMAP command, we need to make sure that the number of blocks we're asked to UNMAP does not exceed our reported maximum number of blocks per UNMAP, and that the range of blocks we're unmapping doesn't go past the end of the device. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> [bwh: Backported to 3.2: adjust filename, context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-09iscsi-target: Drop bogus struct file usage for iSCSI/SCTPAl Viro
commit bf6932f44a7b3fa7e2246a8b18a44670e5eab6c2 upstream. From Al Viro: BTW, speaking of struct file treatment related to sockets - there's this piece of code in iscsi: /* * The SCTP stack needs struct socket->file. */ if ((np->np_network_transport == ISCSI_SCTP_TCP) || (np->np_network_transport == ISCSI_SCTP_UDP)) { if (!new_sock->file) { new_sock->file = kzalloc( sizeof(struct file), GFP_KERNEL); For one thing, as far as I can see it'not true - sctp does *not* depend on socket->file being non-NULL; it does, in one place, check socket->file->f_flags for O_NONBLOCK, but there it treats NULL socket->file as "flag not set". Which is the case here anyway - the fake struct file created in __iscsi_target_login_thread() (and in iscsi_target_setup_login_socket(), with the same excuse) do *not* get that flag set. Moreover, it's a bloody serious violation of a bunch of asserts in VFS; all struct file instances should come from filp_cachep, via get_empty_filp() (or alloc_file(), which is a wrapper for it). FWIW, I'm very tempted to do this and be done with the entire mess: Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Cc: Andy Grover <agrover@redhat.com> Cc: Hannes Reinecke <hare@suse.de> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-09target: Add generation of LOGICAL BLOCK ADDRESS OUT OF RANGERoland Dreier
commit e2397c704429025bc6b331a970f699e52f34283e upstream. Many SCSI commands are defined to return a CHECK CONDITION / ILLEGAL REQUEST with ASC set to LOGICAL BLOCK ADDRESS OUT OF RANGE if the initiator sends a command that accesses a too-big LBA. Add an enum value and case entries so that target code can return this status. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-16target: Fix range calculation in WRITE SAME emulation when num blocks == 0Roland Dreier
When NUMBER OF LOGICAL BLOCKS is 0, WRITE SAME is supposed to write all the blocks from the specified LBA through the end of the device. However, dev->transport->get_blocks(dev) (perhaps confusingly) returns the last valid LBA rather than the number of blocks, so the correct number of blocks to write starting with lba is dev->transport->get_blocks(dev) - lba + 1 (nab: Backport roland's for-3.6 patch to for-3.5) Signed-off-by: Roland Dreier <roland@purestorage.com> Cc: Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-07-16target: Clean up returning errors in PR handling codeRoland Dreier
- instead of (PTR_ERR(file) < 0) just use IS_ERR(file) - return -EINVAL instead of EINVAL - all other error returns in target_scsi3_emulate_pr_out() use "goto out" -- get rid of the one remaining straight "return." Signed-off-by: Roland Dreier <roland@purestorage.com> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-07-14tcm_fc: Fix crash seen with aborts and large readsMark Rustad
This patch fixes a crash seen when large reads have their exchange aborted by either timing out or being reset. Because the exchange abort results in the seq pointer being set to NULL, because the sequence is no longer valid, it must not be dereferenced. This patch changes the function ft_get_task_tag to return ~0 if it is unable to get the tag for this reason. Because the get_task_tag interface provides no means of returning an error, this seems like the best way to fix this issue at the moment. Signed-off-by: Mark Rustad <mark.d.rustad@intel.com> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-07-06tcm_fc: Resolve suspicious RCU usage warningsMark Rustad
Use rcu_dereference_protected to tell rcu that the ft_lport_lock is held during ft_lport_create. This resolved "suspicious RCU usage" warnings when debugging options are turned on. Signed-off-by: Mark Rustad <mark.d.rustad@intel.com> Tested-by: Ross Brattain <ross.b.brattain@intel.com> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-06-12target: Return error to initiator if SET TARGET PORT GROUPS emulation failsRoland Dreier
The error paths in target_emulate_set_target_port_groups() are all essentially "rc = -EINVAL; goto out;" but the code at "out:" ignores rc and always returns success. This means that even if eg explicit ALUA is turned off, the initiator will always see a good SCSI status for SET TARGET PORT GROUPS. Fix this by returning rc as is intended. It appears this bug was added by the following patch: commit 05d1c7c0d0db4cc25548d9aadebb416888a82327 Author: Andy Grover <agrover@redhat.com> Date: Wed Jul 20 19:13:28 2011 +0000 target: Make all control CDBs scatter-gather Signed-off-by: Roland Dreier <roland@purestorage.com> Cc: Andy Grover <agrover@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-06-12target: Add TFO->put_session() caller for HW fabric session shutdownJoern Engel
This patch adds an optional target_core_fabric_ops->put_session() caller within the existing target_put_session() code path. This is required by tcm_qla2xxx code in order to invoke it's own fabric specific session shutdown handler using se_session->sess_kref. Signed-off-by: Joern Engel <joern@logfs.org> Cc: Roland Dreier <roland@purestorage.com> Cc: Arun Easi <arun.easi@qlogic.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-06-02target/file: Use O_DSYNC by default for FILEIO backendsNicholas Bellinger
Convert to use O_DSYNC for all cases at FILEIO backend creation time to avoid the extra syncing of pure timestamp updates with legacy O_SYNC during default operation as recommended by hch. Continue to do this independently of Write Cache Enable (WCE) bit, as WCE=0 is currently the default for all backend devices and enabled by user on per device basis via attrib/emulate_write_cache. This patch drops the now unnecessary fd_buffered_io= token usage that was originally signalling when to explictly disable O_SYNC at backend creation time for buffered I/O operation. This can end up being dangerous for a number of reasons during physical node failure, so go ahead and drop this option for now when O_DSYNC is used as the default. Also allow explict FUA WRITEs -> vfs_fsync_range() call to function in fd_execute_cmd() independently of WCE bit setting. Reported-by: Christoph Hellwig <hch@lst.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-30sbp-target: rename a variable to avoid name clashStefan Richter
'int login_id' shadows 'static atomic_t login_id'. Seen as compilation warning on x86-32. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Acked-by: Chris Boot <bootc@bootc.net> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-23Merge branch 'sbp-target-merge' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending Pull sbp-2 (firewire) target mode support from Nicholas Bellinger: "The FireWire SBP-2 Target is a driver for using an IEEE-1394 connection as a SCSI transport. This module uses the SCSI Target framework to expose LUNs to other machines attached to a FireWire bus, in effect acting as a FireWire hard disk similar to FireWire Target Disk mode on many Apple computers. Also included are the two drivers/firewire/ patches required by sbp-target to access fw_request fabric speed needed for mgt_agent TCODE_WRITE_BLOCK_REQUEST ops, and exporting fw_card kref logic used when creating/destroying active session references to individual endpoints. A credit goes to Chris in being able to get this code up and running so quickly w/o any target core changes, and special thanks goes out to Stefan Richter + Clemens Ladisch + Andy Grover for their help in getting this driver ready for mainline. Also, one of Chris's goals was to be able to connect sbp-target to a PowerPC based MacOS-X based client, that he accomplished along the way in this obligatory screenshot: http://linux-iscsi.org/wiki/File:Linux-fireware-target-bootc-macosx.png Great work Chris + linux-1394 team !!" Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de> * 'sbp-target-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: sbp-target: Initial merge of firewire/ieee-1394 target mode support firewire: Move fw_card kref functions into linux/firewire.h firewire: Add function to get speed from opaque struct fw_request
2012-05-21Merge branch 'for-next' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 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 ...
2012-05-20iscsi-target: Fix iov_count calculation bug in iscsit_allocate_iovecsNicholas Bellinger
This patch fixes a bug in iscsit_allocate_iovecs() where iov_count was incorrectly calculated using min(1UL, data_length / PAGE_SIZE) instead of max(1UL, data_length / PAGE_SIZE), that ends up triggering an OOPs for large block I/O when the SGL <-> iovec mapping exceeds the bogus iov_count allocation size. This is a regression introduced during the iscsi-target conversion back to using core memory allocation here: commit bfb79eac2026b411df9e253a9c350039b4b04bb7 Author: Andy Grover <agrover@redhat.com> Date: Tue Apr 3 15:51:29 2012 -0700 target/iscsi: Go back to core allocating data buffer for cmd Cc: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-17iscsi-target: remove dead code in iscsi_check_valuelist_for_supportDan Carpenter
Neither "acceptor_values" nor "proposer_values" can be NULL here when scanning the value lists for incoming iSCSI login parameters such as HeaderDigest=CRC32C,None. Smatch complains because we are not allowed to pass NULL pointers to strchr(). Also I removed a second later check for "!acceptor_values" because it gets checked on the next line in the do while condition. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-17target: Fix bug in handling of FILEIO + block_device resize opsNicholas Bellinger
This patch fixes a bug in the handling of FILEIO w/ underlying block_device resize operations where the original fd_dev->fd_dev_size was incorrectly being used in fd_get_blocks() for READ_CAPACITY response payloads. This patch avoids using fd_dev->fd_dev_size for FILEIO devices with an underlying block_device, and instead changes fd_get_blocks() to get the sector count directly from i_size_read() as recommended by hch. Reported-by: Christoph Hellwig <hch@lst.de> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-17target: Handle ATA_16 passthrough for pSCSI backend devicesmengcong
The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs with a SATA CD-ROM. This patch adds support to it so that PSCSI CD-ROM passthrough works with the cdrecord. (nab: Add !passthrough check to prevent non pSCSI backends from ATA_16) Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-17target: Add MI_REPORT_TARGET_PGS ext. header + implict_trans_secs attributeNicholas Bellinger
This patch adds support for ALUA MI_REPORT_TARGET_PGS extended header format defined within SPC-4. It changes target core ALUA emulation logic within target_emulate_report_target_port_groups() to support both the extended and original length only header formats. It includes adding a new 'implict_trans_secs' attribute for each ALUA target port group to control the value returned to the application client for an recommended implict translation timeout in seconds. By default this value is currently set to zero, and limited up to 255 by virtue of using a single byte in the extended header format. This value is used by target_emulate_report_target_port_groups() within the extended header logic to set IMPLICIT TRANSITION TIME as defined by spc4r30. Cc: Hannes Reinecke <hare@suse.de> Cc: Rob Evers <revers@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-17target: Fix MAINTENANCE_IN service action CDB checks to use lower 5 bitsNicholas Bellinger
This patch fixes the MAINTENANCE_IN service action type checks to only look at the proper lower 5 bits of cdb byte 1. This addresses the case where MI_REPORT_TARGET_PGS w/ extended header using the upper three bits of cdb byte 1 was not processed correctly in transport_generic_cmd_sequencer, as well as the three cases for standby, unavailable, and transition ALUA primary access state checks. Also add MAINTENANCE_IN to the excluded list in transport_generic_prepare_cdb() to prevent the PARAMETER DATA FORMAT bits from being cleared. Cc: Hannes Reinecke <hare@suse.de> Cc: Rob Evers <revers@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-15target: add support for the WRITE_VERIFY commandBernhard Kohl
Some legacy OS use WRITE_VERIFY on hard disks. Signed-off-by: Bernhard Kohl <bernhard.kohl@gmx.net> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-14target: Fix SPC-2 RELEASE bug for multi-session iSCSI client setupsBernhard Kohl
This patch addresses a bug in a special case for target core SPC-2 RELEASE logic where the same physical client (eg: iSCSI InitiatorName) with differing iSCSI session identifiers (ISID) is allowed to incorrectly release the same client's SPC-2 reservation from the non reservation holding path. Note this bug is specific to iscsi-target w/ SPC-2 reservations, and with the default enforce_pr_isids=1 device attr setting in target-core controls if a InitiatorName + different ISID reservations are handled the same as a single iSCSI client entity. Signed-off-by: Bernhard Kohl <bernhard.kohl@gmx.net> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-11target: make target_put_session voidJörn Engel
No real change, it effectively already was. Signed-off-by: Joern Engel <joern@logfs.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-11target: cleanup transport_execute_tasks()Jörn Engel
The function is effectively void and doesn't need any goto logic. Signed-off-by: Joern Engel <joern@logfs.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-11target: Drop incorrect se_lun_acl release for dynamic -> explict ACL conversionNicholas Bellinger
This patch removes some potentially problematic legacy code within core_clear_initiator_node_from_tpg() that was originally intended to release left over se_lun_acl setup during dynamic NodeACL+MappedLUN generate when running with TPG demo-mode operation. Since we now only ever expect to allocate and release se_lun_acl from within target_core_fabric_configfs.c:target_fabric_make_mappedlun() and target_fabric_drop_mappedlun() context respectively, this code for demo-mode release is incorrect and needs to be removed. Cc: Christoph Hellwig <hch@lst.de> Cc: Andy Grover <agrover@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-09sbp-target: Initial merge of firewire/ieee-1394 target mode supportChris Boot
The FireWire SBP-2 Target is a driver for using an IEEE-1394 connection as a SCSI transport. This module uses the SCSI Target framework to expose LUNs to other machines attached to a FireWire bus, in effect acting as a FireWire hard disk similar to FireWire Target Disk mode on many Apple computers. This commit contains the squashed pull from Chris Boot's SBP-2-Target: https://github.com/bootc/Linux-SBP-2-Target.git patch-v3 firewire-sbp-target: Add sbp_base.h header firewire-sbp-target: Add sbp_configfs.c firewire-sbp-target: Add sbp_fabric.{c,h} firewire-sbp-target: Add sbp_management_agent.{c,h} firewire-sbp-target: Add sbp_login.{c,h} firewire-sbp-target: Add sbp_target_agent.{c,h} firewire-sbp-target: Add sbp_scsi_cmnd.{c,h} firewire-sbp-target: Add to target Kconfig and Makefile Also add bootc's entry to the MAINTAINERS file. Great work Chris !! Signed-off-by: Chris Boot <bootc@bootc.net> Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Cc: Andy Grover <agrover@redhat.com> Cc: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-09target: Remove max_sectors device attribute for modern se_task less codeNicholas Bellinger
This patch removes the original usage of dev_attr->max_sectors in favor of dev_attr->hw_max_sectors that is now being enforced by target core from within transport_generic_cmd_sequencer() for SCF_SCSI_DATA_SG_IO_CDB ops. After the recent se_task removal patches from hch, this value for IBLOCK backends being set via configfs by userspace from an saved max_sectors value that is turning out to be problematic, so it makes sense to go ahead and remove this now legacy attribute all-together. This patch also continues to make se_dev_set_default_attribs() do (sectors / block_size) alignment for what actually get used by target_core_mod to be safe here, following the same alignment currently used by fabric_max_sectors. Reported-by: Andy Grover <agrover@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-09target: lock => unlock typo in transport_lun_wait_for_tasksDan Carpenter
target_stop_cmd() returns with the lock held and IRQs disabled. The intent was to unlock here. This bug was originally added with: commit cf572a9627c9ae86082216de109780c1d2e2ee28 Author: Christoph Hellwig <hch@infradead.org> Date: Tue Apr 24 00:25:05 2012 -0400 target: move the state and execute lists to the command Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-09target: Enforce hw_max_sectors for SCF_SCSI_DATA_SG_IO_CDBNicholas Bellinger
Instead of depending upon a max_sectors value that may be set via configfs based upon original HW queue limitations, go ahead and convert to using the hw_max_sectors reported by the backend device in order to determine when to reject an I/O's who's sector count exceeds what is supported by the backend with a single se_cmd descriptor. It addresses a potential case where se_dev_attrib.max_sectors for IBLOCK backends has already been set via queue_max_sectors() to something small like max_sectors=32 (LVM, DRBD may do this), resulting typically sized SCF_SCSI_DATA_SG_IO_CDB to be incorrectly rejected with invalid_cdb_field in transport_generic_cmd_sequencer(). Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Roland Dreier <roland@purestorage.com> Cc: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove the t_se_count field in struct se_cmdChristoph Hellwig
Now that tasks are gone we are guaranteed to only get a single completion per command, and thus don't need this counter. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove the t_task_cdbs_ex_left field in struct se_cmdChristoph Hellwig
Now that tasks are gone we are guaranteed to only get a single completion per command, and thus don't need this counter. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove the t_task_cdbs_left field in struct se_cmdChristoph Hellwig
Now that tasks are gone we are guaranteed to only get a single completion per command, and thus don't need this counter. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove struct se_taskChristoph Hellwig
We can use struct se_cmd for everything it did. Make sure to pass the S/G list and data direction to the execution function to ease adding back BIDI support later on. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: move the state and execute lists to the commandChristoph Hellwig
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: simplify command to task linkageChristoph Hellwig
Now that we only have a single task per command we can use a direct pointer to it instead of list. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: always allocate a single taskChristoph Hellwig
Simply transport_generic_new_cmd to only allocate a single task. For normal unidirection commands nothing changes except that the code is a lot simpler now. Any BIDI support that used to work will stop now for the next few patches at least. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: replace ->execute_task with ->execute_cmdChristoph Hellwig
Make CDB emulation work on commands instead of tasks again as a preparation of removing tasks completely. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove the task_sectors field in struct se_taskChristoph Hellwig
Remove the task_sectors field that isn't used anywhere. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove the task_size field in struct se_taskChristoph Hellwig
Now that we don't split commands the size field in the task is always equivalent to the one in the CDB, even in cases where we have two tasks due to a BIDI transfer. Just refer the the size in the command instead of duplicating it in the task. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove the task_lba field in struct se_taskChristoph Hellwig
Now that we don't split commands the lba field in the task is always equivalent to the one in the CDB, even in cases where we have two tasks due to a BIDI transfer. Just refer the the lba in the command instead of duplicating it in the task. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove target_get_task_cdbChristoph Hellwig
Now that tasks are always the same size as the command there is no need to rewrite a CDB in common code. Notw that we keep the separately allocated CDB in the pscsi and stgt backends for now, to easy reintroducing any command splitting local to these backends if nessecary. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: remove the unused transport_limit_task_sectors helperChristoph Hellwig
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target: Handle GET_EVENT_STATUS_NOTIFICATION passthroughStefan Hajnoczi
The SCSI MMC GET_EVENT_STATUS_NOTIFICATION command can be used to find out about media change, among other things. This patch adds it to the command sequencer so that PSCSI CD-ROM passthrough works with modern Linux guests that issue this command. Tested-by: Cong Meng <mengcong@cn.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-05-06target/iscsi: cleanup some allocation style issuesDan Carpenter
We can use kcalloc() here instead of kzalloc(). It's better style and it has overflow checking built in. Also -ENOMEM is the correct error code for allocation errors. -1 means -EPERM. None of the callers preserve the error codes so it doesn't matter except as a cleanup. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2012-04-14target/iscsi: Go back to core allocating data buffer for cmdAndy Grover
We originally changed iscsi to allocate its own buffers just as an intermediate step to clean up some core buffer allocation mechanisms. Now we can put it back. Also had to change allocate_iovecs to use data_length instead of t_data_nents because iovecs are now allocated before the data buffer, thus t_data_nents is not yet initialized. Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>