Commit Graph

116 Commits

Author SHA1 Message Date
christos
d731d322c1 print the disklabel information on error if DIAGNOSTIC. 2016-01-06 00:22:30 +00:00
christos
8d10f96266 Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
2015-12-08 20:36:14 +00:00
mlelstv
4ff1b3e606 Handle sector sizes other than DEV_BSIZE when reading labels. 2015-11-28 14:36:00 +00:00
chs
f3abe35cbf in bounds_check_with_*, reject negative block numbers and avoid
a potential overflow in calculating the size of the request.
2015-05-14 17:31:24 +00:00
mlelstv
c0ea84ad3c Always fixup zero sector size, even when other geometry values are invalid. 2015-05-05 22:09:24 +00:00
christos
ed5aa85bd1 - Use NODEV instead of 0
- Return EBUSY if there was no label
2015-01-02 01:14:22 +00:00
mlelstv
2fbc202964 Retire disk_blocksize(). 2014-12-31 20:13:41 +00:00
christos
281c044fc6 Mention which ioctls need to move to dk_ioctl, and don't allow wedges on
wedges.
2014-12-31 19:58:59 +00:00
christos
c60db2e923 make more drivers use disk_ioctl, and add a dev parameter to it so that
we can merge the "easy" disklabel ioctls to it. Ultimately all this will
go do dk_ioctl once all the drivers have been converted.
2014-12-31 19:52:04 +00:00
christos
3be6bb2414 Centralize wedge ioctls in disk_ioctl. 2014-12-31 17:06:48 +00:00
mlelstv
bdddf44518 disk_blocksize and disk_set_info relay the same information
to the disk subsystem.

Make disk_set_info also set blocksize shift values.
Remove every call to disk_blocksize.

Keep disk_blocksize for ABI compatibility, make it also set dg_secsize.
2014-12-31 08:24:50 +00:00
mlelstv
c4ffe4b64c clear error for new ioctls. 2014-12-29 18:54:19 +00:00
mlelstv
78d420c356 Implement DIOCGMEDIASIZE and DIOCGSECTORSIZE from FreeBSD. 2014-12-29 18:41:20 +00:00
mlelstv
3d28892c85 use 64bit arithmetic to compute sectors-per-unit 2013-10-19 22:36:57 +00:00
christos
7b845fa9dc phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
	  n useless copies of it.
2013-05-29 00:47:48 +00:00
christos
a67c3c8971 printflike maintenance. 2013-02-09 00:31:21 +00:00
mrg
3eca36b665 add some (uint64_t) casts so avoid 32 bit overflows. this fixes my
3TB disk with 4KB sectors and disklabel (which looks like it would
work upto 16TB.)

