summaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_spc.c
Commit message (Collapse)AuthorAgeFilesLines
* target: Export SPC inquiry emulationHannes Reinecke2013-02-131-3/+5
| | | | | | | | | | Some target drivers might need to access the inquiry data directly, without sending out the actual command. So export these functions. Signed-off-by: Hannes Reinecke <hare@suse.de> Cc: Nicholas Bellinger <nab@risingtidesystems.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Fix zero-length MODE_SENSE regressionNicholas Bellinger2013-01-291-28/+7Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a regression introduced in v3.8-rc1 code where a zero-length MODE_SENSE was no longer returning GOOD status, but instead returning TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE to generate a CHECK_CONDITION status. This regression was introduced with the following commit: commit de103c93aff0bed0ae984274e5dc8b95899badab Author: Christoph Hellwig <hch@lst.de> Date: Tue Nov 6 12:24:09 2012 -0800 target: pass sense_reason as a return value and this patch has been tested with the following zero-length CDB: sg_raw /dev/sdd 5a 00 0a 00 00 00 00 00 00 00 SCSI Status: Good Sense Information: sense buffer empty Cc: Christoph Hellwig <hch@lst.de> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Fix zero-length INQUIRY additional sense code regressionNicholas Bellinger2013-01-291-5/+4Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a minor regression introduced in v3.8-rc1 code where a zero-length INQUIRY was no longer returning the correct INVALID FIELD IN CDB additional sense code. This regression was introduced with the following commit: commit de103c93aff0bed0ae984274e5dc8b95899badab Author: Christoph Hellwig <hch@lst.de> Date: Tue Nov 6 12:24:09 2012 -0800 target: pass sense_reason as a return value and this patch has been tested with the following zero-length CDB: sg_raw /dev/sdd 12 00 83 00 00 00 SCSI Status: Check Condition Sense Information: Fixed format, current; Sense key: Illegal Request Additional sense: Invalid field in cdb Cc: Christoph Hellwig <hch@lst.de> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Update copyright information to 2012Nicholas Bellinger2012-11-281-4/+1Star
| | | | | | | | v2: Use correct target_core_stat.c 2006 copyright year v3: Drop extra unnessary legal verbage from header (hch) Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Add/check max_write_same_len device attribute + update block limits VPDNicholas Bellinger2012-11-151-1/+7
| | | | | | | | | | | | | | | | | | | This patch adds a new max_write_same_len device attribute for use with WRITE_SAME w/ UNMAP=0 backend emulation. This can be useful for lowering the default backend value (IBLOCK uses 0xFFFF). Also, update block limits VPD emulation code in spc_emulate_evpd_b0() to report MAXIMUM WRITE SAME LENGTH, and enforce max_write_same_len during sbc_parse() -> sbc_setup_write_same() CDB sanity checking for all emulated WRITE_SAME w/ UNMAP=0 cases. (Robert: Move max_write_same_len check in sbc_setup_write_same() to check both WRITE_SAME w/ UNMAP=1 and w/ UNMAP=0 cases) Cc: Christoph Hellwig <hch@lst.de> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Robert Elliott <Elliott@hp.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: pass sense_reason as a return valueChristoph Hellwig2012-11-071-63/+63
| | | | | | | | | | | | | | | Pass the sense reason as an explicit return value from the I/O submission path instead of storing it in struct se_cmd and using negative return values. This cleans up a lot of the code pathes, and with the sparse annotations for the new sense_reason_t type allows for much better error checking. (nab: Convert spc_emulate_modesense + spc_emulate_modeselect to use sense_reason_t with Roland's MODE SELECT changes) Signed-off-by: Christoph Hellwig <hch@lst.de> Cc: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Fix incorrect starting offset after MODE_SENSE refactoringNicholas Bellinger2012-11-071-2/+5
| | | | | | | | | | | | | | | | This patch fixes a new off-by-one bug in the hardcoded starting offset of spc_emulate_modesense() code that causes BLOCK DESCRIPTOR to be incorrectly written within the MEDIUM TYPE buffer area of the mode parameter header. According to spc4r30, Section 7.5.4, BLOCK DESCRIPTOR for MODE_SENSE_10 starts at byte 3, and BLOCK_DESCRIPTOR for MODE_SENSE (6) starts at byte 2. (roland: add MODE DATA LENGTH + MEDIUM TYPE offset comment) Cc: Roland Dreier <roland@purestorage.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Add emulation for MODE SELECTRoland Dreier2012-11-071-0/+53
| | | | | | | | | | This is another thing that compliance tests try, and it's easy to implement on top of the MODE SENSE refactoring; since we don't claim to support any changeable values, all we need to do is check that the page contents sent by the initiator match what we would return. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Implement mode page 0x1c, "Informational Exceptions"Roland Dreier2012-11-071-0/+14
| | | | | | | | | The Windows SCSI compliance test asks for this mode page, and it's easy to implement: we can just return all 0s to show we don't support any of these features. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Refactor MODE SENSE emulationRoland Dreier2012-11-071-59/+176
| | | | | | | | | | | | | | | | | | | Convert spc_emulate_modesense() to use a table of mode pages, rather than a switch statement. This makes it possible to add more pages sanely -- in particular we no longer need to make sure we keep the 0x3f (return all mode pages) case in sync. While we're touching this code, make our MODE SENSE emulation a bit better in a couple of ways: - When the initiator passes PC == 1 asking for changeable values, return all 0s to show we don't support setting anything. - Return a block descriptor for disk devices. (nab: fix up device attribute references to use dev->dev_attrib in for-next code) Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: remove ->get_device_revChristoph Hellwig2012-11-071-1/+1
| | | | | | | | | Now that the reservations and ALUA code have been cleaned up there is no need for the get_device_rev method, as we only need the standards revision in the inquiry data, where we can hardcode it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: simplify alua supportChristoph Hellwig2012-11-071-9/+3Star
| | | | | | | | We always support ALUA for virtual backends, and never for physical ones. Simplify the code to just deal with these two cases and remove the superflous abstractions. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: simplify reservations codeChristoph Hellwig2012-11-071-15/+4Star
| | | | | | | | | | | | We do not support host-level reservations for the pscsi backend, and all virtual backends are newere than SCSI-2, so just make the combined SPC-3 + SCSI-2 support the only supported variant and kill the switches for the different implementations, given that this code handles the no-op version just fine. (hch: Update DRF_SPC2_RESERVATIONS lock usage) Signed-off-by: Christoph Hellwig <hch@lst.de>
* target: kill dev->dev_task_attr_typeChristoph Hellwig2012-11-071-4/+2Star
| | | | | | | We can just key off ordered tag emulation of the transport_type field. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target/pscsi: call spc_emulate_report_luns directlyChristoph Hellwig2012-11-071-1/+2
| | | | | | | | | | No need to indirect through spc_parse_cdb if we only ever call it for REPORT LUNS emulation. (nab: Add missing EXPORT_SYMBOL for spc_emulate_report_luns) Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: move REPORT LUNS emulation to target_core_spc.cChristoph Hellwig2012-11-071-1/+64
| | | | | Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: kill struct se_subsystem_devChristoph Hellwig2012-11-071-49/+42Star
| | | | | | | | | | Simplify the code a lot by killing the superflous struct se_subsystem_dev. Instead se_device is allocated early on by the backend driver, which allocates it as part of its own per-device structure, borrowing the scheme that is for example used for inode allocation. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Re-add explict zeroing of INQUIRY bounce buffer memoryNicholas Bellinger2012-11-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a regression in spc_emulate_inquiry() code where the local scope bounce buffer was no longer getting it's memory zeroed, causing various problems with SCSI initiators that depend upon areas of INQUIRY EVPD=0x83 payload having been zeroed. This bug was introduced with the following v3.7-rc1 patch + CC'ed stable commit: commit ffe7b0e9326d9c68f5688bef691dd49f1e0d3651 Author: Paolo Bonzini <pbonzini@redhat.com> Date: Fri Sep 7 17:30:38 2012 +0200 target: support zero allocation length in INQUIRY Go ahead and re-add the missing memset of bounce buffer memory to be copied into the outgoing se_cmd descriptor kmapped SGL payload. Reported-by: Kelsey Prantis <kelsey.prantis@intel.com> Cc: Kelsey Prantis <kelsey.prantis@intel.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Andy Grover <agrover@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: fix truncation of mode data, support zero allocation lengthPaolo Bonzini2012-09-181-10/+7Star
| | | | | | | | | | | | | | | | | | The offset was not bumped back to the full size after writing the header of the MODE SENSE response, so the last 1 or 2 bytes were not copied. On top of this, support zero-length requests by checking for the return value of transport_kmap_data_sg. Testcase: sg_raw -r20 /dev/sdb 5a 00 0a 00 00 00 00 00 14 00 last byte should be 0x1e it is 0x00 without the patch it is correct with the patch Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: support zero allocation length in INQUIRYPaolo Bonzini2012-09-181-25/+6Star
| | | | | | | | | | | | | | | | | INQUIRY processing already uses an on-heap bounce buffer for loopback, but not for other fabrics. Switch this to a cheaper on-stack bounce buffer, similar to the one used by MODE SENSE and REQUEST SENSE, and use it unconditionally. With this in place, zero allocation length is handled simply by checking the return address of transport_kmap_data_sg. Testcase: sg_raw /dev/sdb 12 00 83 00 00 00 should fail with ILLEGAL REQUEST / INVALID FIELD IN CDB sense does not fail without the patch fails correctly with the series Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: stable@vger.kernel.org Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: support zero allocation length in REQUEST SENSEPaolo Bonzini2012-09-071-17/+18
| | | | | | | | | | | | | | | | | | | | | | Similar to INQUIRY and MODE SENSE, construct the sense data in a buffer and later copy it to the scatterlist. Do not do anything, but still clear a pending unit attention condition, if the allocation length is zero. However, SPC tells us that "If a REQUEST SENSE command is terminated with CHECK CONDITION status [and] the REQUEST SENSE command was received on an I_T nexus with a pending unit attention condition (i.e., before the device server reports CHECK CONDITION status), then the device server shall not clear the pending unit attention condition." Do the transport_kmap_data_sg early to detect this case. It also tells us "Device servers shall not adjust the additional sense length to reflect truncation if the allocation length is less than the sense data available", so do not do that! Note that the err variable is write-only. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: Move MAINTENANCE_[IN,OUT] from pscsi_parse_cdb -> spc_parse_cdbNicholas Bellinger2012-07-171-1/+41
| | | | | | | | | The MAINTENANCE_[IN,OUT] CDB parsing required for generic ALUA emulation needs to be in spc_parse_cdb() to function for virtual TYPE_DISK exports, instead of in backend pscsi_parse_cdb() code used only for passthrough ops. Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: move code for CDB emulationChristoph Hellwig2012-07-171-11/+905
| | | | | | | | | | | Move the existing code in target_core_cdb.c into the files for the command sets that the emulations implement. (roland + nab: Squash patch: Fix range calculation in WRITE SAME emulation when num blocks == 0s) Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: add a parse_cdb method to the backend driversChristoph Hellwig2012-07-171-0/+1
| | | | | | | | | | | | | | | | Instead of trying to handle all SCSI command sets in one function (transport_generic_cmd_sequencer) call out to the backend driver to perform this functionality. For pSCSI a copy of the existing code is used, but for all virtual backends we can use a new parse_sbc_cdb helper is used to provide a simple SBC emulation. For now this setups means a fair amount of duplication between pSCSI and the SBC library, but patches later in this series will sort out that problem. (nab: Fix up build failure in target_core_pscsi.c) Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
* target: split parsing of SPC commands into a separate helperChristoph Hellwig2012-07-171-0/+169
(nab: Add EXPORT_SYMBOL usage for spc_parse_cdb) Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>