History

Merge tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block

Pull block updates from Jens Axboe: - Online capacity resizing (Balbir) - Number of hardware queue change fixes (Bart) - null_blk fault injection addition (Bart) - Cleanup of queue allocation, unifying the node/no-node API (Christoph) - Cleanup of genhd, moving code to where it makes sense (Christoph) - Cleanup of the partition handling code (Christoph) - disk stat fixes/improvements (Konstantin) - BFQ improvements (Paolo) - Various fixes and improvements * tag 'for-5.7/block-2020-03-29' of git://git.kernel.dk/linux-block: (72 commits) block: return NULL in blk_alloc_queue() on error block: move bio_map_* to blk-map.c Revert "blkdev: check for valid request queue before issuing flush" block: simplify queue allocation bcache: pass the make_request methods to blk_queue_make_request null_blk: use blk_mq_init_queue_data block: add a blk_mq_init_queue_data helper block: move the ->devnode callback to struct block_device_operations block: move the part_stat* helpers from genhd.h to a new header block: move block layer internals out of include/linux/genhd.h block: move guard_bio_eod to bio.c block: unexport get_gendisk block: unexport disk_map_sector_rcu block: unexport disk_get_part block: mark part_in_flight and part_in_flight_rw static block: mark block_depr static block: factor out requeue handling from dispatch code block/diskstats: replace time_in_queue with sum of request times block/diskstats: accumulate all per-cpu counters in one pass block/diskstats: more accurate approximation of io_ticks for slow disks ...

Linus Torvalds committed 6 years ago

Commit 10f36b12 parents 3a0eb19 654a366111 files · +1950 −2039Browse files

Showing the changes to include/linux (9 of 111 files). Show all

Unified · Split

9 files
  1. include/linux/bio.h +1 −14
  2. include/linux/blk-mq.h +6 −1
  3. include/linux/blkdev.h +2 −12
  4. include/linux/fs.h +0 −1
  5. include/linux/genhd.h +61 −462
  6. include/linux/iocontext.h +1 −0
  7. include/linux/msdos_partition.h +50 −0
  8. include/linux/part_stat.h +115 −0
  9. include/linux/raid/detect.h +3 −0
