Commit Graph

1412 Commits

Author SHA1 Message Date
mav
0468376762 MFC r268302:
Pass through iSCSI session ISID from LOGIN request to the CTL frontend.

ISID is an important part of initiator transport ID for iSCSI.  It is not
used now, but should be to properly implement persistent reservation.
2014-07-15 17:07:07 +00:00
mav
f1200cac15 MFC r268293:
Burry devid port method, which was a gross hack.

Instead make ports provide wanted port and target IDs, and LUNs provide
wanted LUN IDs.  After that core Device ID VPD code only had to link all
of them together and add relative port and port group numbers.

LUN ID for iSCSI LUNs no longer created by CTL, but by ctld, and passed
to CTL as "scsiname" LUN option.  This makes LUNs to report the same set
of IDs, independently from the port through which it is accessed, as
required by SCSI specifications.
2014-07-15 17:06:10 +00:00
mav
b40b547aa1 MFC r268291:
Create separate CTL port for every iSCSI target (and maybe portal group).

Having single port for all iSCSI connections makes problematic implementing
some more advanced SCSI functionality in CTL, that require proper ports
enumeration and identification.

This change extends CTL iSCSI API, making ctld daemon to control list of
iSCSI ports in CTL.  When new target is defined in config fine, ctld will
create respective port in CTL.  When target is removed -- port will be
also removed after all active commands through that port properly aborted.
This change require ctld to be rebuilt to match the kernel.

As a minor side effect, this allows to have iSCSI targets without LUNs.
While that may look odd and not very useful, that is not incorrect.
2014-07-15 17:05:11 +00:00
mav
5df1093df8 MFC r268288:
Improve CTL_BEARG_* flags support, including optional values copyout.
2014-07-15 17:01:39 +00:00
mav
c09a8b3510 MFC r268287:
Implement and use ctl_frontend_find().
2014-07-15 17:00:41 +00:00
mav
7da5c8a0d6 MFC r268284:
Introduce new IOCTL CTL_PORT_LIST reporting in more flexible XML format.

Leave old CTL_GET_PORT_LIST in place so far.  Garbage-collect it later.
2014-07-15 16:59:46 +00:00
mav
639ef1613c MFC r268280:
Make options KPI more generic to allow it to be used for ports too,
not only for LUNs.
2014-07-15 16:58:38 +00:00
mav
8bfe00fd8a MFC r268266, r268275:
Separate concepts of frontend and port.

Before iSCSI implementation CTL had no knowledge about frontend drivers,
it had only frontends, which really were ports (alike to LUNs, if comparing
to backends).  But iSCSI added there ioctl() method, which does not belong
to frontend as a port, but belongs to a frontend driver.
2014-07-15 16:57:30 +00:00
mav
e396aeead5 MFC r268265:
Remove targ_enable()/targ_disable() frontend methods.

Those methods were never implemented, and I believe that their concept is
wrong, since single frontend (SCSI port) can not handle several targets.
2014-07-15 16:55:13 +00:00
mav
75f2a98771 MFC r268103:
Add support for REPORT TIMESTAMP command.
2014-07-15 16:54:04 +00:00
mav
da977d4032 MFC r268096, r268306, r268361:
Add more formal and strict command parsing and validation.

For every supported command define CDB length and mask of bits that are
allowed to be set.  This allows to remove bunch of checks through the code
and still make the validation more strict.  To properly do it for commands
supporting multiple service actions, formalize their parsing by adding
subtables for each of such commands.

As visible effect, this change allows to add support for REPORT SUPPORTED
OPERATION CODES command, reporting to client all the data about supported
SCSI commands, except timeouts.
2014-07-15 16:53:04 +00:00
mav
a64cd56a0c MFC r267639:
Increase CTL_DEVID_LEN from 16 to 64 bytes.

SPC-4 recommends T10 vendor ID based LUN ID was created by concatenating
product name and serial number (and istgt follows that).  But product name
is 16 bytes long by itself, so 16 bytes total length is clearly not enough
to fit both.

