blob: 4ab853461dff25ea28ef760b7efdaf2bd680c0a3 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef _LINUX_GENHD_H
3#define _LINUX_GENHD_H
4
5/*
6 * genhd.h Copyright (C) 1992 Drew Eckhardt
7 * Generic hard disk header file by
8 * Drew Eckhardt
9 *
10 * <drew@colorado.edu>
11 */
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/types.h>
Kay Sieversedfaa7c2007-05-21 22:08:01 +020014#include <linux/kdev_t.h>
Tejun Heoe71bf0d2008-09-03 09:03:02 +020015#include <linux/rcupdate.h>
Will Drewry6d1d8052010-08-31 15:47:05 -050016#include <linux/slab.h>
Ming Lei6c710132015-07-16 11:16:45 +080017#include <linux/percpu-refcount.h>
Andy Shevchenko63579782016-05-20 17:01:24 -070018#include <linux/uuid.h>
Michael Callahandbae2c52018-07-18 04:47:38 -070019#include <linux/blk_types.h>
Mikulas Patocka1226b8d2018-12-06 11:41:20 -050020#include <asm/local.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Tejun Heo548b10e2008-08-29 09:01:47 +020022#define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev)
Tejun Heoed9e1982008-08-25 19:56:05 +090023#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
Tejun Heo548b10e2008-08-29 09:01:47 +020024#define disk_to_dev(disk) (&(disk)->part0.__dev)
Tejun Heoed9e1982008-08-25 19:56:05 +090025#define part_to_dev(part) (&((part)->__dev))
Kay Sieversedfaa7c2007-05-21 22:08:01 +020026
Boris Burkovef45fe42020-06-01 13:12:05 -070027extern const struct device_type disk_type;
Kay Sieversedfaa7c2007-05-21 22:08:01 +020028extern struct device_type part_type;
Kay Sieversedfaa7c2007-05-21 22:08:01 +020029extern struct class block_class;
30
Tejun Heo689d6fa2008-08-25 19:56:16 +090031#define DISK_MAX_PARTS 256
Tejun Heo3e1a7ff2008-08-25 19:56:17 +090032#define DISK_NAME_LEN 32
Tejun Heo689d6fa2008-08-25 19:56:16 +090033
David Woodhouse34186ef2006-04-25 14:07:57 +010034#include <linux/major.h>
35#include <linux/device.h>
36#include <linux/smp.h>
37#include <linux/string.h>
38#include <linux/fs.h>
Kristen Carlson Accardi8ce7ad7b2007-05-23 13:57:38 -070039#include <linux/workqueue.h>
David Woodhouse34186ef2006-04-25 14:07:57 +010040
Will Drewry6d1d8052010-08-31 15:47:05 -050041#define PARTITION_META_INFO_VOLNAMELTH 64
Stephen Warren1ad7e892012-11-08 16:12:25 -080042/*
43 * Enough for the string representation of any kind of UUID plus NULL.
44 * EFI UUID is 36 characters. MSDOS UUID is 11 characters.
45 */
Andy Shevchenko63579782016-05-20 17:01:24 -070046#define PARTITION_META_INFO_UUIDLTH (UUID_STRING_LEN + 1)
Will Drewry6d1d8052010-08-31 15:47:05 -050047
48struct partition_meta_info {
Stephen Warren1ad7e892012-11-08 16:12:25 -080049 char uuid[PARTITION_META_INFO_UUIDLTH];
Will Drewry6d1d8052010-08-31 15:47:05 -050050 u8 volname[PARTITION_META_INFO_VOLNAMELTH];
51};
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053struct hd_struct {
54 sector_t start_sect;
Vivek Goyalc83f6bf2012-08-01 12:24:18 +020055 /*
56 * nr_sects is protected by sequence counter. One might extend a
57 * partition while IO is happening to it and update of nr_sects
58 * can be non-atomic on 32bit machines with 64bit sector_t.
59 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 sector_t nr_sects;
Ming Lei07c4e1e2020-05-08 16:17:56 +080061#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
Vivek Goyalc83f6bf2012-08-01 12:24:18 +020062 seqcount_t nr_sects_seq;
Ming Lei07c4e1e2020-05-08 16:17:56 +080063#endif
Ming Lei520138c2020-05-08 16:17:57 +080064 unsigned long stamp;
Ming Lei520138c2020-05-08 16:17:57 +080065 struct disk_stats __percpu *dkstats;
Ming Lei520138c2020-05-08 16:17:57 +080066 struct percpu_ref ref;
67
Martin K. Petersenc72758f2009-05-22 17:17:53 -040068 sector_t alignment_offset;
Jens Axboea1706ac2011-05-30 07:42:51 +020069 unsigned int discard_alignment;
Tejun Heoed9e1982008-08-25 19:56:05 +090070 struct device __dev;
Jun'ichi Nomura6a4d44c2006-03-27 01:17:55 -080071 struct kobject *holder_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 int policy, partno;
Will Drewry6d1d8052010-08-31 15:47:05 -050073 struct partition_meta_info *info;
Akinobu Mitac17bb492006-12-08 02:39:46 -080074#ifdef CONFIG_FAIL_MAKE_REQUEST
75 int make_it_fail;
76#endif
Yufen Yu94a2c3a2018-11-28 16:42:01 +080077 struct rcu_work rcu_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078};
79
Stephen Kitt9243c6f2020-03-07 15:56:59 +010080/**
81 * DOC: genhd capability flags
82 *
83 * ``GENHD_FL_REMOVABLE`` (0x0001): indicates that the block device
84 * gives access to removable media.
85 * When set, the device remains present even when media is not
86 * inserted.
87 * Must not be set for devices which are removed entirely when the
88 * media is removed.
89 *
90 * ``GENHD_FL_CD`` (0x0008): the block device is a CD-ROM-style
91 * device.
92 * Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl.
93 *
94 * ``GENHD_FL_UP`` (0x0010): indicates that the block device is "up",
95 * with a similar meaning to network interfaces.
96 *
97 * ``GENHD_FL_SUPPRESS_PARTITION_INFO`` (0x0020): don't include
98 * partition information in ``/proc/partitions`` or in the output of
99 * printk_all_partitions().
100 * Used for the null block device and some MMC devices.
101 *
102 * ``GENHD_FL_EXT_DEVT`` (0x0040): the driver supports extended
103 * dynamic ``dev_t``, i.e. it wants extended device numbers
104 * (``BLOCK_EXT_MAJOR``).
105 * This affects the maximum number of partitions.
106 *
107 * ``GENHD_FL_NATIVE_CAPACITY`` (0x0080): based on information in the
108 * partition table, the device's capacity has been extended to its
109 * native capacity; i.e. the device has hidden capacity used by one
110 * of the partitions (this is a flag used so that native capacity is
111 * only ever unlocked once).
112 *
113 * ``GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE`` (0x0100): event polling is
114 * blocked whenever a writer holds an exclusive lock.
115 *
116 * ``GENHD_FL_NO_PART_SCAN`` (0x0200): partition scanning is disabled.
117 * Used for loop devices in their default settings and some MMC
118 * devices.
119 *
120 * ``GENHD_FL_HIDDEN`` (0x0400): the block device is hidden; it
121 * doesn't produce events, doesn't appear in sysfs, and doesn't have
122 * an associated ``bdev``.
123 * Implies ``GENHD_FL_SUPPRESS_PARTITION_INFO`` and
124 * ``GENHD_FL_NO_PART_SCAN``.
125 * Used for multipath devices.
126 */
127#define GENHD_FL_REMOVABLE 0x0001
128/* 2 is unused (used to be GENHD_FL_DRIVERFS) */
129/* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */
130#define GENHD_FL_CD 0x0008
131#define GENHD_FL_UP 0x0010
132#define GENHD_FL_SUPPRESS_PARTITION_INFO 0x0020
133#define GENHD_FL_EXT_DEVT 0x0040
134#define GENHD_FL_NATIVE_CAPACITY 0x0080
135#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100
136#define GENHD_FL_NO_PART_SCAN 0x0200
137#define GENHD_FL_HIDDEN 0x0400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
Tejun Heo77ea8872010-12-08 20:57:37 +0100139enum {
140 DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */
141 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */
142};
143
Martin Wilckc92e2f02019-03-27 14:51:02 +0100144enum {
145 /* Poll even if events_poll_msecs is unset */
146 DISK_EVENT_FLAG_POLL = 1 << 0,
147 /* Forward events to udev */
148 DISK_EVENT_FLAG_UEVENT = 1 << 1,
149};
150
Tejun Heo540eed52008-08-25 19:56:15 +0900151struct disk_part_tbl {
152 struct rcu_head rcu_head;
153 int len;
Arnd Bergmann4d2deb42010-02-24 20:01:56 +0100154 struct hd_struct __rcu *last_lookup;
155 struct hd_struct __rcu *part[];
Tejun Heo540eed52008-08-25 19:56:15 +0900156};
157
Tejun Heo77ea8872010-12-08 20:57:37 +0100158struct disk_events;
Vishal Verma99e66082016-01-09 08:36:51 -0800159struct badblocks;
Tejun Heo77ea8872010-12-08 20:57:37 +0100160
Martin K. Petersen25520d52015-10-21 13:19:49 -0400161struct blk_integrity {
Eric Biggers869ab902017-03-24 18:03:48 -0700162 const struct blk_integrity_profile *profile;
163 unsigned char flags;
164 unsigned char tuple_size;
165 unsigned char interval_exp;
166 unsigned char tag_size;
Martin K. Petersen25520d52015-10-21 13:19:49 -0400167};
168
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169struct gendisk {
Tejun Heo689d6fa2008-08-25 19:56:16 +0900170 /* major, first_minor and minors are input parameters only,
171 * don't use directly. Use disk_devt() and disk_max_parts().
Tejun Heof331c022008-09-03 09:01:48 +0200172 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 int major; /* major number of driver */
174 int first_minor;
175 int minors; /* maximum number of minors, =1 for
176 * disks that can't be partitioned. */
Tejun Heof331c022008-09-03 09:01:48 +0200177
Tejun Heo3e1a7ff2008-08-25 19:56:17 +0900178 char disk_name[DISK_NAME_LEN]; /* name of major driver */
Tejun Heo77ea8872010-12-08 20:57:37 +0100179
Martin Wilckc92e2f02019-03-27 14:51:02 +0100180 unsigned short events; /* supported events */
181 unsigned short event_flags; /* flags related to event processing */
Tejun Heo77ea8872010-12-08 20:57:37 +0100182
Tejun Heob5d0b9d2008-09-03 09:06:42 +0200183 /* Array of pointers to partitions indexed by partno.
Tejun Heoe71bf0d2008-09-03 09:03:02 +0200184 * Protected with matching bdev lock but stat and other
185 * non-critical accesses use RCU. Always access through
186 * helpers.
187 */
Arnd Bergmann4d2deb42010-02-24 20:01:56 +0100188 struct disk_part_tbl __rcu *part_tbl;
Tejun Heob5d0b9d2008-09-03 09:06:42 +0200189 struct hd_struct part0;
Tejun Heoe71bf0d2008-09-03 09:03:02 +0200190
Alexey Dobriyan83d5cde2009-09-21 17:01:13 -0700191 const struct block_device_operations *fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 struct request_queue *queue;
193 void *private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195 int flags;
Jan Kara56c09082018-02-26 13:01:41 +0100196 struct rw_semaphore lookup_sem;
Jun'ichi Nomura6a4d44c2006-03-27 01:17:55 -0800197 struct kobject *slave_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 struct timer_rand_state *random;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 atomic_t sync_io; /* RAID */
Tejun Heo77ea8872010-12-08 20:57:37 +0100201 struct disk_events *ev;
Martin K. Petersen7ba1ba12008-06-30 20:04:41 +0200202#ifdef CONFIG_BLK_DEV_INTEGRITY
Martin K. Petersenaff34e12015-10-21 13:19:27 -0400203 struct kobject integrity_kobj;
Martin K. Petersen25520d52015-10-21 13:19:49 -0400204#endif /* CONFIG_BLK_DEV_INTEGRITY */
Christoph Hellwiga711d912020-04-25 09:57:00 +0200205#if IS_ENABLED(CONFIG_CDROM)
206 struct cdrom_device_info *cdi;
207#endif
Tejun Heo540eed52008-08-25 19:56:15 +0900208 int node_id;
Vishal Verma99e66082016-01-09 08:36:51 -0800209 struct badblocks *bb;
Byungchul Parke319e1f2017-10-25 17:56:05 +0900210 struct lockdep_map lockdep_map;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211};
212
Christoph Hellwiga711d912020-04-25 09:57:00 +0200213#if IS_REACHABLE(CONFIG_CDROM)
214#define disk_to_cdi(disk) ((disk)->cdi)
215#else
216#define disk_to_cdi(disk) NULL
217#endif
218
Tejun Heo310a2c12008-08-25 19:47:17 +0900219static inline struct gendisk *part_to_disk(struct hd_struct *part)
220{
Tejun Heo548b10e2008-08-29 09:01:47 +0200221 if (likely(part)) {
222 if (part->partno)
223 return dev_to_disk(part_to_dev(part)->parent);
224 else
225 return dev_to_disk(part_to_dev(part));
226 }
Tejun Heo310a2c12008-08-25 19:47:17 +0900227 return NULL;
228}
229
Tejun Heof331c022008-09-03 09:01:48 +0200230static inline int disk_max_parts(struct gendisk *disk)
231{
Tejun Heo689d6fa2008-08-25 19:56:16 +0900232 if (disk->flags & GENHD_FL_EXT_DEVT)
233 return DISK_MAX_PARTS;
234 return disk->minors;
Tejun Heob5d0b9d2008-09-03 09:06:42 +0200235}
236
Tejun Heod27769e2011-08-23 20:01:04 +0200237static inline bool disk_part_scan_enabled(struct gendisk *disk)
Tejun Heob5d0b9d2008-09-03 09:06:42 +0200238{
Tejun Heod27769e2011-08-23 20:01:04 +0200239 return disk_max_parts(disk) > 1 &&
240 !(disk->flags & GENHD_FL_NO_PART_SCAN);
Tejun Heof331c022008-09-03 09:01:48 +0200241}
242
243static inline dev_t disk_devt(struct gendisk *disk)
244{
Christoph Hellwig517bf3c2017-11-02 21:29:52 +0300245 return MKDEV(disk->major, disk->first_minor);
Tejun Heof331c022008-09-03 09:01:48 +0200246}
247
248static inline dev_t part_devt(struct hd_struct *part)
249{
Tejun Heoed9e1982008-08-25 19:56:05 +0900250 return part_to_dev(part)->devt;
Tejun Heof331c022008-09-03 09:01:48 +0200251}
252
Greg Edwards67f25192017-10-24 11:21:48 -0600253extern struct hd_struct *__disk_get_part(struct gendisk *disk, int partno);
Tejun Heoe71bf0d2008-09-03 09:03:02 +0200254extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno);
255
256static inline void disk_put_part(struct hd_struct *part)
257{
258 if (likely(part))
Tejun Heoed9e1982008-08-25 19:56:05 +0900259 put_device(part_to_dev(part));
Tejun Heoe71bf0d2008-09-03 09:03:02 +0200260}
261
Ming Lei07c4e1e2020-05-08 16:17:56 +0800262static inline void hd_sects_seq_init(struct hd_struct *p)
263{
264#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
265 seqcount_init(&p->nr_sects_seq);
266#endif
267}
268
Tejun Heoe71bf0d2008-09-03 09:03:02 +0200269/*
270 * Smarter partition iterator without context limits.
271 */
272#define DISK_PITER_REVERSE (1 << 0) /* iterate in the reverse direction */
273#define DISK_PITER_INCL_EMPTY (1 << 1) /* include 0-sized parts */
Tejun Heob5d0b9d2008-09-03 09:06:42 +0200274#define DISK_PITER_INCL_PART0 (1 << 2) /* include partition 0 */
Tejun Heo71982a42009-04-17 08:34:48 +0200275#define DISK_PITER_INCL_EMPTY_PART0 (1 << 3) /* include empty partition 0 */
Tejun Heoe71bf0d2008-09-03 09:03:02 +0200276
277struct disk_part_iter {
278 struct gendisk *disk;
279 struct hd_struct *part;
280 int idx;
281 unsigned int flags;
282};
283
284extern void disk_part_iter_init(struct disk_part_iter *piter,
285 struct gendisk *disk, unsigned int flags);
286extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter);
287extern void disk_part_iter_exit(struct disk_part_iter *piter);
Linus Torvalds10f36b12020-03-30 11:20:13 -0700288extern bool disk_has_partitions(struct gendisk *disk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
Petros Koutoupis32ca1632009-03-10 08:25:54 +0100290/* block/genhd.c */
Hannes Reineckefef912b2018-09-28 08:17:19 +0200291extern void device_add_disk(struct device *parent, struct gendisk *disk,
292 const struct attribute_group **groups);
Dan Williamse63a46b2016-06-15 18:17:27 -0700293static inline void add_disk(struct gendisk *disk)
294{
Hannes Reineckefef912b2018-09-28 08:17:19 +0200295 device_add_disk(NULL, disk, NULL);
Dan Williamse63a46b2016-06-15 18:17:27 -0700296}
Mike Snitzerfa70d2e2018-01-08 22:01:13 -0500297extern void device_add_disk_no_queue_reg(struct device *parent, struct gendisk *disk);
298static inline void add_disk_no_queue_reg(struct gendisk *disk)
299{
300 device_add_disk_no_queue_reg(NULL, disk);
301}
Dan Williamse63a46b2016-06-15 18:17:27 -0700302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303extern void del_gendisk(struct gendisk *gp);
Tejun Heocf771cb2008-09-03 09:01:09 +0200304extern struct gendisk *get_gendisk(dev_t dev, int *partno);
Tejun Heof331c022008-09-03 09:01:48 +0200305extern struct block_device *bdget_disk(struct gendisk *disk, int partno);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307extern void set_device_ro(struct block_device *bdev, int flag);
308extern void set_disk_ro(struct gendisk *disk, int flag);
309
Tejun Heob7db9952008-08-25 19:56:10 +0900310static inline int get_disk_ro(struct gendisk *disk)
311{
312 return disk->part0.policy;
313}
314
Tejun Heo77ea8872010-12-08 20:57:37 +0100315extern void disk_block_events(struct gendisk *disk);
316extern void disk_unblock_events(struct gendisk *disk);
Tejun Heo85ef06d2011-07-01 16:17:47 +0200317extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
Balbir Singhe598a722020-03-13 05:30:05 +0000318extern void set_capacity_revalidate_and_notify(struct gendisk *disk,
319 sector_t size, bool revalidate);
Tejun Heo77ea8872010-12-08 20:57:37 +0100320extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
321
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322/* drivers/char/random.c */
Emese Revfy0766f782016-06-20 20:42:34 +0200323extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324extern void rand_initialize_disk(struct gendisk *disk);
325
326static inline sector_t get_start_sect(struct block_device *bdev)
327{
Tejun Heo0762b8b2008-08-25 19:56:12 +0900328 return bdev->bd_part->start_sect;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329}
330static inline sector_t get_capacity(struct gendisk *disk)
331{
Tejun Heo80795ae2008-08-25 19:56:07 +0900332 return disk->part0.nr_sects;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333}
334static inline void set_capacity(struct gendisk *disk, sector_t size)
335{
Tejun Heo80795ae2008-08-25 19:56:07 +0900336 disk->part0.nr_sects = size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337}
338
Christoph Hellwig142fe8f2019-11-14 15:34:35 +0100339int bdev_disk_changed(struct block_device *bdev, bool invalidate);
Christoph Hellwiga1548b62019-11-14 15:34:34 +0100340int blk_add_partitions(struct gendisk *disk, struct block_device *bdev);
Christoph Hellwigd46430b2020-04-14 09:28:57 +0200341int blk_drop_partitions(struct block_device *bdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342
Byungchul Parke319e1f2017-10-25 17:56:05 +0900343extern struct gendisk *__alloc_disk_node(int minors, int node_id);
Jan Kara3079c222018-02-26 13:01:38 +0100344extern struct kobject *get_disk_and_module(struct gendisk *disk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345extern void put_disk(struct gendisk *disk);
Jan Kara9df6c292018-02-26 13:01:39 +0100346extern void put_disk_and_module(struct gendisk *disk);
Kay Sieversedfaa7c2007-05-21 22:08:01 +0200347extern void blk_register_region(dev_t devt, unsigned long range,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 struct module *module,
349 struct kobject *(*probe)(dev_t, int *, void *),
350 int (*lock)(dev_t, void *),
351 void *data);
Kay Sieversedfaa7c2007-05-21 22:08:01 +0200352extern void blk_unregister_region(dev_t devt, unsigned long range);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
Byungchul Parke319e1f2017-10-25 17:56:05 +0900354#define alloc_disk_node(minors, node_id) \
355({ \
356 static struct lock_class_key __key; \
357 const char *__name; \
358 struct gendisk *__disk; \
359 \
360 __name = "(gendisk_completion)"#minors"("#node_id")"; \
361 \
362 __disk = __alloc_disk_node(minors, node_id); \
363 \
364 if (__disk) \
365 lockdep_init_map(&__disk->lockdep_map, __name, &__key, 0); \
366 \
367 __disk; \
368})
369
370#define alloc_disk(minors) alloc_disk_node(minors, NUMA_NO_NODE)
371
Christoph Hellwig3f1266f2020-06-20 09:16:41 +0200372int register_blkdev(unsigned int major, const char *name);
373void unregister_blkdev(unsigned int major, const char *name);
374
375int revalidate_disk(struct gendisk *disk);
376int check_disk_change(struct block_device *bdev);
377int __invalidate_device(struct block_device *bdev, bool kill_dirty);
378void bd_set_size(struct block_device *bdev, loff_t size);
379
380/* for drivers/char/raw.c: */
381int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
382long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
383
384#ifdef CONFIG_SYSFS
385int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk);
386void bd_unlink_disk_holder(struct block_device *bdev, struct gendisk *disk);
387#else
388static inline int bd_link_disk_holder(struct block_device *bdev,
389 struct gendisk *disk)
390{
391 return 0;
392}
393static inline void bd_unlink_disk_holder(struct block_device *bdev,
394 struct gendisk *disk)
395{
396}
397#endif /* CONFIG_SYSFS */
398
Christoph Hellwig1a4dcfa2020-06-20 09:16:43 +0200399#ifdef CONFIG_BLOCK
400void printk_all_partitions(void);
401dev_t blk_lookup_devt(const char *name, int partno);
Jens Axboe87c1efb2007-05-11 13:29:54 +0200402#else /* CONFIG_BLOCK */
Christoph Hellwig1a4dcfa2020-06-20 09:16:43 +0200403static inline void printk_all_partitions(void)
404{
405}
Tejun Heocf771cb2008-09-03 09:01:09 +0200406static inline dev_t blk_lookup_devt(const char *name, int partno)
Kay Sieversedfaa7c2007-05-21 22:08:01 +0200407{
408 dev_t devt = MKDEV(0, 0);
409 return devt;
410}
Jens Axboe87c1efb2007-05-11 13:29:54 +0200411#endif /* CONFIG_BLOCK */
David Howells93614012006-09-30 20:45:40 +0200412
David Woodhousea8ae50b2008-03-12 17:52:56 +0100413#endif /* _LINUX_GENHD_H */