include/linux/bio.h+1−14
@@ -441,14 +441,6 @@ void __bio_add_page(struct bio *bio, struct page *page, · 440 unmodified lines
441 unsigned int len, unsigned int off);441 unsigned int len, unsigned int off);
442int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter);442int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter);
443void bio_release_pages(struct bio *bio, bool mark_dirty);443void bio_release_pages(struct bio *bio, bool mark_dirty);
444struct rq_map_data;
445extern struct bio *bio_map_user_iov(struct request_queue *,
446 struct iov_iter *, gfp_t);
447extern void bio_unmap_user(struct bio *);
448extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int,
449 gfp_t);
450extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int,
451 gfp_t, int);
452extern void bio_set_pages_dirty(struct bio *bio);444extern void bio_set_pages_dirty(struct bio *bio);
453extern void bio_check_pages_dirty(struct bio *bio);445extern void bio_check_pages_dirty(struct bio *bio);
454 446
@@ -463,14 +455,9 @@ extern void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter, · 8 unmodified lines
463extern void bio_copy_data(struct bio *dst, struct bio *src);455extern void bio_copy_data(struct bio *dst, struct bio *src);
464extern void bio_list_copy_data(struct bio *dst, struct bio *src);456extern void bio_list_copy_data(struct bio *dst, struct bio *src);
465extern void bio_free_pages(struct bio *bio);457extern void bio_free_pages(struct bio *bio);
466
467extern struct bio *bio_copy_user_iov(struct request_queue *,
468 struct rq_map_data *,
469 struct iov_iter *,
470 gfp_t);
471extern int bio_uncopy_user(struct bio *);
472void zero_fill_bio_iter(struct bio *bio, struct bvec_iter iter);458void zero_fill_bio_iter(struct bio *bio, struct bvec_iter iter);
473void bio_truncate(struct bio *bio, unsigned new_size);459void bio_truncate(struct bio *bio, unsigned new_size);
460void guard_bio_eod(struct bio *bio);
474 461
475static inline void zero_fill_bio(struct bio *bio)462static inline void zero_fill_bio(struct bio *bio)
476{463{
include/linux/blk-mq.h+6−1
@@ -162,7 +162,10 @@ struct blk_mq_hw_ctx { · 161 unmodified lines
162 struct dentry *sched_debugfs_dir;162 struct dentry *sched_debugfs_dir;
163#endif163#endif
164 164
165 /** @hctx_list: List of all hardware queues. */165 /**
166 * @hctx_list: if this hctx is not in use, this is an entry in
167 * q->unused_hctx_list.
168 */
166 struct list_head hctx_list;169 struct list_head hctx_list;
167 170
168 /**171 /**
@@ -409,6 +412,8 @@ enum { · 240 unmodified lines
409 << BLK_MQ_F_ALLOC_POLICY_START_BIT)412 << BLK_MQ_F_ALLOC_POLICY_START_BIT)
410 413
411struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *);414struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *);
415struct request_queue *blk_mq_init_queue_data(struct blk_mq_tag_set *set,
416 void *queuedata);
412struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,417struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
413 struct request_queue *q,418 struct request_queue *q,
414 bool elevator_init);419 bool elevator_init);
include/linux/blkdev.h+2−12
@@ -1063,7 +1063,6 @@ extern void blk_abort_request(struct request *); · 1062 unmodified lines
1063 * Access functions for manipulating queue properties1063 * Access functions for manipulating queue properties
1064 */1064 */
1065extern void blk_cleanup_queue(struct request_queue *);1065extern void blk_cleanup_queue(struct request_queue *);
1066extern void blk_queue_make_request(struct request_queue *, make_request_fn *);
1067extern void blk_queue_bounce_limit(struct request_queue *, u64);1066extern void blk_queue_bounce_limit(struct request_queue *, u64);
1068extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int);1067extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int);
1069extern void blk_queue_chunk_sectors(struct request_queue *, unsigned int);1068extern void blk_queue_chunk_sectors(struct request_queue *, unsigned int);
@@ -1140,8 +1139,7 @@ extern void blk_dump_rq_flags(struct request *, char *); · 70 unmodified lines
1140extern long nr_blockdev_pages(void);1139extern long nr_blockdev_pages(void);
1141 1140
1142bool __must_check blk_get_queue(struct request_queue *);1141bool __must_check blk_get_queue(struct request_queue *);
1143struct request_queue *blk_alloc_queue(gfp_t);1142struct request_queue *blk_alloc_queue(make_request_fn make_request, int node_id);
1144struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id);
1145extern void blk_put_queue(struct request_queue *);1143extern void blk_put_queue(struct request_queue *);
1146extern void blk_set_queue_dying(struct request_queue *);1144extern void blk_set_queue_dying(struct request_queue *);
1147 1145
@@ -1484,15 +1482,6 @@ static inline unsigned int block_size(struct block_device *bdev) · 336 unmodified lines
1484 return bdev->bd_block_size;1482 return bdev->bd_block_size;
1485}1483}
1486 1484
1487typedef struct {struct page *v;} Sector;
1488
1489unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *);
1490
1491static inline void put_dev_sector(Sector p)
1492{
1493 put_page(p.v);
1494}
1495
1496int kblockd_schedule_work(struct work_struct *work);1485int kblockd_schedule_work(struct work_struct *work);
1497int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);1486int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
1498 1487
@@ -1706,6 +1695,7 @@ struct block_device_operations { · 207 unmodified lines
1706 void (*swap_slot_free_notify) (struct block_device *, unsigned long);1695 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
1707 int (*report_zones)(struct gendisk *, sector_t sector,1696 int (*report_zones)(struct gendisk *, sector_t sector,
1708 unsigned int nr_zones, report_zones_cb cb, void *data);1697 unsigned int nr_zones, report_zones_cb cb, void *data);
1698 char *(*devnode)(struct gendisk *disk, umode_t *mode);
1709 struct module *owner;1699 struct module *owner;
1710 const struct pr_ops *pr_ops;1700 const struct pr_ops *pr_ops;
1711};1701};
include/linux/fs.h+0−1
@@ -2700,7 +2700,6 @@ static inline void unregister_chrdev(unsigned int major, const char *name) · 2699 unmodified lines
2700 2700
2701#ifdef CONFIG_BLOCK2701#ifdef CONFIG_BLOCK
2702#define BLKDEV_MAJOR_MAX 5122702#define BLKDEV_MAJOR_MAX 512
2703extern const char *__bdevname(dev_t, char *buffer);
2704extern const char *bdevname(struct block_device *bdev, char *buffer);2703extern const char *bdevname(struct block_device *bdev, char *buffer);
2705extern struct block_device *lookup_bdev(const char *);2704extern struct block_device *lookup_bdev(const char *);
2706extern void blkdev_show(struct seq_file *,off_t);2705extern void blkdev_show(struct seq_file *,off_t);
include/linux/genhd.h+61−462
@@ -27,39 +27,8 @@ · 26 unmodified lines
27#define part_to_dev(part) (&((part)->__dev))27#define part_to_dev(part) (&((part)->__dev))
28 28
29extern struct device_type part_type;29extern struct device_type part_type;
30extern struct kobject *block_depr;
31extern struct class block_class;30extern struct class block_class;
32 31
33enum {
34/* These three have identical behaviour; use the second one if DOS FDISK gets
35 confused about extended/logical partitions starting past cylinder 1023. */
36 DOS_EXTENDED_PARTITION = 5,
37 LINUX_EXTENDED_PARTITION = 0x85,
38 WIN98_EXTENDED_PARTITION = 0x0f,
39
40 SUN_WHOLE_DISK = DOS_EXTENDED_PARTITION,
41
42 LINUX_SWAP_PARTITION = 0x82,
43 LINUX_DATA_PARTITION = 0x83,
44 LINUX_LVM_PARTITION = 0x8e,
45 LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
46
47 SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
48 NEW_SOLARIS_X86_PARTITION = 0xbf,
49
50 DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */
51 DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */
52 DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */
53 EZD_PARTITION = 0x55, /* EZ-DRIVE */
54
55 FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */
56 OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */
57 NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */
58 BSDI_PARTITION = 0xb7, /* BSDI Partition ID */
59 MINIX_PARTITION = 0x81, /* Minix Partition ID */
60 UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */
61};
62
63#define DISK_MAX_PARTS 25632#define DISK_MAX_PARTS 256
64#define DISK_NAME_LEN 3233#define DISK_NAME_LEN 32
65 34
@@ -70,26 +39,12 @@ enum { · 4 unmodified lines
70#include <linux/fs.h>39#include <linux/fs.h>
71#include <linux/workqueue.h>40#include <linux/workqueue.h>
72 41
73struct partition {
74 unsigned char boot_ind; /* 0x80 - active */
75 unsigned char head; /* starting head */
76 unsigned char sector; /* starting sector */
77 unsigned char cyl; /* starting cylinder */
78 unsigned char sys_ind; /* What partition type */
79 unsigned char end_head; /* end head */
80 unsigned char end_sector; /* end sector */
81 unsigned char end_cyl; /* end cylinder */
82 __le32 start_sect; /* starting sector counting from 0 */
83 __le32 nr_sects; /* nr of sectors in partition */
84} __attribute__((packed));
85
86struct disk_stats {42struct disk_stats {
87 u64 nsecs[NR_STAT_GROUPS];43 u64 nsecs[NR_STAT_GROUPS];
88 unsigned long sectors[NR_STAT_GROUPS];44 unsigned long sectors[NR_STAT_GROUPS];
89 unsigned long ios[NR_STAT_GROUPS];45 unsigned long ios[NR_STAT_GROUPS];
90 unsigned long merges[NR_STAT_GROUPS];46 unsigned long merges[NR_STAT_GROUPS];
91 unsigned long io_ticks;47 unsigned long io_ticks;
92 unsigned long time_in_queue;
93 local_t in_flight[2];48 local_t in_flight[2];
94};49};
95 50
@@ -133,17 +88,64 @@ struct hd_struct { · 37 unmodified lines
133 struct rcu_work rcu_work;88 struct rcu_work rcu_work;
134};89};
135 90
136#define GENHD_FL_REMOVABLE 191/**
137/* 2 is unused */92 * DOC: genhd capability flags
138#define GENHD_FL_MEDIA_CHANGE_NOTIFY 493 *
139#define GENHD_FL_CD 894 * ``GENHD_FL_REMOVABLE`` (0x0001): indicates that the block device
140#define GENHD_FL_UP 1695 * gives access to removable media.
141#define GENHD_FL_SUPPRESS_PARTITION_INFO 3296 * When set, the device remains present even when media is not
142#define GENHD_FL_EXT_DEVT 64 /* allow extended devt */97 * inserted.
143#define GENHD_FL_NATIVE_CAPACITY 12898 * Must not be set for devices which are removed entirely when the
144#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 25699 * media is removed.
145#define GENHD_FL_NO_PART_SCAN 512100 *
146#define GENHD_FL_HIDDEN 1024101 * ``GENHD_FL_CD`` (0x0008): the block device is a CD-ROM-style
102 * device.
103 * Affects responses to the ``CDROM_GET_CAPABILITY`` ioctl.
104 *
105 * ``GENHD_FL_UP`` (0x0010): indicates that the block device is "up",
106 * with a similar meaning to network interfaces.
107 *
108 * ``GENHD_FL_SUPPRESS_PARTITION_INFO`` (0x0020): don't include
109 * partition information in ``/proc/partitions`` or in the output of
110 * printk_all_partitions().
111 * Used for the null block device and some MMC devices.
112 *
113 * ``GENHD_FL_EXT_DEVT`` (0x0040): the driver supports extended
114 * dynamic ``dev_t``, i.e. it wants extended device numbers
115 * (``BLOCK_EXT_MAJOR``).
116 * This affects the maximum number of partitions.
117 *
118 * ``GENHD_FL_NATIVE_CAPACITY`` (0x0080): based on information in the
119 * partition table, the device's capacity has been extended to its
120 * native capacity; i.e. the device has hidden capacity used by one
121 * of the partitions (this is a flag used so that native capacity is
122 * only ever unlocked once).
123 *
124 * ``GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE`` (0x0100): event polling is
125 * blocked whenever a writer holds an exclusive lock.
126 *
127 * ``GENHD_FL_NO_PART_SCAN`` (0x0200): partition scanning is disabled.
128 * Used for loop devices in their default settings and some MMC
129 * devices.
130 *
131 * ``GENHD_FL_HIDDEN`` (0x0400): the block device is hidden; it
132 * doesn't produce events, doesn't appear in sysfs, and doesn't have
133 * an associated ``bdev``.
134 * Implies ``GENHD_FL_SUPPRESS_PARTITION_INFO`` and
135 * ``GENHD_FL_NO_PART_SCAN``.
136 * Used for multipath devices.
137 */
138#define GENHD_FL_REMOVABLE 0x0001
139/* 2 is unused (used to be GENHD_FL_DRIVERFS) */
140/* 4 is unused (used to be GENHD_FL_MEDIA_CHANGE_NOTIFY) */
141#define GENHD_FL_CD 0x0008
142#define GENHD_FL_UP 0x0010
143#define GENHD_FL_SUPPRESS_PARTITION_INFO 0x0020
144#define GENHD_FL_EXT_DEVT 0x0040
145#define GENHD_FL_NATIVE_CAPACITY 0x0080
146#define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 0x0100
147#define GENHD_FL_NO_PART_SCAN 0x0200
148#define GENHD_FL_HIDDEN 0x0400
147 149
148enum {150enum {
149 DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */151 DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */
@@ -189,7 +191,6 @@ struct gendisk { · 39 unmodified lines
189 * disks that can't be partitioned. */191 * disks that can't be partitioned. */
190 192
191 char disk_name[DISK_NAME_LEN]; /* name of major driver */193 char disk_name[DISK_NAME_LEN]; /* name of major driver */
192 char *(*devnode)(struct gendisk *gd, umode_t *mode);
193 194
194 unsigned short events; /* supported events */195 unsigned short events; /* supported events */
195 unsigned short event_flags; /* flags related to event processing */196 unsigned short event_flags; /* flags related to event processing */
@@ -283,144 +284,7 @@ extern void disk_part_iter_init(struct disk_part_iter *piter, · 87 unmodified lines
283 struct gendisk *disk, unsigned int flags);284 struct gendisk *disk, unsigned int flags);
284extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter);285extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter);
285extern void disk_part_iter_exit(struct disk_part_iter *piter);286extern void disk_part_iter_exit(struct disk_part_iter *piter);
286 287extern bool disk_has_partitions(struct gendisk *disk);
287extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk,
288 sector_t sector);
289bool disk_has_partitions(struct gendisk *disk);
290
291/*
292 * Macros to operate on percpu disk statistics:
293 *
294 * {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters
295 * and should be called between disk_stat_lock() and
296 * disk_stat_unlock().
297 *
298 * part_stat_read() can be called at any time.
299 *
300 * part_stat_{add|set_all}() and {init|free}_part_stats are for
301 * internal use only.
302 */
303#ifdef CONFIG_SMP
304#define part_stat_lock() ({ rcu_read_lock(); get_cpu(); })
305#define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0)
306
307#define part_stat_get_cpu(part, field, cpu) \
308 (per_cpu_ptr((part)->dkstats, (cpu))->field)
309
310#define part_stat_get(part, field) \
311 part_stat_get_cpu(part, field, smp_processor_id())
312
313#define part_stat_read(part, field) \
314({ \
315 typeof((part)->dkstats->field) res = 0; \
316 unsigned int _cpu; \
317 for_each_possible_cpu(_cpu) \
318 res += per_cpu_ptr((part)->dkstats, _cpu)->field; \
319 res; \
320})
321
322static inline void part_stat_set_all(struct hd_struct *part, int value)
323{
324 int i;
325
326 for_each_possible_cpu(i)
327 memset(per_cpu_ptr(part->dkstats, i), value,
328 sizeof(struct disk_stats));
329}
330
331static inline int init_part_stats(struct hd_struct *part)
332{
333 part->dkstats = alloc_percpu(struct disk_stats);
334 if (!part->dkstats)
335 return 0;
336 return 1;
337}
338
339static inline void free_part_stats(struct hd_struct *part)
340{
341 free_percpu(part->dkstats);
342}
343
344#else /* !CONFIG_SMP */
345#define part_stat_lock() ({ rcu_read_lock(); 0; })
346#define part_stat_unlock() rcu_read_unlock()
347
348#define part_stat_get(part, field) ((part)->dkstats.field)
349#define part_stat_get_cpu(part, field, cpu) part_stat_get(part, field)
350#define part_stat_read(part, field) part_stat_get(part, field)
351
352static inline void part_stat_set_all(struct hd_struct *part, int value)
353{
354 memset(&part->dkstats, value, sizeof(struct disk_stats));
355}
356
357static inline int init_part_stats(struct hd_struct *part)
358{
359 return 1;
360}
361
362static inline void free_part_stats(struct hd_struct *part)
363{
364}
365
366#endif /* CONFIG_SMP */
367
368#define part_stat_read_msecs(part, which) \
369 div_u64(part_stat_read(part, nsecs[which]), NSEC_PER_MSEC)
370
371#define part_stat_read_accum(part, field) \
372 (part_stat_read(part, field[STAT_READ]) + \
373 part_stat_read(part, field[STAT_WRITE]) + \
374 part_stat_read(part, field[STAT_DISCARD]))
375
376#define __part_stat_add(part, field, addnd) \
377 (part_stat_get(part, field) += (addnd))
378
379#define part_stat_add(part, field, addnd) do { \
380 __part_stat_add((part), field, addnd); \
381 if ((part)->partno) \
382 __part_stat_add(&part_to_disk((part))->part0, \
383 field, addnd); \
384} while (0)
385
386#define part_stat_dec(gendiskp, field) \
387 part_stat_add(gendiskp, field, -1)
388#define part_stat_inc(gendiskp, field) \
389 part_stat_add(gendiskp, field, 1)
390#define part_stat_sub(gendiskp, field, subnd) \
391 part_stat_add(gendiskp, field, -subnd)
392
393#define part_stat_local_dec(gendiskp, field) \
394 local_dec(&(part_stat_get(gendiskp, field)))
395#define part_stat_local_inc(gendiskp, field) \
396 local_inc(&(part_stat_get(gendiskp, field)))
397#define part_stat_local_read(gendiskp, field) \
398 local_read(&(part_stat_get(gendiskp, field)))
399#define part_stat_local_read_cpu(gendiskp, field, cpu) \
400 local_read(&(part_stat_get_cpu(gendiskp, field, cpu)))
401
402unsigned int part_in_flight(struct request_queue *q, struct hd_struct *part);
403void part_in_flight_rw(struct request_queue *q, struct hd_struct *part,
404 unsigned int inflight[2]);
405void part_dec_in_flight(struct request_queue *q, struct hd_struct *part,
406 int rw);
407void part_inc_in_flight(struct request_queue *q, struct hd_struct *part,
408 int rw);
409
410static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk)
411{
412 if (disk)
413 return kzalloc_node(sizeof(struct partition_meta_info),
414 GFP_KERNEL, disk->node_id);
415 return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL);
416}
417
418static inline void free_part_info(struct hd_struct *part)
419{
420 kfree(part->info);
421}
422
423void update_io_ticks(struct hd_struct *part, unsigned long now);
424 288
425/* block/genhd.c */289/* block/genhd.c */
426extern void device_add_disk(struct device *parent, struct gendisk *disk,290extern void device_add_disk(struct device *parent, struct gendisk *disk,
@@ -450,6 +314,8 @@ static inline int get_disk_ro(struct gendisk *disk) · 23 unmodified lines
450extern void disk_block_events(struct gendisk *disk);314extern void disk_block_events(struct gendisk *disk);
451extern void disk_unblock_events(struct gendisk *disk);315extern void disk_unblock_events(struct gendisk *disk);
452extern void disk_flush_events(struct gendisk *disk, unsigned int mask);316extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
317extern void set_capacity_revalidate_and_notify(struct gendisk *disk,
318 sector_t size, bool revalidate);
453extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);319extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
454 320
455/* drivers/char/random.c */321/* drivers/char/random.c */
@@ -469,170 +335,11 @@ static inline void set_capacity(struct gendisk *disk, sector_t size) · 13 unmodified lines
469 disk->part0.nr_sects = size;335 disk->part0.nr_sects = size;
470}336}
471 337
472#ifdef CONFIG_SOLARIS_X86_PARTITION
473
474#define SOLARIS_X86_NUMSLICE 16
475#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
476
477struct solaris_x86_slice {
478 __le16 s_tag; /* ID tag of partition */
479 __le16 s_flag; /* permission flags */
480 __le32 s_start; /* start sector no of partition */
481 __le32 s_size; /* # of blocks in partition */
482};
483
484struct solaris_x86_vtoc {
485 unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */
486 __le32 v_sanity; /* to verify vtoc sanity */
487 __le32 v_version; /* layout version */
488 char v_volume[8]; /* volume name */
489 __le16 v_sectorsz; /* sector size in bytes */
490 __le16 v_nparts; /* number of partitions */
491 unsigned int v_reserved[10]; /* free space */
492 struct solaris_x86_slice
493 v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
494 unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */
495 char v_asciilabel[128]; /* for compatibility */
496};
497
498#endif /* CONFIG_SOLARIS_X86_PARTITION */
499
500#ifdef CONFIG_BSD_DISKLABEL
501/*
502 * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il>
503 * updated by Marc Espie <Marc.Espie@openbsd.org>
504 */
505
506/* check against BSD src/sys/sys/disklabel.h for consistency */
507
508#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */
509#define BSD_MAXPARTITIONS 16
510#define OPENBSD_MAXPARTITIONS 16
511#define BSD_FS_UNUSED 0 /* disklabel unused partition entry ID */
512struct bsd_disklabel {
513 __le32 d_magic; /* the magic number */
514 __s16 d_type; /* drive type */
515 __s16 d_subtype; /* controller/d_type specific */
516 char d_typename[16]; /* type name, e.g. "eagle" */
517 char d_packname[16]; /* pack identifier */
518 __u32 d_secsize; /* # of bytes per sector */
519 __u32 d_nsectors; /* # of data sectors per track */
520 __u32 d_ntracks; /* # of tracks per cylinder */
521 __u32 d_ncylinders; /* # of data cylinders per unit */
522 __u32 d_secpercyl; /* # of data sectors per cylinder */
523 __u32 d_secperunit; /* # of data sectors per unit */
524 __u16 d_sparespertrack; /* # of spare sectors per track */
525 __u16 d_sparespercyl; /* # of spare sectors per cylinder */
526 __u32 d_acylinders; /* # of alt. cylinders per unit */
527 __u16 d_rpm; /* rotational speed */
528 __u16 d_interleave; /* hardware sector interleave */
529 __u16 d_trackskew; /* sector 0 skew, per track */
530 __u16 d_cylskew; /* sector 0 skew, per cylinder */
531 __u32 d_headswitch; /* head switch time, usec */
532 __u32 d_trkseek; /* track-to-track seek, usec */
533 __u32 d_flags; /* generic flags */
534#define NDDATA 5
535 __u32 d_drivedata[NDDATA]; /* drive-type specific information */
536#define NSPARE 5
537 __u32 d_spare[NSPARE]; /* reserved for future use */
538 __le32 d_magic2; /* the magic number (again) */
539 __le16 d_checksum; /* xor of data incl. partitions */
540
541 /* filesystem and partition information: */
542 __le16 d_npartitions; /* number of partitions in following */
543 __le32 d_bbsize; /* size of boot area at sn0, bytes */
544 __le32 d_sbsize; /* max size of fs superblock, bytes */
545 struct bsd_partition { /* the partition table */
546 __le32 p_size; /* number of sectors in partition */
547 __le32 p_offset; /* starting sector */
548 __le32 p_fsize; /* filesystem basic fragment size */
549 __u8 p_fstype; /* filesystem type, see below */
550 __u8 p_frag; /* filesystem fragments per block */
551 __le16 p_cpg; /* filesystem cylinders per group */
552 } d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
553};
554
555#endif /* CONFIG_BSD_DISKLABEL */
556
557#ifdef CONFIG_UNIXWARE_DISKLABEL
558/*
559 * Unixware slices support by Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
560 * and Krzysztof G. Baranowski <kgb@knm.org.pl>
561 */
562
563#define UNIXWARE_DISKMAGIC (0xCA5E600DUL) /* The disk magic number */
564#define UNIXWARE_DISKMAGIC2 (0x600DDEEEUL) /* The slice table magic nr */
565#define UNIXWARE_NUMSLICE 16
566#define UNIXWARE_FS_UNUSED 0 /* Unused slice entry ID */
567
568struct unixware_slice {
569 __le16 s_label; /* label */
570 __le16 s_flags; /* permission flags */
571 __le32 start_sect; /* starting sector */
572 __le32 nr_sects; /* number of sectors in slice */
573};
574
575struct unixware_disklabel {
576 __le32 d_type; /* drive type */
577 __le32 d_magic; /* the magic number */
578 __le32 d_version; /* version number */
579 char d_serial[12]; /* serial number of the device */
580 __le32 d_ncylinders; /* # of data cylinders per device */
581 __le32 d_ntracks; /* # of tracks per cylinder */
582 __le32 d_nsectors; /* # of data sectors per track */
583 __le32 d_secsize; /* # of bytes per sector */
584 __le32 d_part_start; /* # of first sector of this partition */
585 __le32 d_unknown1[12]; /* ? */
586 __le32 d_alt_tbl; /* byte offset of alternate table */
587 __le32 d_alt_len; /* byte length of alternate table */
588 __le32 d_phys_cyl; /* # of physical cylinders per device */
589 __le32 d_phys_trk; /* # of physical tracks per cylinder */
590 __le32 d_phys_sec; /* # of physical sectors per track */
591 __le32 d_phys_bytes; /* # of physical bytes per sector */
592 __le32 d_unknown2; /* ? */
593 __le32 d_unknown3; /* ? */
594 __le32 d_pad[8]; /* pad */
595
596 struct unixware_vtoc {
597 __le32 v_magic; /* the magic number */
598 __le32 v_version; /* version number */
599 char v_name[8]; /* volume name */
600 __le16 v_nslices; /* # of slices */
601 __le16 v_unknown1; /* ? */
602 __le32 v_reserved[10]; /* reserved */
603 struct unixware_slice
604 v_slice[UNIXWARE_NUMSLICE]; /* slice headers */
605 } vtoc;
606
607}; /* 408 */
608
609#endif /* CONFIG_UNIXWARE_DISKLABEL */
610
611#ifdef CONFIG_MINIX_SUBPARTITION
612# define MINIX_NR_SUBPARTITIONS 4
613#endif /* CONFIG_MINIX_SUBPARTITION */
614
615#define ADDPART_FLAG_NONE 0
616#define ADDPART_FLAG_RAID 1
617#define ADDPART_FLAG_WHOLEDISK 2
618
619extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt);
620extern void blk_free_devt(dev_t devt);
621extern void blk_invalidate_devt(dev_t devt);
622extern dev_t blk_lookup_devt(const char *name, int partno);338extern dev_t blk_lookup_devt(const char *name, int partno);
623extern char *disk_name (struct gendisk *hd, int partno, char *buf);
624 339
625int bdev_disk_changed(struct block_device *bdev, bool invalidate);340int bdev_disk_changed(struct block_device *bdev, bool invalidate);
626int blk_add_partitions(struct gendisk *disk, struct block_device *bdev);341int blk_add_partitions(struct gendisk *disk, struct block_device *bdev);
627int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev);342int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev);
628extern int disk_expand_part_tbl(struct gendisk *disk, int target);
629extern struct hd_struct * __must_check add_partition(struct gendisk *disk,
630 int partno, sector_t start,
631 sector_t len, int flags,
632 struct partition_meta_info
633 *info);
634extern void __delete_partition(struct percpu_ref *);
635extern void delete_partition(struct gendisk *, int);
636extern void printk_all_partitions(void);343extern void printk_all_partitions(void);
637 344
638extern struct gendisk *__alloc_disk_node(int minors, int node_id);345extern struct gendisk *__alloc_disk_node(int minors, int node_id);
@@ -646,20 +353,6 @@ extern void blk_register_region(dev_t devt, unsigned long range, · 7 unmodified lines
646 void *data);353 void *data);
647extern void blk_unregister_region(dev_t devt, unsigned long range);354extern void blk_unregister_region(dev_t devt, unsigned long range);
648 355
649extern ssize_t part_size_show(struct device *dev,
650 struct device_attribute *attr, char *buf);
651extern ssize_t part_stat_show(struct device *dev,
652 struct device_attribute *attr, char *buf);
653extern ssize_t part_inflight_show(struct device *dev,
654 struct device_attribute *attr, char *buf);
655#ifdef CONFIG_FAIL_MAKE_REQUEST
656extern ssize_t part_fail_show(struct device *dev,
657 struct device_attribute *attr, char *buf);
658extern ssize_t part_fail_store(struct device *dev,
659 struct device_attribute *attr,
660 const char *buf, size_t count);
661#endif /* CONFIG_FAIL_MAKE_REQUEST */
662
663#define alloc_disk_node(minors, node_id) \356#define alloc_disk_node(minors, node_id) \
664({ \357({ \
665 static struct lock_class_key __key; \358 static struct lock_class_key __key; \
@@ -678,100 +371,6 @@ extern ssize_t part_fail_store(struct device *dev, · 12 unmodified lines
678 371
679#define alloc_disk(minors) alloc_disk_node(minors, NUMA_NO_NODE)372#define alloc_disk(minors) alloc_disk_node(minors, NUMA_NO_NODE)
680 373
681static inline int hd_ref_init(struct hd_struct *part)
682{
683 if (percpu_ref_init(&part->ref, __delete_partition, 0,
684 GFP_KERNEL))
685 return -ENOMEM;
686 return 0;
687}
688
689static inline void hd_struct_get(struct hd_struct *part)
690{
691 percpu_ref_get(&part->ref);
692}
693
694static inline int hd_struct_try_get(struct hd_struct *part)
695{
696 return percpu_ref_tryget_live(&part->ref);
697}
698
699static inline void hd_struct_put(struct hd_struct *part)
700{
701 percpu_ref_put(&part->ref);
702}
703
704static inline void hd_struct_kill(struct hd_struct *part)
705{
706 percpu_ref_kill(&part->ref);
707}
708
709static inline void hd_free_part(struct hd_struct *part)
710{
711 free_part_stats(part);
712 free_part_info(part);
713 percpu_ref_exit(&part->ref);
714}
715
716/*
717 * Any access of part->nr_sects which is not protected by partition
718 * bd_mutex or gendisk bdev bd_mutex, should be done using this
719 * accessor function.
720 *
721 * Code written along the lines of i_size_read() and i_size_write().
722 * CONFIG_PREEMPTION case optimizes the case of UP kernel with preemption
723 * on.
724 */
725static inline sector_t part_nr_sects_read(struct hd_struct *part)
726{
727#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
728 sector_t nr_sects;
729 unsigned seq;
730 do {
731 seq = read_seqcount_begin(&part->nr_sects_seq);
732 nr_sects = part->nr_sects;
733 } while (read_seqcount_retry(&part->nr_sects_seq, seq));
734 return nr_sects;
735#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
736 sector_t nr_sects;
737
738 preempt_disable();
739 nr_sects = part->nr_sects;
740 preempt_enable();
741 return nr_sects;
742#else
743 return part->nr_sects;
744#endif
745}
746
747/*
748 * Should be called with mutex lock held (typically bd_mutex) of partition
749 * to provide mutual exlusion among writers otherwise seqcount might be
750 * left in wrong state leaving the readers spinning infinitely.
751 */
752static inline void part_nr_sects_write(struct hd_struct *part, sector_t size)
753{
754#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
755 write_seqcount_begin(&part->nr_sects_seq);
756 part->nr_sects = size;
757 write_seqcount_end(&part->nr_sects_seq);
758#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
759 preempt_disable();
760 part->nr_sects = size;
761 preempt_enable();
762#else
763 part->nr_sects = size;
764#endif
765}
766
767#if defined(CONFIG_BLK_DEV_INTEGRITY)
768extern void blk_integrity_add(struct gendisk *);
769extern void blk_integrity_del(struct gendisk *);
770#else /* CONFIG_BLK_DEV_INTEGRITY */
771static inline void blk_integrity_add(struct gendisk *disk) { }
772static inline void blk_integrity_del(struct gendisk *disk) { }
773#endif /* CONFIG_BLK_DEV_INTEGRITY */
774
775#else /* CONFIG_BLOCK */374#else /* CONFIG_BLOCK */
776 375
777static inline void printk_all_partitions(void) { }376static inline void printk_all_partitions(void) { }
include/linux/iocontext.h+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
8 8
9enum {9enum {
10 ICQ_EXITED = 1 << 2,10 ICQ_EXITED = 1 << 2,
11 ICQ_DESTROYED = 1 << 3,
11};12};
12 13
13/*14/*
include/linux/msdos_partition.h+50−0
@@ -0,0 +1,50 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_MSDOS_PARTITION_H
3#define _LINUX_MSDOS_PARTITION_H
4
5#define MSDOS_LABEL_MAGIC 0xAA55
6
7struct msdos_partition {
8 u8 boot_ind; /* 0x80 - active */
9 u8 head; /* starting head */
10 u8 sector; /* starting sector */
11 u8 cyl; /* starting cylinder */
12 u8 sys_ind; /* What partition type */
13 u8 end_head; /* end head */
14 u8 end_sector; /* end sector */
15 u8 end_cyl; /* end cylinder */
16 __le32 start_sect; /* starting sector counting from 0 */
17 __le32 nr_sects; /* nr of sectors in partition */
18} __packed;
19
20enum msdos_sys_ind {
21 /*
22 * These three have identical behaviour; use the second one if DOS FDISK
23 * gets confused about extended/logical partitions starting past
24 * cylinder 1023.
25 */
26 DOS_EXTENDED_PARTITION = 5,
27 LINUX_EXTENDED_PARTITION = 0x85,
28 WIN98_EXTENDED_PARTITION = 0x0f,
29
30 LINUX_DATA_PARTITION = 0x83,
31 LINUX_LVM_PARTITION = 0x8e,
32 LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */
33
34 SOLARIS_X86_PARTITION = 0x82, /* also Linux swap partitions */
35 NEW_SOLARIS_X86_PARTITION = 0xbf,
36
37 DM6_AUX1PARTITION = 0x51, /* no DDO: use xlated geom */
38 DM6_AUX3PARTITION = 0x53, /* no DDO: use xlated geom */
39 DM6_PARTITION = 0x54, /* has DDO: use xlated geom & offset */
40 EZD_PARTITION = 0x55, /* EZ-DRIVE */
41
42 FREEBSD_PARTITION = 0xa5, /* FreeBSD Partition ID */
43 OPENBSD_PARTITION = 0xa6, /* OpenBSD Partition ID */
44 NETBSD_PARTITION = 0xa9, /* NetBSD Partition ID */
45 BSDI_PARTITION = 0xb7, /* BSDI Partition ID */
46 MINIX_PARTITION = 0x81, /* Minix Partition ID */
47 UNIXWARE_PARTITION = 0x63, /* Same as GNU_HURD and SCO Unix */
48};
49
50#endif /* LINUX_MSDOS_PARTITION_H */
include/linux/part_stat.h+115−0
@@ -0,0 +1,115 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_PART_STAT_H
3#define _LINUX_PART_STAT_H
4
5#include <linux/genhd.h>
6
7/*
8 * Macros to operate on percpu disk statistics:
9 *
10 * {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters
11 * and should be called between disk_stat_lock() and
12 * disk_stat_unlock().
13 *
14 * part_stat_read() can be called at any time.
15 *
16 * part_stat_{add|set_all}() and {init|free}_part_stats are for
17 * internal use only.
18 */
19#ifdef CONFIG_SMP
20#define part_stat_lock() ({ rcu_read_lock(); get_cpu(); })
21#define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0)
22
23#define part_stat_get_cpu(part, field, cpu) \
24 (per_cpu_ptr((part)->dkstats, (cpu))->field)
25
26#define part_stat_get(part, field) \
27 part_stat_get_cpu(part, field, smp_processor_id())
28
29#define part_stat_read(part, field) \
30({ \
31 typeof((part)->dkstats->field) res = 0; \
32 unsigned int _cpu; \
33 for_each_possible_cpu(_cpu) \
34 res += per_cpu_ptr((part)->dkstats, _cpu)->field; \
35 res; \
36})
37
38static inline void part_stat_set_all(struct hd_struct *part, int value)
39{
40 int i;
41
42 for_each_possible_cpu(i)
43 memset(per_cpu_ptr(part->dkstats, i), value,
44 sizeof(struct disk_stats));
45}
46
47static inline int init_part_stats(struct hd_struct *part)
48{
49 part->dkstats = alloc_percpu(struct disk_stats);
50 if (!part->dkstats)
51 return 0;
52 return 1;
53}
54
55static inline void free_part_stats(struct hd_struct *part)
56{
57 free_percpu(part->dkstats);
58}
59
60#else /* !CONFIG_SMP */
61#define part_stat_lock() ({ rcu_read_lock(); 0; })
62#define part_stat_unlock() rcu_read_unlock()
63
64#define part_stat_get(part, field) ((part)->dkstats.field)
65#define part_stat_get_cpu(part, field, cpu) part_stat_get(part, field)
66#define part_stat_read(part, field) part_stat_get(part, field)
67
68static inline void part_stat_set_all(struct hd_struct *part, int value)
69{
70 memset(&part->dkstats, value, sizeof(struct disk_stats));
71}
72
73static inline int init_part_stats(struct hd_struct *part)
74{
75 return 1;
76}
77
78static inline void free_part_stats(struct hd_struct *part)
79{
80}
81
82#endif /* CONFIG_SMP */
83
84#define part_stat_read_accum(part, field) \
85 (part_stat_read(part, field[STAT_READ]) + \
86 part_stat_read(part, field[STAT_WRITE]) + \
87 part_stat_read(part, field[STAT_DISCARD]))
88
89#define __part_stat_add(part, field, addnd) \
90 (part_stat_get(part, field) += (addnd))
91
92#define part_stat_add(part, field, addnd) do { \
93 __part_stat_add((part), field, addnd); \
94 if ((part)->partno) \
95 __part_stat_add(&part_to_disk((part))->part0, \
96 field, addnd); \
97} while (0)
98
99#define part_stat_dec(gendiskp, field) \
100 part_stat_add(gendiskp, field, -1)
101#define part_stat_inc(gendiskp, field) \
102 part_stat_add(gendiskp, field, 1)
103#define part_stat_sub(gendiskp, field, subnd) \
104 part_stat_add(gendiskp, field, -subnd)
105
106#define part_stat_local_dec(gendiskp, field) \
107 local_dec(&(part_stat_get(gendiskp, field)))
108#define part_stat_local_inc(gendiskp, field) \
109 local_inc(&(part_stat_get(gendiskp, field)))
110#define part_stat_local_read(gendiskp, field) \
111 local_read(&(part_stat_get(gendiskp, field)))
112#define part_stat_local_read_cpu(gendiskp, field, cpu) \
113 local_read(&(part_stat_get_cpu(gendiskp, field, cpu)))
114
115#endif /* _LINUX_PART_STAT_H */
include/linux/raid/detect.h+3−0
@@ -0,0 +1,3 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2
3void md_autodetect_dev(dev_t dev);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t