To keep compatibility with existing configurations, pad short device IDs
to old length of 16, same as before.

This change probably breaks CTL user-level ABI, so control tools should
be rebuilt after this change.
2014-07-15 16:49:35 +00:00
mav
fe5b2cf89f MFC r267643, r267873, r268391, r268398:
Introduce fine-grained CTL locking to improve SMP scalability.

Split global ctl_lock, historically protecting most of CTL context:
 - remaining ctl_lock now protects lists of fronends and backends;
 - per-LUN lun_lock(s) protect LUN-specific information;
 - per-thread queue_lock(s) protect request queues.
This allows to radically reduce congestion on ctl_lock.

Create multiple worker threads, depending on number of CPUs, and assign
each LUN to one of them.  This allows to spread load between multiple CPUs,
still avoiging congestion on queues and LUNs locks.

On 40-core server, exporting 5 LUNs, each backed by gstripe of SATA SSDs,
accessed via 6 iSCSI connections, this change improves peak request rate
from 250K to 680K IOPS.

Sponsored by:	iXsystems, Inc.
2014-07-12 04:34:39 +00:00
mav
48e8be2fd2 MFC r268283:
Improve readability of XML generated by CTL_LUN_LIST.
2014-07-12 02:40:25 +00:00
mav
59eea8bc78 MFC r268392:
Do not return statuses for aborted iSCSI commands.
2014-07-12 02:33:03 +00:00
mav
593a15490b MFC r268204:
Use separate memory type M_CTLIO for I/Os.

CTL allocate large amount of RAM.  This change give some more stats.
2014-07-12 02:29:33 +00:00
mav
e1151dc51c MFC r267933:
Simplify statistics calculation.

Instead of trying to guess size of disk I/O operations (it just won't work
that way for newly added commands, and is equal to data move size for old
ones), account data move traffic.  If disk I/Os are that interesting, then
backends have to account and provide that information.

Block backend already exports the information about disk I/Os via devstat,
so having it here too is excessive.
2014-07-12 02:28:11 +00:00
mav
dcab9610fe MFC r267906:
Allow MODE SENSE commands through Write Exclusive persistent reservation,
as required by SPC-4.

Report that fact in persistent reservation capabilities.
2014-07-12 02:26:11 +00:00
mav
38fbbeedce MFC r267905:
Add READ BUFFER and improve WRITE BUFFER SCSI commands support.

This gives some use to 512KB per-LUN buffers, allocated for Copan-specific
processor code and not used.  It allows, for example, to test transport
performance and/or correctness without accessing the media, as supported
by Linux version of sg3_utils.
2014-07-12 02:24:52 +00:00
mav
a52f21b413 MFC r267877:
Lock devstat updates in block backend to make it usable.  Polish lock names.
2014-07-12 02:17:10 +00:00
mav
51dd83f4d5 MFC r268419:
Fix use-after-free on XPT_RESET_BUS.

That command is not queued, so does not use later status update.
2014-07-12 02:03:29 +00:00
mav
95c9d23391 MFC r267986:
Remove odd practice of inverting error codes.

-EPERM is equal to ERESTART, returning which from ioctl() handler causes
infinite syscall restart.
2014-07-12 01:59:07 +00:00
mav
dc2d478426 MFC r267641:
Add some more CTL_FLAG_ABORT check points.

This should allow to abort commands doing mostly disk I/O, such as VERIFY
or WRITE SAME.  Before this change CTL_FLAG_ABORT was only checked around
data moves, which for these commands may not happen for a very long time.
2014-07-04 16:11:30 +00:00
mav
37a9790756 MFC r267637:
Add iSCSI Target Name ID descriptor to VPD 83h.

It shall/should be there according to SPC-4, and istgt also provides it.
2014-07-04 16:10:14 +00:00
mav
8eb696c14e MFC r267610 (by trasz):
Rework session termination in iSCSI target to actually wait
for any outstanding commands to be properly aborted by CTL.
Without it, in some cases (such as files backing the LUNs
stored on failing disk drives), terminating a busy session
would result in panic.
2014-07-04 16:09:09 +00:00
mav
f736ccce13 MFC r267574 (by trasz):
Make cs_terminating a bool; no functional changes.
2014-07-04 16:07:57 +00:00
mav
cfae63c84f MFC r267547, r267551 (by trasz):
Add LUN-associated name to VPD, to make Hyper-V Failover Cluster happy.
2014-07-04 16:06:56 +00:00
mav
526d9691dc MFC r267051:
- Add support for SG_GET_SG_TABLESIZE IOCTL to report that we don't support
scatter/gather lists.
- Return error for still unsupported SG 3.x API read/write calls.
2014-07-04 15:09:56 +00:00
mav
2019810069 MFC r267537:
Add support for VERIFY(10/12/16) and COMPARE AND WRITE SCSI commands.

Make data_submit backends method support not only read and write requests,
but also two new ones: verify and compare.  Verify just checks readability
of the data in specified location without transferring them outside.
Compare reads the specified data and compares them to received data,
returning error if they are different.

VERIFY(10/12/16) commands request either verify or compare from backend,
depending on BYTCHK CDB field.  COMPARE AND WRITE command executed in two
stages: first it requests compare, and then, if succeesed, requests write.
Atomicity of operation is guarantied by CTL request ordering code.

Sponsored by:	iXsystems, Inc.
2014-07-02 10:45:31 +00:00
mav
ada40bacc7 MFC r267519:
Make backends track completion by processed number of sectors instead of
total transfer size.

Commands such as VERIFY or COMPARE AND WRITE may have transfer size not
matching directly to number of sectors.
2014-07-02 10:43:53 +00:00
mav
15c36a3817 MFC r267515:
Remove memcpy() from ctl_private[] accesses.

That union is aligned enough to access data directly.
2014-07-02 10:42:43 +00:00
mav
27197291fa MFC r267514:
Move kern_total_len setting from backend to core code.
2014-07-02 10:41:11 +00:00
mav
cf9ef68328 MFC r267500:
Format Portal Group Tag same as istgt does -- %4.4x instead of %x.

SPC-4 spec tells it should be "two or more hexadecimal digits".
RFC3720 tells it is 16-bit value.
2014-07-02 10:39:45 +00:00
mav
9389599de5 MFC r267499:
Remove custom processing for "file" option.
2014-07-02 10:38:22 +00:00
mav
eeaafb7fba MFC r267496, r267498:
Add "vendor", "product" and "revision" options to control inquiry data.
2014-07-02 10:37:22 +00:00
mav
a615b5284a MFC r267485:
Remove non-functional remnants of control LUN -- 18MB of RAM for nothing.
2014-07-02 10:36:04 +00:00
mav
a7e3ab1dac MFC r267481, r267952:
Implement small KPI to access LUN options instead doing it by hands.
2014-07-02 10:35:06 +00:00
mav
f77bfe41e2 MFC r265323 (by trasz):
Provide better descriptions for 'struct ctl_scsiio' fields; based mostly
on emails from ken@.
2014-07-02 10:32:44 +00:00
mav
9922777340 MFC r267872:
Allow to use iSCSI immediate data by several ctl_datamove() calls.

While for FreeBSD client that is only a minor optimization, VMWare client
doesn't support additional data requests after all data being sent once as
immediate.
2014-07-02 10:20:08 +00:00
mav
927a52fbbf MFC r266981:
Overhaul CAM SG driver IOCTL interfaces.

Make it really work for native FreeBSD programs.  Before this it was broken
for years due to different number of pointer dereferences in Linux and
FreeBSD IOCTL paths, permanently returning errors to FreeBSD programs.
This change breaks the driver FreeBSD IOCTL ABI, making it more strict,
but since it was not working any way -- who bother.

Add shims for 32-bit programs on 64-bit host, translating the argument
of the SG_IO IOCTL for both FreeBSD and Linux ABIs.

