summaryrefslogtreecommitdiff
path: root/sys/kern/subr_disk.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't pick up a name from the dev_t if it is not there.Poul-Henning Kamp2003-03-031-1/+7
| | | | Notes: svn path=/head/; revision=111808
* NO_GEOM cleanup: remove #ifdefPoul-Henning Kamp2003-01-301-423/+0
| | | | Notes: svn path=/head/; revision=110089
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-1/+1
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Only include <sys/diskslice.h> ifdef NO_GEOMPoul-Henning Kamp2003-01-201-1/+1
| | | | Notes: svn path=/head/; revision=109561
* This checkin reimplements the io-request priority hack in a wayKirk McKusick2002-10-221-29/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that works in the new threaded kernel. It was commented out of the disksort routine earlier this year for the reasons given in kern/subr_disklabel.c (which is where this code used to reside before it moved to kern/subr_disk.c): ---------------------------- revision 1.65 date: 2002/04/22 06:53:20; author: phk; state: Exp; lines: +5 -0 Comment out Kirks io-request priority hack until we can do this in a civilized way which doesn't cause grief. The problem is that it is not generally safe to cast a "struct bio *" to a "struct buf *". Things like ccd, vinum, ata-raid and GEOM constructs bio's which are not entrails of a struct buf. Also, curthread may or may not have anything to do with the I/O request at hand. The correct solution can either be to tag struct bio's with a priority derived from the requesting threads nice and have disksort act on this field, this wouldn't address the "silly-seek syndrome" where two equal processes bang the diskheads from one edge to the other of the disk repeatedly. Alternatively, and probably better: a sleep should be introduced either at the time the I/O is requested or at the time it is completed where we can be sure to sleep in the right thread. The sleep also needs to be in constant timeunits, 1/hz can be practicaly any sub-second size, at high HZ the current code practically doesn't do anything. ---------------------------- As suggested in this comment, it is no longer located in the disk sort routine, but rather now resides in spec_strategy where the disk operations are being queued by the thread that is associated with the process that is really requesting the I/O. At that point, the disk queues are not visible, so the I/O for positively niced processes is always slowed down whether or not there is other activity on the disk. On the issue of scaling HZ, I believe that the current scheme is better than using a fixed quantum of time. As machines and I/O subsystems get faster, the resolution on the clock also rises. So, ten years from now we will be slowing things down for shorter periods of time, but the proportional effect on the system will be about the same as it is today. So, I view this as a feature rather than a drawback. Hence this patch sticks with using HZ. Sponsored by: DARPA & NAI Labs. Reviewed by: Poul-Henning Kamp <phk@critter.freebsd.dk> Notes: svn path=/head/; revision=105667
* One #include <sys/sysctl.h> should be enough.Olivier Houchard2002-10-211-1/+0
| | | | | | | Approved by: mux (mentor) Notes: svn path=/head/; revision=105642
* Separate fiels reported by disk_err() with spaces, so that output doesn'tMaxim Sobolev2002-10-171-7/+7
| | | | | | | | | look cryptic. MFC after: 1 week Notes: svn path=/head/; revision=105365
* Populate more fields of the disklabel for PC98.Poul-Henning Kamp2002-10-141-0/+2
| | | | | | | Submitted by: Kawanobe Koh <kawanobe@st.rim.or.jp> Notes: svn path=/head/; revision=105108
* NB: This commit does *NOT* make GEOM the default in FreeBSDPoul-Henning Kamp2002-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NB: But it will enable it in all kernels not having options "NO_GEOM" Put the GEOM related options into the intended order. Add "options NO_GEOM" to all kernel configs apart from NOTES. In some order of controlled fashion, the NO_GEOM options will be removed, architecture by architecture in the coming days. There are currently three known issues which may force people to need the NO_GEOM option: boot0cfg/fdisk: Tries to update the MBR while it is being used to control slices. GEOM does not allow this as a direct operation. SCSI floppy drives: Appearantly the scsi-da driver return "EBUSY" if no media is inserted. This is wrong, it should return ENXIO. PC98: It is unclear if GEOM correctly recognizes all variants of PC98 disklabels. (Help Wanted! I have neither docs nor HW) These issues are all being worked. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=104519
* If dsgetlabel() returns a label with a size of zero in diskdumpconf(),Brian Somers2002-10-051-0/+2
| | | | | | | | | | | | | treat it as an invalid partition. This fixes a bug where ``dumpon <device>'' will configure the dump device at a random offset on the disk if <device> isn't a valid partition. Reviewed by: phk Notes: svn path=/head/; revision=104507
* (This commit touches about 15 disk device drivers in a very consistentPoul-Henning Kamp2002-09-201-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and predictable way, and I apologize if I have gotten it wrong anywhere, getting prior review on a patch like this is not feasible, considering the number of people involved and hardware availability etc.) If struct disklabel is the messenger: kill the messenger. Inside struct disk we had a struct disklabel which disk drivers used to communicate certain metrics to the disklayer above (GEOM or the disk mini-layer). This commit changes this communication to use four explicit fields instead. Amongst the benefits is that the fields do not get overwritten by wrong or bogus on-disk disklabels. Once that is clear, <sys/disk.h> which is included in the drivers no longer need to pull <sys/disklabel.h> and <sys/diskslice.h> in, the few places that needs them, have gotten explicit #includes for them. The disklabel inside struct disk is now only for internal use in the disk mini-layer, so instead of embedding it, we malloc it as we need it. This concludes (modulus any mistakes) the series of disklabel related commits. I belive it all amounts to a NOP for all the rest of you :-) Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=103714
* Make FreeBSD "struct disklabel" agnostic, step 312 of 723:Poul-Henning Kamp2002-09-201-0/+150
| | | | | | | | | | | | | Rename bioqdisksort() to bioq_disksort(). Keep a #define around to avoid changing all diskdrivers right now. Move it from subr_disklabel.c to subr_disk.c. Move prototype from <sys/disklabel.h> to <sys/bio.h> Sponsored by: DARPA and NAI Labs. Notes: svn path=/head/; revision=103683
* Make FreeBSD "struct disklabel" agnostic, step 311 of 723:Poul-Henning Kamp2002-09-201-3/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename diskerr() to disk_err() for naming consistency. Drop the by now entirely useless struct disklabel argument. Add a flag argument for new-line termination. Fix a couple of printf-format-casts to %j instead of %l. Correctly print the name of all bio commands. Move the function from subr_disklabel.c to subr_disk.c, and from <sys/disklabel.h> to <sys/disk.h>. Use the new disk_err() throughout, #include <sys/disk.h> as needed. Bump __FreeBSD_version for the sake of the aac disk drivers #ifdefs. Remove unused disklabel members of softc for aac, amr and mlx, which seem to originally have been intended for diskerr() use, but which only rotted and got Copy&Pasted at least two times to many. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=103675
* Don't use "NULL" when "0" is really meant.Archie Cobbs2002-08-211-1/+1
| | | | Notes: svn path=/head/; revision=102241
* Implement DIOCGFRONTSTUFF ioctl which reports how many bytes from the startPoul-Henning Kamp2002-04-091-0/+4
| | | | | | | | | of the device magic stuff might occupy. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=94287
* Rename DIOCGKERNELDUMP to DIOCSKERNELDUMP as it strictly speakingPoul-Henning Kamp2002-04-091-1/+1
| | | | | | | | | is a "set" not a "get" operation. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=94272
* Here follows the new kernel dumping infrastructure.Poul-Henning Kamp2002-03-311-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Caveats: The new savecore program is not complete in the sense that it emulates enough of the old savecores features to do the job, but implements none of the options yet. I would appreciate if a userland hacker could help me out getting savecore to do what we want it to do from a users point of view, compression, email-notification, space reservation etc etc. (send me email if you are interested). Currently, savecore will scan all devices marked as "swap" or "dump" in /etc/fstab _or_ any devices specified on the command-line. All architectures but i386 lack an implementation of dumpsys(), but looking at the i386 version it should be trivial for anybody familiar with the platform(s) to provide this function. Documentation is quite sparse at this time, more to come. Details: ATA and SCSI drivers should work as the dump formatting code has been removed. The IDA, TWE and AAC have not yet been converted. Dumpon now opens the device and uses ioctl(DIOCGKERNELDUMP) to set the device as dumpdev. To implement the "off" argument, /dev/null is used as the device. Savecore will fail if handed any options since they are not (yet) implemented. All devices marked "dump" or "swap" in /etc/fstab will be scanned and dumps found will be saved to diskfiles named from the MD5 hash of the header record. The header record is dumped in readable format in the .info file. The kernel is not saved. Only complete dumps will be saved. All maintainer rights for this code are disclaimed: feel free to improve and extend. Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=93496
* Make the disk_clone() routine more robust for abuse.Poul-Henning Kamp2002-03-111-33/+26
| | | | | | | Sneak in a trivial bit of the GEOM stuff while we're here anyway. Notes: svn path=/head/; revision=92074
* Fix a warning.Robert Drehmel2002-03-051-2/+0
| | | | Notes: svn path=/head/; revision=91689
* Don't call cdevsw_add().Poul-Henning Kamp2001-11-041-1/+0
| | | | Notes: svn path=/head/; revision=86020
* Rename the top 7 bits if disk minors to spare bits, rather than type bits.Poul-Henning Kamp2001-11-041-1/+1
| | | | Notes: svn path=/head/; revision=86012
* Don't choke on old sd%d.ctl devices.Poul-Henning Kamp2001-11-031-0/+2
| | | | | | | Tripped over by: Jos Backus <josb@cncdsl.com> Notes: svn path=/head/; revision=85996
* Turn the symlinks around, instead of ad0s1 -> ad0s1c, make it ad0s1c -> ad0s1.Poul-Henning Kamp2001-11-021-13/+23
| | | | | | | Requested by: peter Notes: svn path=/head/; revision=85858
* Fix a problem in the disk related hack where device nodes for a physicallyPoul-Henning Kamp2001-10-281-0/+2
| | | | | | | | | | | non-existent disk in a legacy /dev on a DEVFS system would panic the system if stat(2)'ed. Do not whine about anonymous device nodes not having a si_devsw, they're not supposed to. Notes: svn path=/head/; revision=85624
* Nudge the axe a bit closer to cdevsw[]:Poul-Henning Kamp2001-10-271-2/+55
| | | | | | | | | | | | | | | Make it a panic to repeat make_dev() or destroy_dev(), this check should maybe be neutered when -current goes -stable. Whine if devsw() is called on anon dev_t's in a devfs system. Make a hack to avoid our lazy-eval disk code triggering the above whine. Fix the multiple make_dev() in disk code by making ${disk}${unit}s${slice} an alias/symlink to ${disk}${unit}s${slice}c Notes: svn path=/head/; revision=85603
* disk_clone() was a bit too eager to please: "md0s1ec" is not a validPoul-Henning Kamp2001-10-221-0/+2
| | | | | | | | | device. Noticed by: Chad David <davidc@acns.ab.ca> Notes: svn path=/head/; revision=85311
* KSE Milestone 2Julian Elischer2001-09-121-7/+7
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=83366
* Don't dump on the label sector or below. This avoids clobbering theBruce Evans2001-08-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | label if the dump device overflaps the label (which is a slight misconfiguration). Dump routines don't use dscheck(), so the normal write protection of the label doesn't help. Reduced some nearby overflow bugs. In disk_dumpcheck(), there was (fatal but fail-safe) overflow on i386's with 4GB of memory, at least if Maxmem was the top page (can this happen?). The fix assumes that the sector size divides PAGE_SIZE (dump routines already assume this). In setdumpdev(), the corresponding overflow occurred with only about 2GB of memory on all machines with 32-bit ints. This allowed setdumpdev() to succeed when it shouldn't have, but then disk_dumpcheck() failed safe later. Except in old versions of FreeBSD like RELENG_3 where there is no disk_dumpcheck(). PR: 28164 (label clobbering part) MFC after: 1 week Notes: svn path=/head/; revision=81688
* Remove the hack-around for the slice/label code, it didn'tPoul-Henning Kamp2001-05-291-11/+1
| | | | | | | cover the hole. Notes: svn path=/head/; revision=77408
* The disklabel/slice code is more twisted than I thought. Revert toPoul-Henning Kamp2001-05-281-0/+1
| | | | | | | calling the cdevsw_add() unconditionally. Notes: svn path=/head/; revision=77343
* Create a general facility for making dev_t's depend on anotherPoul-Henning Kamp2001-05-261-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_t. The dev_depends(dev_t, dev_t) function is for tying them to each other. When destroy_dev() is called on a dev_t, all dev_t's depending on it will also be destroyed (depth first order). Rewrite the make_dev_alias() to use this dependency facility. kern/subr_disk.c: Make the disk mini-layer use dependencies to make sure all relevant dev_t's are removed when the disk disappears. Make the disk mini-layer precreate some magic sub devices which the disk/slice/label code expects to be there. kern/subr_disklabel.c: Remove some now unneeded variables. kern/subr_diskmbr.c: Remove some ancient, commented out code. kern/subr_diskslice.c: Minor cleanup. Use name from dev_t instead of dsname() Notes: svn path=/head/; revision=77215
* Don't take the detour around devsw() to find out if the proto-cdevswPoul-Henning Kamp2001-05-241-3/+1
| | | | | | | is already initialized. Notes: svn path=/head/; revision=77147
* Always initialize bio_resid from bio_bcount in the disk mini-layer soPoul-Henning Kamp2001-05-081-1/+1
| | | | | | | that the drivers don't have to do it umpteen times. Notes: svn path=/head/; revision=76361
* Make the disk mini-layer check for and handle zero-length transfersPoul-Henning Kamp2001-05-061-0/+6
| | | | | | | instead of the underlying drivers. Notes: svn path=/head/; revision=76324
* Actually biofinish(struct bio *, struct devstat *, int error) is more generalPoul-Henning Kamp2001-05-061-3/+1
| | | | | | | | | than the bioerror(). Most of this patch is generated by scripts. Notes: svn path=/head/; revision=76322
* Dont call device close and ioctl functions if device has disappeared.Søren Schmidt2001-03-131-2/+5
| | | | | | | Reviewed by: phk Notes: svn path=/head/; revision=74206
* Don't clone impossible unit numbers for disks.Poul-Henning Kamp2000-12-151-0/+2
| | | | Notes: svn path=/head/; revision=70058
* Staticize some malloc M_ instances.Poul-Henning Kamp2000-12-081-1/+1
| | | | Notes: svn path=/head/; revision=69774
* Avoid the modules madness I inadvertently introduced by making thePoul-Henning Kamp2000-09-021-12/+1
| | | | | | | | | | | | | | | | | | | | | cloning infrastructure standard in kern_conf. Modules are now the same with or without devfs support. If you need to detect if devfs is present, in modules or elsewhere, check the integer variable "devfs_present". This happily removes an ugly hack from kern/vfs_conf.c. This forces a rename of the eventhandler and the standard clone helper function. Include <sys/eventhandler.h> in <sys/conf.h>: it's a helper #include like <sys/queue.h> Remove all #includes of opt_devfs.h they no longer matter. Notes: svn path=/head/; revision=65374
* Remove all traces of Julians DEVFS (incl from kern/subr_diskslice.c)Poul-Henning Kamp2000-08-201-2/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove old DEVFS support fields from dev_t. Make uid, gid & mode members of dev_t and set them in make_dev(). Use correct uid, gid & mode in make_dev in disk minilayer. Add support for registering alias names for a dev_t using the new function make_dev_alias(). These will show up as symlinks in DEVFS. Use makedev() rather than make_dev() for MFSs magic devices to prevent DEVFS from noticing this abuse. Add a field for DEVFS inode number in dev_t. Add new DEVFS in fs/devfs. Add devfs cloning to: disk minilayer (ie: ad(4), sd(4), cd(4) etc etc) md(4), tun(4), bpf(4), fd(4) If DEVFS add -d flag to /sbin/inits args to make it mount devfs. Add commented out DEVFS to GENERIC Notes: svn path=/head/; revision=64880
* End two weeks of on and off debugging. Fix the crash on the NthWarner Losh2000-07-051-24/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | insertion of a CF card, for random values of N > 1. With these fixes, I've been able to do 100 insert/remove of the cards w/o a crash with lots of system activity going on that in the past would help trigger the crash. The problem: FreeBSD creates dev_t's on the fly as they are needed and never destroys them. These dev_t's point to a struct disk that is used for housekeeping on the disk. When a device goes away, the struct disk pointer becomes a dangling pointer. Sometimes when the device comes back, the pointer will point to the new struct disk (in which case the insertion will work). Other times it won't (especially if any length of time has passed, since it is dependent on memory returned from malloc). The Fix: There is one of these dev_t's that is always correct. The device for the WHOLE_DISK_SLICE is always right. It gets set at create_disk() time. So, the fix is to spend a little CPU time and lookup the WHOLE_DISK_SLICE dev_t and use the si_disk from that in preference to the one that's in the device asking to do the I/O. In addition, we change the test of si_disk == NULL meaning that the dev needed to inherit properties from the pdev to dev->si_disk != pdev->si_disk. This test is a little stronger than the previous test, but can sometimes be fooled into not inheriting. However, the results of this fooling are that the old values will be used, which will generally always be the same as before. si_drv[12] are the only values that are copied that might pose a problem. They tend to change as the si_disk field would change, so it is a hole, but it is a small hole. One could correctly argue that one should replace much of this code with something much much better. I would be on the pro side of that argument. Reviewed by: phk (who also ported the original patch to current) Sponsored by: Timing Solutions Notes: svn path=/head/; revision=62617
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.Poul-Henning Kamp2000-07-041-1/+1
| | | | | | | Pointed out by: bde Notes: svn path=/head/; revision=62573
* Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:Poul-Henning Kamp2000-07-031-1/+1
| | | | | | | | | | | Sanitize SYSCTL_HANDLER_ARGS so that simplistic tools can grog our sources: -sysctl_vm_zone SYSCTL_HANDLER_ARGS +sysctl_vm_zone (SYSCTL_HANDLER_ARGS) Notes: svn path=/head/; revision=62454
* Add 'kern.disks', a sysctl which returns the list of disks fromNeil Blakey-Milner2000-06-221-0/+29
| | | | | | | | | | disk_enumerate(), space delimited. This allows non-root users to get a list of disks and will simplify libdisk's Disk_Names(). Reviewed by: phk Notes: svn path=/head/; revision=61953
* Add disk_enumerate() for finding names of disks. Vinum and libh willPoul-Henning Kamp2000-06-151-1/+15
| | | | | | | | | | | | | | | need this RSN. Remove a pointless warning in the root device locating code. Remove the "wd" compatibility name from the "ad" driver. WARNING: If you have not updated to use /dev/wd* in your /etc/fstab and modern bootblocks, it would be a very good idea to do so BEFORE you upgrade your kernel. Notes: svn path=/head/; revision=61717
* Separate the struct bio related stuff out of <sys/buf.h> intoPoul-Henning Kamp2000-05-051-1/+1
| | | | | | | | | | | | | | | | | | <sys/bio.h>. <sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall not be made a nested include according to bdes teachings on the subject of nested includes. Diskdrivers and similar stuff below specfs::strategy() should no longer need to include <sys/buf.> unless they need caching of data. Still a few bogus uses of struct buf to track down. Repocopy by: peter Notes: svn path=/head/; revision=60041
* Clone the {b|bio}_offset field, and make sure it is always initializedPoul-Henning Kamp2000-04-251-0/+2
| | | | | | | | | | in struct bio. Eventually, bio_offset will probably obsolete the bio_blkno and bio_pblkno fields. Remove the special hack in atapi-cd.c to determine of bio_offset was valid. Notes: svn path=/head/; revision=59623
* Complete the bio/buf divorce for all code below devfs::strategyPoul-Henning Kamp2000-04-151-11/+11
| | | | | | | | | | | | | Exceptions: Vinum untouched. This means that it cannot be compiled. Greg Lehey is on the case. CCD not converted yet, casts to struct buf (still safe) atapi-cd casts to struct buf to examine B_PHYS Notes: svn path=/head/; revision=59249
* Move B_ERROR flag to b_ioflags and call it BIO_ERROR.Poul-Henning Kamp2000-04-021-1/+1
| | | | | | | | | | | | | | | | (Much of this done by script) Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED. Move b_pblkno and b_iodone_chain to struct bio while we transition, they will be obsoleted once bio structs chain/stack. Add bio_queue field for struct bio aware disksort. Address a lot of stylistic issues brought up by bde. Notes: svn path=/head/; revision=58934
* Fixed a null pointer panic for dumpon(8) on a nonexistent device whoseBruce Evans2000-03-091-0/+2
| | | | | | | | | | driver uses the new disk layer. Reviewed by: phk Approved by: jkh Notes: svn path=/head/; revision=57850