idea from mlelstv@.
2010-10-14 00:47:16 +00:00
dsl
454df0687b When truncating a request in bounds_check_with_mediasize() multiply
by the provided sector size instead of 512.
Fixes last bit of PR/31565
2009-11-28 22:38:07 +00:00
tsutsui
c48b085654 u_short -> uint16_t, some KNF. 2009-11-27 11:23:50 +00:00
dyoung
85d8d1fcdd On second thought, let's call disk_predetach() disk_begindetach().
Verbs are good.
2009-05-20 03:26:21 +00:00
dyoung
a76a7fd159 Encapsulate the checks that I do before detaching a disk(9) provider
in a pre-detachment routine, disk_predetach().
2009-05-19 23:42:05 +00:00
ad
4307e10df2 Add disk_isbusy(), iostat_isbusy(). 2009-04-04 07:30:09 +00:00
yamt
cb1e92d5d5 malloc -> kmem_alloc 2009-01-22 14:38:34 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
matt
49cf9ad72a constify dkdriver 2008-02-28 04:55:47 +00:00
dyoung
cb8aa1ff9b Constify both struct disk->dk_name and the `name' argument to
disk_init().
2008-01-31 18:30:55 +00:00
ad
4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
ad
2af68666da Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
2007-10-08 16:41:05 +00:00
ad
66fefd117b It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
2007-07-29 12:15:35 +00:00
ad
b5a9ff06f1 Replace some uses of lockmgr(). 2007-07-21 19:51:47 +00:00
dyoung
1ee8f4a418 Extract common code from i386, xen, and sparc64, creating
config_handle_wedges() and read_disk_sectors().  On x86, handle_wedges()
is a thin wrapper for config_handle_wedges().  Share opendisk()
across architectures.

Add kernel code in support of specifying a root partition by wedge
name.  E.g., root specifications "wedge:wd0a", "wedge:David's Root
Volume" are possible.  (Patches for config(1) coming soon.)

In support of moving disks between architectures (esp. i386 <->
evbmips), I've written a routine convertdisklabel() that ensures
that the raw partition is at RAW_DISK by following these steps:

        0 If we have read a disklabel that has a RAW_PART with
          p_offset == 0 and p_size != 0, then use that raw partition.

        1 If we have read a disklabel that has both partitions 'c'
          and 'd', and RAW_PART has p_offset != 0 or p_size == 0,
          but the other partition is suitable for a raw partition
          (p_offset == 0, p_size != 0), then swap the two partitions
          and use the new raw partition.

        2 If the architecture's raw partition is 'd', and if there
          is no partition 'd', but there is a partition 'c' that
          is suitable for a raw partition, then copy partition 'c'
          to partition 'd'.

        3 Determine the drive's last sector, using either the
          d_secperunit the drive reported, or by guessing (0x1fffffff).
          If we cannot read the drive's last sector, then fail.

        4 If we have read a disklabel that has no partition slot
          RAW_PART, then create a partition RAW_PART.  Make it span
          the whole drive.

        5 If there are fewer than MAXPARTITIONS partitions,
          then "slide" the unsuitable raw partition RAW_PART, and
          subsequent partitions, into partition slots RAW_PART+1
          and subsequent slots.  Create a raw partition at RAW_PART.
          Make it span the whole drive.

The convertdisklabel() procedure can probably stand to be simplified,
but it ought to deal with all but an extraordinarily broken disklabel,
now.

i386: compiled and tested, sparc64: compiled, evbmips: compiled.
2007-06-24 01:43:34 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
martin
dd8b45ebc6 Split the disklabel checksum function into two, so we can pass the
length separately.
Use this for foreign-endianess labels in wedge autodiscovery, and
calculate the checksum of those before we swap various fields in the
label.
2007-03-01 21:30:50 +00:00
scw
e07faf8a74 Replace the myriad copies of bounds_check_with_label() with a single MI
version.

Add disk_blocksize(9) so that disk drivers can record the physical
block size of a disk if it is different to DEV_BSIZE. Right now this
simply initialises dk_blkshift and dk_byteshift according to the
supplied block size. This information is used in the MI version of
bounds_check_with_label().
2006-11-25 11:59:55 +00:00
thorpej
3c6ae35ab2 - Add a new disk ioctl (DIOCGDISKINFO) to get the disk-info dictionary
for the disk.
- Add a new function, disk_ioctl(), that does generic disk ioctl handling.
  DIOCGDISKINFO is handled here now, and others will be added in the future.
- In the wd driver, fill in the dk_info member of struct disk and use the
  new disk_ioctl() function.
2006-10-25 04:04:45 +00:00
thorpej
1edb40635e - Define disk information, disk geometry, and disk partition dictionary
schemas.  Disk information and disk geometry are designed to replace
  information currently conveyed to user space using struct disklabel.
- Add a dk_info member to struct disk; a reference to a disk information
  dictionary.  This dictionary is to be allocated and the reference stored
  in struct disk by individual drivers.
- disk_detach0() will release dk_info if non-NULL.
- Convert the wd(4) driver to stash geometry and other disk properties
  as the "disk-info" property in its properties dictionary.  This needs
  some cleanup, but will serve as an example of what to do with other
  disk drivers.
2006-09-22 04:48:38 +00:00
christos
f73c6e5980 Change iostat_alloc() to take the parent pointer and the name directly, so
that callers are not responsible for initializing the fields. Store the name
inside the struct instead of maintaining a pointer to external storage, or
leaked memory (nfs case).
2006-08-23 17:19:32 +00:00
kardel
de4337ab21 merge FreeBSD timecounters from branch simonb-timecounters
- struct timeval time is gone
  time.tv_sec -> time_second
- struct timeval mono_time is gone
  mono_time.tv_sec -> time_uptime
- access to time via
	{get,}{micro,nano,bin}time()
	get* versions are fast but less precise
- support NTP nanokernel implementation (NTP API 4)
- further reading:
  Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf
  NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html
2006-06-07 22:33:33 +00:00
yamt
b9eb99f927 iostat_find/disk_find: constify and simplify. 2006-04-21 13:53:30 +00:00
yamt
f7fc2f12db remove some unnecessary #include. 2006-04-21 13:51:24 +00:00
yamt
6237cabc7d whitespace. 2006-04-21 13:48:57 +00:00
blymn
10df330c85 Prefix iostat structure elements with io_ 2006-04-20 12:13:51 +00:00
blymn
3c0adb7d99 Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.
2006-04-14 13:09:05 +00:00
perry
144515ce1a u_intN_t -> uintN_t 2005-12-26 18:41:36 +00:00
christos
95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
yamt
aec75b1cc6 - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
  have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
  from sys/bufq.h to sys/bufq_impl.h.
  (is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c.  (not tested)
2005-10-15 17:29:10 +00:00
yamt
6f645a09cb introduce a variant of disk_attach/detach, for pseudo disks
which is opened by user before being attached.
2005-08-20 12:00:01 +00:00
christos
efb6943313 - add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.
2005-05-29 22:24:14 +00:00
yamt
99229e5d39 introduce a function to drain bufq and use it where appropriate. 2005-03-31 11:28:53 +00:00
fvdl
af5309b07c Change the 'sz' variable in bounds_check_* to int64_t to avoid overflows
when a very large blocknumber is passed in.
2005-02-08 08:56:21 +00:00