With this change I was able to run 32-bit Linux sg3_utils tools and simple
32 and 64-bit FreeBSD test tools on both 32 and 64-bit FreeBSD systems.
2014-07-02 10:16:12 +00:00
marius
27080bb5dd MFC: r267638
Don't denounce peripherals on system shutdown. Together with r267321
(MFCed to stable/10 in r267775), we're now back to the pre-r228483
level of default verbosity. This in turn again typically allows for
reading information that userland might have printed on the screen
before initiating a halt, but still permits to debug potential device
shutdown problems on system shutdown via CAM_DEBUG etc.

Reviewed by:	mav
Sponsored by:	Bally Wulff Games & Entertainment GmbH
2014-06-23 08:32:36 +00:00
mav
afa2d243ef MFC r267429:
Fix some leaks on LUN creation error.
2014-06-22 21:28:05 +00:00
mav
8c42300872 MFC r265159:
Respect MAXIMUM TRANSFER LENGTH field of Block Limits VPD page.

Nobody yet reported disk supporting I/Os less then our MAXPHYS value, but
since we any way have code to read Block Limits VPD page, that is easy.
2014-05-08 07:13:22 +00:00
mav
878513ca7d MFC r265150:
Do not reread SCSI disk VPD pages on every device open.

Instead of rereading VPD pages on every device open, do it only on initial
device probe, and in cases when device reported via UNIT ATTENTIONs that
something has changed.  Capacity is still rereaded on every open because
it is more critical for operation and more probable to change in run time.

On my tests with Intel 530 SSDs on mps(4) HBA this change reduces time
GEOM needs to retaste the device (that includes few open/close cycles)
from ~150ms to ~30ms.
2014-05-08 07:12:06 +00:00
mav
c2e87a8026 MFC r264886:
Remove limits on size of READ/WRITE operations.

Instead of allocating up to 16MB or RAM at once to handle whole I/O,
allocate up to 1MB at a time, but do multiple ctl_datamove() and storage
I/Os if needed.
2014-05-08 07:10:38 +00:00
mav
e2d7108ca8 MFC r264884:
Make CAM target CTL frontend respect SIM I/O size limitations.

If datamove size is bigger then SIM can handle, or it has more segments
then this code can handle -- split it into several CTIO requests.
2014-05-08 07:08:47 +00:00
mav
84e0de396e MFC r264880 (by trasz):
Modify CTL iSCSI frontend to properly handle situations where datamove
routine is called multiple times per SCSI task.
2014-05-08 07:07:51 +00:00
mav
df5d1f3a9b MFC r264834:
Disable UNMAP support for STEC 842 SSDs.

In some unknown cases UNMAP commands make device firmware stuck.
2014-05-08 07:05:19 +00:00
mav
1252c77788 MFC r264407:
Join CTL worker threads into one process for convenience.
Report their idle state as "-".
2014-05-08 07:04:13 +00:00
mav
9f15393e22 MFC r264406:
Report more readable state "-" for idle CAM scan thread.
2014-05-08 07:01:54 +00:00
mav
2d5dc4736b MFC r264274, r264279, r264283, r264296, r264297:
Add support for SCSI UNMAP commands to CTL.

This patch adds support for three new SCSI commands: UNMAP, WRITE SAME(10)
and WRITE SAME(16).  WRITE SAME commands support both normal write mode
and UNMAP flag.  To properly report UNMAP capabilities this patch also adds
support for reporting two new VPD pages: Block limits and Logical Block
Provisioning.

UNMAP support can be enabled per-LUN by adding "-o unmap=on" to `ctladm
create` command line or "option unmap on" to lun sections of /etc/ctl.conf.

At this moment UNMAP supported for ramdisks and device-backed block LUNs.
It was tested to work great with ZFS ZVOLs.  For file-backed LUNs UNMAP
support is unfortunately missing due to absence of respective VFS KPI.

Sponsored by:   iXsystems, Inc
2014-05-08 07:00:45 +00:00
mav
246a5ae3a0 MFC r260509:
Replace several instances of -1 with appropriate CAM_*_WILDCARD and types.

