Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: Document genhd capability flags

The kernel documentation includes a brief section about genhd
capabilities, but it turns out that the only documented
capability (GENHD_FL_MEDIA_CHANGE_NOTIFY) isn't used any more.

This patch removes that flag, and documents the rest, based on my
understanding of the current uses of these flags in the kernel. The
documentation is kept in the header file, alongside the declarations,
in the hope that it will be kept up-to-date in future; the kernel
documentation is changed to include the documentation generated from
the header file.

Because the ultimate goal is to provide some end-user
documentation (or end-administrator documentation), the comments are
perhaps more user-oriented than might be expected. Since the values
are shown to users in hexadecimal, the documentation lists them in
hexadecimal, and the constant declarations are adjusted to match.

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Stephen Kitt <steve@sk2.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Stephen Kitt and committed by
Jens Axboe
9243c6f3 ce24f736

+62 -23
+4 -12
Documentation/block/capability.rst
··· 2 2 Generic Block Device Capability 3 3 =============================== 4 4 5 - This file documents the sysfs file block/<disk>/capability 5 + This file documents the sysfs file ``block/<disk>/capability``. 6 6 7 - capability is a hex word indicating which capabilities a specific disk 8 - supports. For more information on bits not listed here, see 9 - include/linux/genhd.h 7 + ``capability`` is a bitfield, printed in hexadecimal, indicating which 8 + capabilities a specific block device supports: 10 9 11 - GENHD_FL_MEDIA_CHANGE_NOTIFY 12 - ---------------------------- 13 - 14 - Value: 4 15 - 16 - When this bit is set, the disk supports Asynchronous Notification 17 - of media change events. These events will be broadcast to user 18 - space via kernel uevent. 10 + .. kernel-doc:: include/linux/genhd.h
+58 -11
include/linux/genhd.h
··· 133 133 struct rcu_work rcu_work; 134 134 }; 135 135 136 - #define GENHD_FL_REMOVABLE 1 137 - /* 2 is unused */ 138 - #define GENHD_FL_MEDIA_CHANGE_NOTIFY 4 139 - #define GENHD_FL_CD 8 140 - #define GENHD_FL_UP 16 141 - #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 142 - #define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ 143 - #define GENHD_FL_NATIVE_CAPACITY 128 144 - #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256 145 - #define GENHD_FL_NO_PART_SCAN 512 146 - #define GENHD_FL_HIDDEN 1024 136 + /** 137 + * DOC: genhd capability flags 138 + * 139 + * ``GENHD_FL_REMOVABLE`` (0x0001): indicates that the block device 140 + * gives access to removable media. 141 + * When set, the device remains present even when media is not 142 + * inserted. 143 + * Must not be set for devices which are removed entirely when the 144 + * media is removed. 145 + * 146 + * ``GENHD_FL_CD`` (0x0008): the block device is a CD-ROM-style 147 + * device. 148 + * Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl. 149 + * 150 + * ``GENHD_FL_UP`` (0x0010): indicates that the block device is "up", 151 + * with a similar meaning to network interfaces. 152 + * 153 + * ``GENHD_FL_SUPPRESS_PARTITION_INFO`` (0x0020): don't include 154 + * partition information in ``/proc/partitions`` or in the output of 155 + * printk_all_partitions(). 156 + * Used for the null block device and some MMC devices. 157 + * 158 + * ``GENHD_FL_EXT_DEVT`` (0x0040): the driver supports extended 159 + * dynamic ``dev_t``, i.e. it wants extended device numbers 160 + * (``BLOCK_EXT_MAJOR``). 161 + * This affects the maximum number of partitions. 162 + * 163 + * ``GENHD_FL_NATIVE_CAPACITY`` (0x0080): based on information in the 164 + * partition table, the device's capacity has been extended to its 165 + * native capacity; i.e. the device has hidden capacity used by one 166 + * of the partitions (this is a flag used so that native capacity is 167 + * only ever unlocked once). 168 + * 169 + * ``GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE`` (0x0100): event polling is 170 + * blocked whenever a writer holds an exclusive lock. 171 + * 172 + * ``GENHD_FL_NO_PART_SCAN`` (0x0200): partition scanning is disabled. 173 + * Used for loop devices in their default settings and some MMC 174 + * devices. 175 + * 176 + * ``GENHD_FL_HIDDEN`` (0x0400): the block device is hidden; it 177 + * doesn't produce events, doesn't appear in sysfs, and doesn't have 178 + * an associated ``bdev``. 179 + * Implies ``GENHD_FL_SUPPRESS_PARTITION_INFO`` and 180 + * ``GENHD_FL_NO_PART_SCAN``. 181 + * Used for multipath devices. 182 + */ 183 + #define GENHD_FL_REMOVABLE 0x0001 184 + /* 2 is unused (used to be GENHD_FL_DRIVERFS) */ 185 + /* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */ 186 + #define GENHD_FL_CD 0x0008 187 + #define GENHD_FL_UP 0x0010 188 + #define GENHD_FL_SUPPRESS_PARTITION_INFO 0x0020 189 + #define GENHD_FL_EXT_DEVT 0x0040 190 + #define GENHD_FL_NATIVE_CAPACITY 0x0080 191 + #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100 192 + #define GENHD_FL_NO_PART_SCAN 0x0200 193 + #define GENHD_FL_HIDDEN 0x0400 147 194 148 195 enum { 149 196 DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */