summaryrefslogtreecommitdiffstats
path: root/sys/cam/scsi/scsi_target.c
Commit message (Collapse)AuthorAgeFilesLines
* Replace most of priority numbers with defines. No logical changes.mav2009-10-231-5/+5
|
* Remember to unlock the peripheral prior to notifying the user. Make somemjacob2009-09-191-15/+70
| | | | | | | | | | allocations M_NOWAIT so that we don't try and sleep with a nested non-sleepable lock. This makes the userland scsi_target begin to function again. Obtained from: Sean Bruno MFC after: 1 month
* Use C99 initialization for struct filterops.rwatson2009-09-121-2/+5
| | | | | | Obtained from: Mac OS X Sponsored by: Apple Inc. MFC after: 3 weeks
* Change the type of uio_resid member of struct uio from int to ssize_t.kib2009-06-251-1/+1
| | | | | | | | Note that this does not actually enable full-range i/o requests for 64 architectures, and is done now to update KBI only. Tested by: pho Reviewed by: jhb, bde (as part of the review of the bigger patch)
* Adapt vfs kqfilter to the shared vnode lock used by zfs write vop. Usekib2009-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | vnode interlock to protect the knote fields [1]. The locking assumes that shared vnode lock is held, thus we get exclusive access to knote either by exclusive vnode lock protection, or by shared vnode lock + vnode interlock. Do not use kl_locked() method to assert either lock ownership or the fact that curthread does not own the lock. For shared locks, ownership is not recorded, e.g. VOP_ISLOCKED can return LK_SHARED for the shared lock not owned by curthread, causing false positives in kqueue subsystem assertions about knlist lock. Remove kl_locked method from knlist lock vector, and add two separate assertion methods kl_assert_locked and kl_assert_unlocked, that are supposed to use proper asserts. Change knlist_init accordingly. Add convenience function knlist_init_mtx to reduce number of arguments for typical knlist initialization. Submitted by: jhb [1] Noted by: jhb [2] Reviewed by: jhb Tested by: rnoland
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).des2008-10-231-9/+9
| | | | MFC after: 3 months
* Replace all calls to minor() with dev2unit().ed2008-09-271-1/+1
| | | | | | | | | | | | | | | After I removed all the unit2minor()/minor2unit() calls from the kernel yesterday, I realised calling minor() everywhere is quite confusing. Character devices now only have the ability to store a unit number, not a minor number. Remove the confusion by using dev2unit() everywhere. This commit could also be considered as a bug fix. A lot of drivers call minor(), while they should actually be calling dev2unit(). In -CURRENT this isn't a problem, but it turns out we never had any problem reports related to that issue in the past. I suspect not many people connect more than 256 pieces of the same hardware. Reviewed by: kib
* Remove unit2minor() use from kernel code.ed2008-09-261-1/+1
| | | | | | | | | | | | | | | When I changed kern_conf.c three months ago I made device unit numbers equal to (unneeded) device minor numbers. We used to require bitshifting, because there were eight bits in the middle that were reserved for a device major number. Not very long after I turned dev2unit(), minor(), unit2minor() and minor2unit() into macro's. The unit2minor() and minor2unit() macro's were no-ops. We'd better not remove these four macro's from the kernel, because there is a lot of (external) code that may still depend on them. For now it's harmless to remove all invocations of unit2minor() and minor2unit(). Reviewed by: kib
* Remove Giant from CAM. Drivers (SIMs) now register a mutex that CAM willscottl2007-04-151-16/+64
| | | | | | | | | | | use to synchornize and protect all data objects that are used for that SIM. Drivers that are not yet MPSAFE register Giant and operate as usual. RIght now, no drivers are MPSAFE, though a few will be changed in the coming week as this work settles down. The driver API has changed, so all CAM drivers will need to be recompiled. The userland API has not changed, so tools like camcontrol do not need to be recompiled.
* Use tsleep() rather than msleep() with a NULL mtx.jhb2007-02-271-3/+3
|
* Add an xpt_print function to reduce most of the xpt_print_path/printfmjacob2006-12-051-11/+9
| | | | | | | pairs. Convert the core code to use it. Reviewed by: scsi (various folks weighing in with good advice) MFC after: 2 weeks
* Forced commit - last checkin got away from me.mjacob2006-05-241-0/+1
| | | | | | | | | | This version of scsi_target.c removes all SMP locking until we have a lock-aware CAM stack. This allows us to use KNOTE without a panic at least. It's not yet clear whether target mode is working yet or not. Discussed with: Scott, Ken, Nate, Justin
* Make physical buffers in cam_periph_mapmem owned by the kernel in case wemjacob2006-05-241-57/+9
| | | | | | | | return to user space w/o waiting for I/O to complete. I tried to get several folks who know this code better than me to review it with no luck. I *do* know that w/o this code, using the SCSI target driver panics in userret (if it doesn't panic in knote first).
* Merge the dev_clone and dev_clone_cred event handlers into a singlerwatson2005-08-081-3/+4
| | | | | | | | | | | | | event handler, dev_clone, which accepts a credential argument. Implementors of the event can ignore it if they're not interested, and most do. This avoids having multiple event handler types and fall-back/precedence logic in devfs. This changes the kernel API for /dev cloning, and may affect third party packages containg cloning kernel modules. Requested by: phk MFC after: 3 days
* Fix the recent panics/LORs/hangs created by my kqueue commit by:ssouhlal2005-07-011-1/+1
| | | | | | | | | | | | | | | | | - Introducing the possibility of using locks different than mutexes for the knlist locking. In order to do this, we add three arguments to knlist_init() to specify the functions to use to lock, unlock and check if the lock is owned. If these arguments are NULL, we assume mtx_lock, mtx_unlock and mtx_owned, respectively. - Using the vnode lock for the knlist locking, when doing kqueue operations on a vnode. This way, we don't have to lock the vnode while holding a mutex, in filt_vfsread. Reviewed by: jmg Approved by: re (scottl), scottl (mentor override) Pointyhat to: ssouhlal Will be happy: everyone
* Explicitly hold a reference to the cdev we have just cloned. Thisphk2005-03-311-0/+1
| | | | | closes the race where the cdev was reclaimed before it ever made it back to devfs lookup.
* Remove a shadow declaration of 'error' that caused certain tests to bescottl2005-02-121-1/+0
| | | | | | pointless. Submitted by: Coverity Prevent analysis tool
* Start each of the license/copyright comments with /*-imp2005-01-051-1/+1
|
* Add locking to the kqueue subsystem. This also makes the kqueue subsystemjmg2004-08-151-21/+5
| | | | | | | | | | | | | a more complete subsystem, and removes the knowlege of how things are implemented from the drivers. Include locking around filter ops, so a module like aio will know when not to be unloaded if there are outstanding knotes using it's filter ops. Currently, it uses the MTX_DUPOK even though it is not always safe to aquire duplicate locks. Witness currently doesn't support the ability to discover if a dup lock is ok (in some cases). Reviewed by: green, rwatson (both earlier versions)
* Second half of the dev_t cleanup.phk2004-06-171-1/+1
| | | | | | | | | | | The big lines are: NODEV -> NULL NOUDEV -> NODEV udev_t -> dev_t udev2dev() -> findcdev() Various minor adjustments including handling of userland access to kernel space struct cdev etc.
* Do the dreaded s/dev_t/struct cdev */phk2004-06-161-9/+9
| | | | Bump __FreeBSD_version accordingly.
* Device megapatch 4/6:phk2004-02-211-0/+2
| | | | | | | | Introduce d_version field in struct cdevsw, this must always be initialized to D_VERSION. Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
* Device megapatch 1/6:phk2004-02-211-2/+0
| | | | | | | Free approx 86 major numbers with a mostly automatically generated patch. A number of strategic drivers have been left behind by caution, and a few because they still (ab)use their major number.
* - Implement selwakeuppri() which allows raising the priority of atanimura2003-11-091-1/+1
| | | | | | | | | | | | | thread being waken up. The thread waken up can run at a priority as high as after tsleep(). - Replace selwakeup()s with selwakeuppri()s and pass appropriate priorities. - Add cv_broadcastpri() which raises the priority of the broadcast threads. Used by selwakeuppri() if collision occurs. Not objected in: -arch, -current
* Be kind to 64bit architectures.simokawa2003-10-021-5/+5
|
* Calling KNOTE with locks held may result in recursion when it calls backnjl2003-09-041-2/+13
| | | | | | | | into targreadfilt(). Unlock around calls to notify_user(). If an application is sending CCBs while the endpoint is shutting down, this may result in incomplete disable. A more complete solution will come with a "dying" flag. Submitted by: simokawa
* Upon receiving a CCB for a LUN that is not enabled, be sure to unlock thenjl2003-09-041-0/+1
| | | | | | softc on exit. Submitted by: simokawa
* Use __FBSDID().obrien2003-06-101-2/+3
|
* Make nokqfilter() return the correct return value.phk2003-03-031-1/+0
| | | | Ditch the D_KQFILTER flag which was used to prevent calling NULL pointers.
* Gigacommit to improve device-driver source compatibility betweenphk2003-03-031-14/+10
| | | | | | | | | | | | | branches: Initialize struct cdevsw using C99 sparse initializtion and remove all initializations to default values. This patch is automatically generated and has been tested by compiling LINT with all the fields in struct cdevsw in reverse order on alpha, sparc64 and i386. Approved by: re(scottl)
* msgphk2003-02-261-1/+0
|
* Back out M_* changes, per decision of the TRB.imp2003-02-191-3/+3
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-3/+3
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* kernel:njl2003-01-161-1/+1
| | | | | | | | | | | | * Fix a bug where devices weren't cleaned up on close(): CAM_REQ_CMP != 0 user: * Increase timeout in usermode to CAM_TIME_INFINITY. The initiator is in charge of timeouts and the value was in ms, not seconds. * Bring two debugging printfs under the debug flag * Clean up man page to show increased testing on isp(4) Submitted by: gibbs (bugfixes)
* Remove unnecessary includes and add sys/{lock,mutex}.hnjl2002-11-251-6/+2
| | | | | Submitted by: bde Approved by: re (previously)
* New SCSI target emulator codenjl2002-11-221-2016/+899
| | | | | | | | | | | | | | | | | | | | | This code allows a user program to enable target mode on a SIM and then emulate any number of devices (disks, tape drives, etc.) All decisions about device behavior (UA, CA, inquiry response) are left to the usermode program and the kernel driver is merely a conduit for CCBs. This enables multiple concurrent target emulators, each using its own backing store and IO model. Also included is a user program that emulates a disk (RBC) using a file as a backing store. This provides functionality similar to md(4) at the CAM layer. Code has been tested on ahc(4) and should also work on isp(4) (and other SIMs that gain target mode support). It is a complete rewrite of /sys/cam/scsi_target* and /usr/share/examples/scsi_target. Design, comments from: gibbs Supported by: Cryptography Research Approved by: re
* Remove usage of cam_extend.c, replace with dev->si_drv1njl2002-08-151-48/+16
| | | | | PR: kern/39809 Approved by: gibbs
* KSE Milestone 2julian2001-09-121-6/+6
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* (Forced commit- last one missed the comments)mjacob2001-07-301-2/+2
| | | | | | | Handle both old and new TARGIOALLOCUNIT/TARGIOFREEUNIT cases- the new one allows us to specify inquiry data we want to use. Handle more of the CAM_DIS_DISCONNECT case.
* scsi_targetio.hmjacob2001-07-301-56/+118
|
* Exploit recent improvements in the disk minilayer to simplify errorphk2001-05-081-15/+9
| | | | | | | | handling a bit. Dogmatic lingupurists can celebrate that a number of gotos got removed. Reviewed by: mjacob, ken
* Fix up unit attention and selection timeout handling in various peripheralken2001-05-011-11/+5
| | | | | | | | | | | | drivers. - change daprevent() to set CAM_RETRY_SELTO and SF_RETRY_UA when it calls cam_periph_runccb(). - change the pt(4) driver to ignore unit attentions - change the targ(4) driver to retry selection timeouts - clean up a few formatting glitches in the targ(4) driver Reviewed by: gibbs
* Send the remains (such as I have located) of "block major numbers" tophk2001-03-261-1/+0
| | | | the bit-bucket.
* Change the peripheral driver list from a linker set to module drivenpeter2001-02-071-1/+1
| | | | | driver registration. This should allow things like da, sa, cd etc to be in seperate KLD's to the cam core and make them preloadable.
* select() DKI is defined in <sys/selinfo.h> now.wollman2001-01-091-1/+1
|
* Convert all users of fldoff() to offsetof(). fldoff() is badphk2000-10-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | because it only takes a struct tag which makes it impossible to use unions, typedefs etc. Define __offsetof() in <machine/ansi.h> Define offsetof() in terms of __offsetof() in <stddef.h> and <sys/types.h> Remove myriad of local offsetof() definitions. Remove includes of <stddef.h> in kernel code. NB: Kernelcode should *never* include from /usr/include ! Make <sys/queue.h> include <machine/ansi.h> to avoid polluting the API. Deprecate <struct.h> with a warning. The warning turns into an error on 01-12-2000 and the file gets removed entirely on 01-01-2001. Paritials reviews by: various. Significant brucifications by: bde
* Preserve CAM_DIS_DISCONNECT as passed up from SIM (likemjacob2000-07-171-9/+16
| | | | | | | | CAM_TAG_ACTION_VALID and CAM_DIR_MASK). Remove redundant CAM_DEBUG line. Spiff up CAM_DEBUG printout for commands and move the printout up to the top where we can see it, even for the pending_ua/pending_ca cass. Add missing newline in a CAM_DEBUG.
* Don't, when doing cam_fill_ctio, add a SIMPLE Q tag unlessmjacob2000-07-141-2/+3
| | | | TAG_ACTION_VALID is set.
* Pick up some changes from Justin (add tagged queing support, remembermjacob2000-07-141-15/+96
| | | | | | | | | | | to splx(s) if cam_extend_get fails and we return ENXIO, reset ccb flags when we push ATIOs back to the SIM, do some data increment fixes, set priority of command based on whether CAM_DIS_DISCONNECT is set and related changes). Add in some more CAM_DEBUG_PERIPH debug statements and also add in support for TARGIODEBUG which then will enable or disable CAM_DEBUG_PERIPH tracing for an instance.
* Use %p to print a pointer.mjacob2000-07-081-1/+1
|
OpenPOWER on IntegriCloud