It was equal before r259397, but for good or bad, not any more for LUNs.

This change fixes at least CAM debugging.
2014-05-08 06:55:48 +00:00
trasz
21ec0cf2d0 MFC r264530:
Properly pass the initiator address when running in proxy mode.

Sponsored by:	The FreeBSD Foundation
2014-05-07 07:37:55 +00:00
trasz
1abd1411d7 MFC r264527:
Make it possible to interrupt login when running in proxy mode.

Sponsored by:	The FreeBSD Foundation
2014-05-07 07:33:56 +00:00
trasz
f2085cbf68 MFC r264526:
Properly identify target portal when running in proxy mode.  While here,
remove CTL_ISCSI_CLOSE, it wasn't used or implemented anyway.

Sponsored by:	The FreeBSD Foundation
2014-05-07 07:32:45 +00:00
trasz
f86dc9fb87 MFC r264525:
Add some stuff to make it easier to figure out for the system administrator
whether the ICL_KERNEL_PROXY stuff got compiled in correctly.

Sponsored by:	The FreeBSD Foundation
2014-05-07 07:31:25 +00:00
trasz
690b7a7a12 MFC r264524:
Make it possible for the iSCSI target side to operate in both normal
and ICL_KERNEL_PROXY mode, and fix some bit rot so the latter actually
works again.

Sponsored by:	The FreeBSD Foundation
2014-05-07 07:29:39 +00:00
trasz
69dfd86371 MFC r263740:
Use a less unusual syntax in debug printfs.

Sponsored by:	The FreeBSD Foundation
2014-05-07 07:25:47 +00:00
trasz
91f13dce9c MFC r264264 by mav@:
Wakeup only one thread of added in r263978i at a time.

This slightly reduces lock congestion between threads.
2014-05-07 07:20:02 +00:00
trasz
339da02d0d MFC r264110:
All the iSCSI sysctls are also tunables; advertise that.

Sponsored by:	The FreeBSD Foundation
2014-05-07 06:46:59 +00:00
trasz
4fd7169afe MFC r264024:
Use atomic ops instead of mutexes where appropriate.

Submitted by:	mav@
Sponsored by:	The FreeBSD Foundation
2014-05-07 06:34:03 +00:00
trasz
26ce3cd6c7 MFC r264023:
Instead of "icltx" and "iclrx", use thread names with prefix from upper
layer, so that one can see which side of the stack the threads are for.

Sponsored by:	The FreeBSD Foundation
2014-05-07 06:31:45 +00:00
trasz
76ebd34835 MFC r264022:
Get rid of ICL lock; use upper-layer (initiator or target) lock instead.
This avoids extra locking in icl_pdu_queue(); the upper layer needs to call
it while holding its own lock anyway, to avoid sending PDUs out of order.

Sponsored by:	The FreeBSD Foundation
2014-05-07 06:29:01 +00:00
trasz
dfa8f3f0a1 MFC r264020:
Remove the homegrown ctl_be_block_io allocator, replacing it with UMA.
There is no performance difference.

Reviewed by:	mav@
Sponsored by:	The FreeBSD Foundation
2014-05-07 06:26:34 +00:00
trasz
2cb2c64704 MFC r263979:
Hide CTL messages about SCSI error responses.  Too many users take
them for actual target errors.  They can be enabled back by setting
kern.cam.ctl.verbose=1, or booting with bootverbose.

Sponsored by:	The FreeBSD Foundation
2014-05-07 06:24:46 +00:00
trasz
4ceefd197d MFC r263978:
Make it possible to have multiple CTL worker threads.  Leave the default
of 1 for now.

Sponsored by:	The FreeBSD Foundation
2014-05-07 06:22:51 +00:00
trasz
d026d687fc MFC r263811:
Remove ctl_mem_pool.{c,h}.

Sponsored by:	The FreeBSD Foundation
2014-05-07 06:20:35 +00:00
trasz
0060724119 MFC r263810:
Rework cfiscsi_datamove_in() to obey expected data transfer length
received from the initiator.

