summaryrefslogtreecommitdiffstats
path: root/sys/dev/md
Commit message (Collapse)AuthorAgeFilesLines
* Allow the MDIOCATTACH ioctl operation to originate from within the kernel.marcel2010-10-181-8/+16
| | | | | | To protect against malicious software, we demand that the file name is at a particular location (i.e. appended to the mdio structure) for it to be treated as in-kernel.
* - Remove some extra white space.jh2010-07-261-9/+7
| | | | - Wrap g_md_dumpconf() prototype to 80 columns.
* Convert md(4) to use alloc_unr(9) and alloc_unr_specific(9) for unitjh2010-07-221-12/+20
| | | | | | | number allocation. The old approach had some problems such as it allowed an overflow to occur in the unit number calculation. PR: kern/122288
* Calculate nshift only once.kib2010-07-061-4/+6
| | | | | Also noted by: avg MFC after: 1 week
* Eliminate unnecessary page queues locking.alc2010-06-151-3/+1
|
* Lock the page around vm_page_activate() and vm_page_deactivate() callskib2010-05-031-0/+2
| | | | | | | where it was missed. The wrapped fragments now protect wire_count with page lock. Reviewed by: alc
* Fix panic on invalid 'mdconfig -at preload' usage.trasz2010-02-271-0/+2
| | | | PR: kern/80136
* (S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.antoine2009-12-281-1/+1
| | | | | | | | | Fix some wrong usages. Note: this does not affect generated binaries as this argument is not used. PR: 137213 Submitted by: Eygene Ryabinkin (initial version) MFC after: 1 month
* Implement global and per-uid accounting of the anonymous memory. Addkib2009-06-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | rlimit RLIMIT_SWAP that limits the amount of swap that may be reserved for the uid. The accounting information (charge) is associated with either map entry, or vm object backing the entry, assuming the object is the first one in the shadow chain and entry does not require COW. Charge is moved from entry to object on allocation of the object, e.g. during the mmap, assuming the object is allocated, or on the first page fault on the entry. It moves back to the entry on forks due to COW setup. The per-entry granularity of accounting makes the charge process fair for processes that change uid during lifetime, and decrements charge for proper uid when region is unmapped. The interface of vm_pager_allocate(9) is extended by adding struct ucred *, that is used to charge appropriate uid when allocation if performed by kernel, e.g. md(4). Several syscalls, among them is fork(2), may now return ENOMEM when global or per-uid limits are enforced. In collaboration with: pho Reviewed by: alc Approved by: re (kensmith)
* Add cpu_flush_dcache() for use after non-DMA based I/O so that amarcel2009-05-181-3/+6
| | | | | | | | | | | | | | | | | | | | | possible future I-cache coherency operation can succeed. On ARM for example the L1 cache can be (is) virtually mapped, which means that any I/O that uses temporary mappings will not see the I-cache made coherent. On ia64 a similar behaviour has been observed. By flushing the D-cache, execution of binaries backed by md(4) and/or NFS work reliably. For Book-E (powerpc), execution over NFS exhibits SIGILL once in a while as well, though cpu_flush_dcache() hasn't been implemented yet. Doing an explicit D-cache flush as part of the non-DMA based I/O read operation eliminates the need to do it as part of the I-cache coherency operation itself and as such avoids pessimizing the DMA-based I/O read operations for which D-cache are already flushed/invalidated. It also allows future optimizations whereby the bcopy() followed by the D-cache flush can be integrated in a single operation, which could be implemented using on-chips DMA engines, by-passing the D-cache altogether.
* Add a new internal mount flag (MNTK_EXTENDED_SHARED) to indicate that ajhb2009-03-111-10/+20
| | | | | | | | | | | | | | | | | | | | | | | | filesystem supports additional operations using shared vnode locks. Currently this is used to enable shared locks for open() and close() of read-only file descriptors. - When an ISOPEN namei() request is performed with LOCKSHARED, use a shared vnode lock for the leaf vnode only if the mount point has the extended shared flag set. - Set LOCKSHARED in vn_open_cred() for requests that specify O_RDONLY but not O_CREAT. - Use a shared vnode lock around VOP_CLOSE() if the file was opened with O_RDONLY and the mountpoint has the extended shared flag set. - Adjust md(4) to upgrade the vnode lock on the vnode it gets back from vn_open() since it now may only have a shared vnode lock. - Don't enable shared vnode locks on FIFO vnodes in ZFS and UFS since FIFO's require exclusive vnode locks for their open() and close() routines. (My recent MPSAFE patches for UDF and cd9660 already included this change.) - Enable extended shared operations on UFS, cd9660, and UDF. Submitted by: ups Reviewed by: pjd (ZFS bits) MFC after: 1 month
* Remove unnecessary page queues locking around vm_page_wakeup(). (Thisalc2009-02-221-7/+1
| | | | | | change is applicable to RELENG_7 but not RELENG_6.) MFC after: 1 week
* Add the possibility to specify "-o force" with "mdconfig -du".trasz2009-01-101-2/+4
| | | | | | Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
* Fix forced mdconfig -du. E.g. the following would previouslytrasz2008-12-161-1/+4
| | | | | | | | | | | | result in panic: mdconfig -af blah.img -o force mount /dev/md0 /mnt mdconfig -du 0 Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
* Decontextualize the couplet VOP_GETATTR / VOP_SETATTR as the passed threadattilio2008-08-281-1/+1
| | | | | | was always curthread and totally unuseful. Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com>
* Remove the distinction between device minor and unit numbers.ed2008-05-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Even though we got rid of device major numbers some time ago, device drivers still need to provide unique device minor numbers to make_dev(). These numbers are only used inside the kernel. They are not related to device major and minor numbers which are visible in devfs. These are actually based on the inode number of the device. It would eventually be nice to remove minor numbers entirely, but we don't want to be too agressive here. Because the 8-15 bits of the device number field (si_drv0) are still reserved for the major number, there is no 1:1 mapping of the device minor and unit numbers. Because this is now unused, remove the restrictions on these numbers. The MAXMAJOR definition was actually used for two purposes. It was used to convert both the userspace and kernelspace device numbers to their major/minor pair, which is why it is now named UMINORMASK. minor2unit() and unit2minor() have now become useless. Both minor() and dev2unit() now serve the same purpose. We should eventually remove some of them, at least turning them into macro's. If devfs would become completely minor number unaware, we could consider using si_drv0 directly, just like si_drv1 and si_drv2. Approved by: philip (mentor)
* Zero sc->vnode if mdsetcred() fails.philip2008-02-281-0/+1
| | | | | | | | This fixes the panic which happens when mdcreate_vnode() calls vn_close() and mddestroy() calls it again further down the error handling path. Reviewed by: kris, kib MFC after: 3 days
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inattilio2008-01-131-8/+8
| | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com>
* vn_lock() is currently only used with the 'curthread' passed as argument.attilio2008-01-101-6/+6
| | | | | | | | | | | | | | | | Remove this argument and pass curthread directly to underlying VOP_LOCK1() VFS method. This modify makes the code cleaner and in particular remove an annoying dependence helping next lockmgr() cleanup. KPI results, obviously, changed. Manpage and FreeBSD_version will be updated through further commits. As a side note, would be valuable to say that next commits will address a similar cleanup about VFS methods, in particular vop_lock1 and vop_unlock. Tested by: Diego Sardina <siarodx at gmail dot com>, Andrea Di Pasquale <whyx dot it at gmail dot com>
* Put back devstat support that was lost during GEOM transition. Initially,sobomax2007-11-071-0/+12
| | | | | | | | | | | I've tried to move md(4) to use geom_disk class, like real disks do, but this requires major rework of some of the existing features such as configuration dumping for example. Therefore just putting devstat support directly into md(4) seems to be optimal solution. Now you can see md(4) stats in `systat -vm' again. MFC after: 2 weeks
* Rename the kthread_xxx (e.g. kthread_create()) callsjulian2007-10-201-2/+2
| | | | | | | | | | | to kproc_xxx as they actually make whole processes. Thos makes way for us to add REAL kthread_create() and friends that actually make theads. it turns out that most of these calls actually end up being moved back to the thread version when it's added. but we need to make this cosmetic change first. I'd LOVE to do this rename in 7.0 so that we can eventually MFC the new kthread_xxx() calls.
* Commit 14/14 of sched_lock decomposition.jeff2007-06-051-2/+2
| | | | | | | | | | | - Use thread_lock() rather than sched_lock for per-thread scheduling sychronization. - Use the per-process spinlock rather than the sched_lock for per-process scheduling synchronization. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
* Revert UF_OPENING workaround for CURRENT.kib2007-05-311-1/+1
| | | | | | | | | Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation argument from being file descriptor index into the pointer to struct file. Proposed and reviewed by: jhb Reviewed by: daichi (unionfs) Approved by: re (kensmith)
* Resolve two deadlocks that could be caused by busy md device backedkib2006-12-141-0/+9
| | | | | | | | | | by vnode. Allow for md thread and the thread that owns lock on vnode backing the md device to do the write even when runningbufspace is exhausted. Tested by: Peter Holm Reviewed by: tegge MFC after: 2 weeks
* Style nits.pjd2006-11-011-2/+2
|
* Fix md(4) panic which occurs when I/O request different thanpjd2006-11-011-10/+53
| | | | | | | | | | BIO_READ/BIO_WRITE is sent to vnode-backed provider (BIO_DELETE or BIO_FLUSH). Reported by: ceri Add support for BIO_FLUSH to vnode-backed md(4) devices based on VOP_FSYNC().
* - Conditionally acquire Giant in mdstart_vnode(), mdcreate_vnode(), andjhb2006-03-281-29/+23
| | | | | | | | mddestroy() only if the file is from a non-MPSAFE VFS. - No longer unconditionally hold Giant in the md kthread for vnode-backed kthreads. - Improve the handling of the thread exit race when destroying an md device.
* Teach md(4) and mdconfig(8) how to understand XML. Right now there won't bewkoszek2006-03-261-0/+62
| | | | | | | | | | | | a problem with listing large number of md(4) devices. Either 'list' or 'query' mode uses XML. Additionally, new functionality was introduced. It's possible to pass multiple devices to -u: # ./mdconfig -l -u md0,md1 Approved by: cognet (mentor)
* make sure that the start and end preloaded MFS markers areluigi2006-01-311-4/+14
| | | | | in contiguous strings, and that the compiler does not optimize them away because it thinks they are unused.
* Call NDFREE() only when vn_open() succeeded.pjd2006-01-271-1/+1
| | | | MFC after: 3 days
* o Fix typos in the comments.maxim2005-12-281-2/+2
| | | | Submitted by: Wojciech A. Koszek
* Normalize a significant number of kernel malloc type names:rwatson2005-10-311-2/+2
| | | | | | | | | | | | | | | | | | | - Prefer '_' to ' ', as it results in more easily parsed results in memory monitoring tools such as vmstat. - Remove punctuation that is incompatible with using memory type names as file names, such as '/' characters. - Disambiguate some collisions by adding subsystem prefixes to some memory types. - Generally prefer lower case to upper case. - If the same type is defined in multiple architecture directories, attempt to use the same name in additional cases. Not all instances were caught in this change, so more work is required to finish this conversion. Similar changes are required for UMA zone names.
* Make sure that the worker thread knows the type early enough tophk2005-10-061-6/+5
| | | | | | grab Giant for vnode backing. Found by: pho & tegge
* Fix configuration locking in MD.phk2005-09-191-116/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove md_mtx. Remove GIANT from the mdctl device driver and avoid DROP_GIANT, PICKUP_GIANT and geom events since we can call into GEOM directly now. Pick up Giant around vn_close(). Apply an exclusive sx around mdctls ioctl and preloading to protect lists etc.. Don't initialize our lock (md_mtx or md_sx) from a SYSINIT when there is a perfectly good pair of _fini/_init functions to do it from. Prune any final fractional sector from the mediasize to keep GEOM happy. Cleanups: Unify MDIOVERSION check in (x)mdctlioctl() Add pointer to start() routine to softc to eliminate a switch{} Inline guts of mddetach(). Always pass error pointer to mdnew(), simplify implementation.
* Do not destroy the queue mutex until the thread is done with it.phk2005-09-111-1/+1
|
* - Add md_mtx lock to protect ID number and list of devices.pjd2005-08-311-25/+37
| | | | | | | | | | - Always check mdnew() return value, as even in !autounit case kthread_create() can fail. Those two changes fix serval panics provked by simple stress test. Tested by: Kris The BugMagnet MFC after: 3 days
* Ensure that file flags such as schg, sappnd (and others) are honoredcsjp2005-08-171-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | by md(4). Before this change, it was possible to by-pass these flags by creating memory disks which used a file as a backing store and writing to the device. This was discussed by the security team, and although this is problematic, it was decided that it was not critical as we never guarantee that root will be restricted. This change implements the following behavior changes: -If the user specifies the readonly flag, unset write operations before opening the file. If the FWRITE mask is unset, the device will be created with the MD_READONLY mask set. (readonly) -Add a check in g_md_access which checks to see if the MD_READONLY mask is set, if so return EROFS -Do not gracefully downgrade access modes without telling the user. Instead make the user specify their intentions for the device (assuming the file is read only). This seems like the more correct way to handle things. This is a RELENG_6 candidate. PR: kern/84635 Reviewed by: phk
* Request a CPU private mapping from sf_buf_alloc(). If the swap-backedalc2005-02-131-1/+6
| | | | | | | | | memory disk is larger than the number of available sf_bufs, this improves performance on SMPs by eliminating interprocessor TLB shootdowns. For example, with 6656 sf_bufs, the default on my test machine, and a 256MB swap-backed memory disk, I see the command "dd if=/dev/md0 of=/dev/null bs=64k" achieve ~489MB/sec with the default, shared mappings, and ~587MB/sec with CPU private mappings.
* Use MAXMINORphk2005-01-291-1/+1
|
* - Don't destroy UMA zone on error in mdcreate_malloc(), because we need itpjd2005-01-221-4/+1
| | | | | | | | | in mddestroy() to properly free already allocated memory. This fixes a panic when we want to create too big memory backed device with preallocate memory (-o reserve). - Remove redundant { }. MFC after: 1 week
* Add a couple of mtx_asserts() to try to narrow down the window onphk2005-01-221-0/+2
| | | | a bug repeatedly reported.
* Start each of the license/copyright comments with /*-, minor shuffle of linesimp2005-01-061-2/+2
|
* Add needed synchronization to the error handling code that was introducedalc2005-01-051-0/+6
| | | | | | in revision 1.141. Lock assertion failures reported by: Kris Kennaway
* Stop explicitly touching td_base_pri outside of the scheduler and simplyjhb2004-12-301-1/+4
| | | | | set a thread's priority via sched_prio() when that is the desired action. The schedulers will start managing td_base_pri internally shortly.
* Rewrite piece of code which I committed some time ago that allows topjd2004-12-271-10/+8
| | | | | | | | | show file name for 'mdconfig -l -u <x>' command. This allows to preserve API/ABI compatibility with version 0 (that's why I changed version number back to 0) and will allow to merge this change to RELENG_5. MFC after: 5 days
* Fix the MDIOCDETACH ioctl() for md(4). Now that the md_file field inmarcel2004-11-131-1/+1
| | | | | the mdio structure is an array and not a pointer, we cannot test for it to be NULL. It never is. Instead, test for md_file[0] to be '\0'.
* Be consistent and use 'if (error != 0)' instead of 'if (error)' everywhere.pjd2004-11-061-5/+5
|
* For file backed md(4) devices output their source file viapjd2004-11-061-4/+13
| | | | | 'mdconfig -l -u <unit>'. Bump version number, as this change breaks ABI/API.
* Don't explicitly call g_waitidle(), it happens automagically now.phk2004-10-231-2/+0
|
* Account for failure in vm_pager_allocate() or vm_pager_get_pages() ingreen2004-10-121-1/+19
| | | | | | | | | md(8). The former is generally not going to fail, but the latter can fail when the underlying swap device returns an error. There are still plenty of other places where vm_pager_get_pages() failing will lead directly to crashes, so it's a good idea to put your swap on RAID if you care enough to put any of your disks on RAID....
OpenPOWER on IntegriCloud