Sponsored by:	The FreeBSD Foundation
2014-05-07 06:18:03 +00:00
trasz
6296615c5f MFC r263745:
Target Transfer Tag is opaque; no need to htonl(3) it.

Sponsored by:	The FreeBSD Foundation
2014-05-07 06:14:41 +00:00
mav
f908bd3cc2 MFC r264191:
Report stripe size and offset of the backing device in READ CAPACITY (16)
as physical sector size and offset.
2014-04-21 16:26:24 +00:00
trasz
37c6468863 MFC r262837:
Make reset handling in iSCSI target RFC-compliant.  This fixes some rare
hangs with Open-iSCSI (Linux).

Sponsored by:	The FreeBSD Foundation
2014-04-17 12:41:12 +00:00
mav
71409ea2b1 MFC r264311 (by smh):
Fix build breakage caused by r264295
2014-04-16 15:27:14 +00:00
mav
469b08489b MFC r264307:
Fix three refcounter leaks and lock recursion they covered.
2014-04-16 10:05:35 +00:00
mav
b3571af592 MFC r264295:
Remove support of LUN-based CD changers from cd(4) driver.

This code was heavily broken few months ago during CAM locking changes.
Fixing it would require almost complete rewrite.  Since there are no
known devices on market using this interface younger then ~15 years, and
they are CD, not even DVD, I don't see much reason to rewrite it.

This change does not mean those devices won't work.  They will just work
slower due to inefficient disks load/unload schedule if several LUNs
accessed same time.
2014-04-16 10:04:19 +00:00
trasz
49c9412490 MFC 262782:
Fix missing unlock in persistent reservations code, which resulted in panics
with Hyper-V Failover Cluster.

Sponsored by:	The FreeBSD Foundation
2014-03-25 13:18:09 +00:00
mav
5e93044a78 MFC r262741:
Do not retry on CAM_FUNC_NOTAVAIL error, but return immediately.
2014-03-18 14:18:45 +00:00
mav
855ff9ecbb MFC r262886:
Fix support for increased logical sector size (4K-native drives).

- Logical sector size is measured in words, not bytes.
- If physical sector is not bigger then logical sector, it does not mean
it should be set equal to 512 bytes, but set to logical sector.

PR:		misc/187269
Submitted by:	Ravi Pokala <rpokala@panasas.com>
2014-03-14 07:47:28 +00:00
mav
6e3a96834a MFC r261538:
Make CTL block backend return proper error code for operations unsupposed
by the underlying device.
2014-02-21 18:32:45 +00:00
mav
d374d7f398 MFC r260996:
Fix memory and references leak due to unfreed path in case we can't
allocate bus scan CCB.
2014-02-04 00:51:06 +00:00
mav
3e6f6a1694 MFC r260267 (by smh), r261042:
Correct short delete issue in SCSI UNMAP support
Correct missing \n's in xpt_print's
Correct incorrect count being passed to short delete xpt_print
2014-01-29 02:38:25 +00:00
mav
f1efe4c670 MFC r260549:
Move xpt_run_devq() call before request completion callback where it was
originally.

I am not sure why exactly have I moved it during one of many refactorings
during camlock project, but obviously it opens race window that may cause
use after free panics during SIM (in reported cases umass(4)) detach.
2014-01-25 01:58:15 +00:00
mav
5f170995ac MFC r260407:
Allow delete_method sysctl to be set to "DISABLE".
2014-01-20 23:56:49 +00:00
avg
c1dbdbde60 MFC r258622: dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE 2014-01-17 10:58:59 +00:00
mav
204096a62c MFC r260541, r260547:
Take additional reference on SCSI probe periph to cover its freeze count.

Otherwise periph may be invalidated and freed before single-stepping freeze
is dropped, causing use after free panic.
2014-01-14 12:01:36 +00:00
mav
f9a52747b5 MFC r257946:
Introduce seperate mutex lock to protect protect CTL I/O pools, slightly
reducing global CTL lock scope and congestion.

While there, simplify CTL I/O pools KPI, hiding implementation details.
2014-01-09 10:59:31 +00:00
mav
2886802896 MFC r256995:
Remove 128KB bzero() call done for every block I/O data buffer.
2014-01-09 10:50:20 +00:00
mav
2e2af5808b MFC r256547 (by smh):
Added 4K quirks for Corsair Neutron GTX SSD's
2014-01-09 10:49:14 +00:00
scottl
cd4455d638 MFC Alexander Motin's direct dispatch, multi-queue, and finer-grained
locking support for CAM

r256826:
Fix several target mode SIMs to not blindly clear ccb_h.flags field of
ATIO CCBs.  Not all CCB flags there belong to them.

r256836:
Remove hard limit on number of BIOs handled with one ATA TRIM request.

r256843:
Merge CAM locking changes from the projects/camlock branch to radically
reduce lock congestion and improve SMP scalability of the SCSI/ATA stack,
preparing the ground for the coming next GEOM direct dispatch support.

r256888:
Unconditionally acquire periph reference on CCB allocation failure.

r256895:
Fix memory and references leak due to unfreed path.

r256960:
Move CAM_UNQUEUED_INDEX setting to the last moment and under the periph lock.
This fixes race condition with cam_periph_ccbwait(), causing use-after-free.

r256975:
Minor (mostly cosmetical) addition to r256960.

r257054:
Some microoptimizations for da and ada drivers:
 - Replace ordered_tag_count counter with single flag;
 - From da remove outstanding_cmds counter, duplicating pending_ccbs list;
 - From da_softc remove unused links field.

r257482:
Fix lock recursion, triggered by `smartctl -a /dev/adaX`.

r257501:
Make getenv_*() functions and respectively TUNABLE_*_FETCH() macros not
allocate memory and so not require sleepable environment.  getenv() has
already used on-stack temporary storage, so just use it more rationally.
getenv_string() receives buffer as argument, so don't need another one.

r257914:
Some CAM locks polishing:
 - Fix LOR and possible lock recursion when handling high-power commands.
Introduce new lock to protect left power quota and list of frozen devices.
 - Correct locking around xpt periph creation.
 - Remove seems never used XPT_FLAG_OPEN xpt periph flag.

Again, Netflix assisted with testing the merge, but all of the credit goes
to Alexander and iX Systems.

Submitted by:	mav
Sponsored by:	iX Systems
2014-01-07 01:51:48 +00:00
scottl
0a34594b9c MFC Alexander Motin's GEOM direct dispatch work:
r256603:
Introduce new function devstat_end_transaction_bio_bt(), adding new argument
to specify present time.  Use this function to move binuptime() out of lock,
substantially reducing lock congestion when slow timecounter is used.

r256606:
Move g_io_deliver() out of the lock, as required for direct dispatch.
Move g_destroy_bio() out too to reduce lock scope even more.

r256607:
Fix passing uninitialized bio_resid argument to g_trace().

r256610:
Add unmapped I/O support to GEOM RAID.

r256830:
Restore BIO_UNMAPPED and BIO_TRANSIENT_MAPPING in biodonne() when unmapping
temporary mapped buffer.  That fixes double unmap if biodone() called twice
for the same BIO (but with different done methods).

r256880:
Merge GEOM direct dispatch changes from the projects/camlock branch.

When safety requirements are met, it allows to avoid passing I/O requests
to GEOM g_up/g_down thread, executing them directly in the caller context.
That allows to avoid CPU bottlenecks in g_up/g_down threads, plus avoid
several context switches per I/O.

r259247:
Fix bug introduced at r256607.  We have to recalculate bp_resid here since
sizes of original and completed requests may differ due to end of media.

Testing of the stable/10 merge was done by Netflix, but all of the credit
goes to Alexander and iX Systems.

Submitted by:   mav
Sponsored by:   iX Systems
2014-01-07 01:32:23 +00:00
mav
53624fa293 MFC r259108:
When comparing device IDs, make sure that they have the same type
(like NAA assigned) and identify the same entity (like device or port).
Otherwise there can be false positives since at least some models of
Seagate disks use same IDs for the whole device and one of its ports.
2013-12-22 13:02:34 +00:00
trasz
61fa4c178c MFC r258871:
Properly report an error instead of panicing when user tries to create
LUN backed by non-disk device, e.g. /dev/null.

Sponsored by:	The FreeBSD Foundation
2013-12-13 15:19:37 +00:00
nwhitehorn
ebd6e46afc MFC r257345,257382,257388:
Implement extended LUN support. If PIM_EXTLUNS is set by a SIM, encode
the upper 32-bits of the LUN, if possible, into the target_lun field as
passed directly from the REPORT LUNs response. This allows extended LUN
support to work for all LUNs with zeros in the lower 32-bits, which covers
most addressing modes without breaking KBI. Behavior for drivers not
setting PIM_EXTLUNS is unchanged. No user-facing interfaces are modified.

Extended LUNs are stored with swizzled 16-bit word order so that, for
devices implementing LUN addressing (like SCSI-2), the numerical
representation of the LUN is identical with and without PIM_EXTLUNS. Thus
setting PIM_EXTLUNS keeps most behavior, and user-facing LUN IDs, unchanged.
This follows the strategy used in Solaris. A macro (CAM_EXTLUN_BYTE_SWIZZLE)
is provided to transform a lun_id_t into a uint64_t ordered for the wire.

This is the second part of work for full 64-bit extended LUN support and is
designed to a bridge for stable/10 to the final 64-bit LUN code. The
third and final part will involve widening lun_id_t to 64 bits and will
not be MFCed. This third part will break the KBI but will keep the KPI
unchanged so that all drivers that will care about this can be updated now
and not require code changes between HEAD and stable/10.

Reviewed by:	scottl
2013-12-10 22:55:22 +00:00
mav
c896ef2ccc MFC r256552:
Unify periph invalidation and destruction reporting.
Print message containing device model and serial number on invalidation.

Approved by:	re (hrs)
2013-10-24 10:33:31 +00:00
mav
5411f6951e MFC r256533:
Unhide "Serial Number" lines from bootverbose.  That information may
be useful for system administration to have in hard copy (in logs) if
one of several devices suddenly dies.

Approved by:	re (hrs)
2013-10-24 10:31:02 +00:00
trasz
b4e2aceae6 Remove no longer useful debugging output and a stale comment.
Approved by:	re (gjb)
Sponsored by:	FreeBSD Foundation
2013-10-09 17:34:45 +00:00
trasz
b33524a23e Make the error handling more consistant. Shouldn't make any functional
difference.

Approved by:	re (gjb)
Sponsored by:	FreeBSD Foundation
2013-10-09 17:06:03 +00:00
trasz
0085d0dc1e Tidy up, cache return value of a function, and add an assertion;
shouldn't make any functional difference.

Approved by:	re (gjb)
Sponsored by:	FreeBSD Foundation
2013-10-09 16:55:52 +00:00
mav
c054998939 Close the race on path ID allocation in xpt_bus_register() if two buses are
registered simultaneously. Due to topology unlock between the ID allocation
and the bus registration there is a chance that two buses may get the
same IDs. That is supposed reason of lock assertion panic in CAM during
initial bus scanning after new iscsid initiates two sessions same time.

Reported by:	trasz
Approved by:	re (glebus, marius)
MFC after:	2 weeks
2013-10-09 12:09:01 +00:00
trasz
06b2736d4d Fix NOP-In/NOP-Out payload handling. Previous way didn't work at all; fortunately
nothing seems to actually use this feature, but it's required by standard.

Approved by:	re (glebius)
Sponsored by:	FreeBSD Foundation
2013-10-09 12:03:04 +00:00
trasz
4d9730d87e Properly fix out of memory handling in the iSCSI target.
Approved by:	re (glebius)
Sponsored by:	FreeBSD Foundation
2013-10-08 19:18:02 +00:00