linux/block
Matteo Croce cf17994855 block: add disk sequence number
Associating uevents with block devices in userspace is difficult and racy:
the uevent netlink socket is lossy, and on slow and overloaded systems
has a very high latency.
Block devices do not have exclusive owners in userspace, any process can
set one up (e.g. loop devices). Moreover, device names can be reused
(e.g. loop0 can be reused again and again). A userspace process setting
up a block device and watching for its events cannot thus reliably tell
whether an event relates to the device it just set up or another earlier
instance with the same name.

Being able to set a UUID on a loop device would solve the race conditions.
But it does not allow to derive orderings from uevents: if you see a
uevent with a UUID that does not match the device you are waiting for,
you cannot tell whether it's because the right uevent has not arrived yet,
or it was already sent and you missed it. So you cannot tell whether you
should wait for it or not.

Associating a unique, monotonically increasing sequential number to the
lifetime of each block device, which can be retrieved with an ioctl
immediately upon setting it up, allows to solve the race conditions with
uevents, and also allows userspace processes to know whether they should
wait for the uevent they need or if it was dropped and thus they should
move on.

Additionally, increment the disk sequence number when the media change,
i.e. on DISK_EVENT_MEDIA_CHANGE event.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Tested-by: Luca Boccassi <bluca@debian.org>
Link: https://lore.kernel.org/r/20210712230530.29323-2-mcroce@linux.microsoft.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-08-02 13:37:28 -06:00
..
partitions block: remove cmdline-parser.c 2021-08-02 13:37:28 -06:00
badblocks.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
bfq-cgroup.c block, bfq: merge bursts of newly-created queues 2021-03-25 10:50:07 -06:00
bfq-iosched.c blk: Fix lock inversion between ioc lock and bfqd lock 2021-06-24 18:43:55 -06:00
bfq-iosched.h block, bfq: merge bursts of newly-created queues 2021-03-25 10:50:07 -06:00
bfq-wf2q.c block, bfq: always inject I/O of queues blocked by wakers 2021-03-25 10:50:07 -06:00
bio-integrity.c block: use bvec_kmap_local in bio_integrity_process 2021-08-02 13:37:28 -06:00
bio.c block: rewrite bio_copy_data_iter to use bvec_kmap_local and memcpy_to_bvec 2021-08-02 13:37:27 -06:00
blk-cgroup-rwstat.c blk-cgroup: Fix the recursive blkg rwstat 2021-03-05 11:32:15 -07:00
blk-cgroup-rwstat.h
blk-cgroup.c blk-cgroup: prevent rcu_sched detected stalls warnings while iterating blkgs 2021-07-07 09:36:36 -06:00
blk-core.c block: fix the problem of io_ticks becoming smaller 2021-07-07 06:43:20 -06:00
blk-crypto-fallback.c block: rename BIO_MAX_PAGES to BIO_MAX_VECS 2021-03-11 07:47:48 -07:00
blk-crypto-internal.h block: make blk_crypto_rq_bio_prep() able to fail 2020-10-05 10:47:43 -06:00
blk-crypto.c dm: support key eviction from keyslot managers of underlying devices 2021-02-11 09:45:25 -05:00
blk-exec.c block: return errors from blk_execute_rq() 2021-06-30 15:35:45 -06:00
blk-flush.c block: avoid double io accounting for flush request 2021-05-24 06:47:21 -06:00
blk-integrity.c block: remove the unused blk_integrity_merge_bio export 2020-10-06 07:29:53 -06:00
blk-ioc.c block: remove retry loop in ioc_release_fn() 2020-07-16 10:22:15 -06:00
blk-iocost.c blk-iocost: fix operation ordering in iocg_wake_fn() 2021-07-27 19:25:37 -06:00
blk-iolatency.c block: Remove redundant 'return' statement 2020-10-08 07:59:48 -06:00
blk-ioprio.c block: Introduce the ioprio rq-qos policy 2021-06-21 15:03:40 -06:00
blk-ioprio.h block: Introduce the ioprio rq-qos policy 2021-06-21 15:03:40 -06:00
blk-lib.c block: export blk_next_bio() 2021-06-17 15:51:20 +02:00
blk-map.c block: use memcpy_from_bvec in bio_copy_kern_endio_read 2021-08-02 13:37:28 -06:00
blk-merge.c block: fix discard request merge 2021-06-29 07:41:08 -06:00
blk-mq-cpumap.c blk-mq: remove the calling of local_memory_node() 2020-10-20 07:08:17 -06:00
blk-mq-debugfs-zoned.c
blk-mq-debugfs.c block: Introduce the ioprio rq-qos policy 2021-06-21 15:03:40 -06:00
blk-mq-debugfs.h
blk-mq-pci.c
blk-mq-rdma.c
blk-mq-sched.c blk-mq-sched: Fix blk_mq_sched_alloc_tags() error handling 2021-07-27 16:44:38 -06:00
blk-mq-sched.h blk: Fix lock inversion between ioc lock and bfqd lock 2021-06-24 18:43:55 -06:00
blk-mq-sysfs.c blk-mq: move cancel of hctx->run_work to the front of blk_exit_queue 2020-10-09 12:46:28 -06:00
blk-mq-tag.c blk-mq: Use request queue-wide tags for tagset-wide sbitmap 2021-05-24 06:47:22 -06:00
blk-mq-tag.h blk-mq: Some tag allocation code refactoring 2021-05-24 06:47:22 -06:00
blk-mq-virtio.c blk-mq: Fix typo in comment 2020-03-17 20:55:21 +01:00
blk-mq.c block: mark blk_mq_init_queue_data static 2021-06-30 15:34:13 -06:00
blk-mq.h blk: Fix lock inversion between ioc lock and bfqd lock 2021-06-24 18:43:55 -06:00
blk-pm.c scsi: block: Fix a race in the runtime power management code 2020-12-09 11:41:41 -05:00
blk-pm.h block: Remove unused blk_pm_*() function definitions 2021-02-22 06:33:48 -07:00
blk-rq-qos.c rq-qos: fix missed wake-ups in rq_qos_throttle try two 2021-06-08 15:12:57 -06:00
blk-rq-qos.h block: Introduce the ioprio rq-qos policy 2021-06-21 15:03:40 -06:00
blk-settings.c block: simplify printing the device names disk_stack_limits 2021-08-02 13:37:28 -06:00
blk-stat.c blk-stat: make q->stats->lock irqsafe 2020-09-01 16:48:46 -06:00
blk-stat.h
blk-sysfs.c block: mark queue init done at the end of blk_register_queue 2021-06-16 08:41:50 -06:00
blk-throttle.c block: store a block_device pointer in struct bio 2021-01-24 18:17:20 -07:00
blk-timeout.c block: blk-timeout: delete duplicated word 2020-07-31 16:29:47 -06:00
blk-wbt.c blk-wbt: make sure throttle is enabled properly 2021-06-21 15:03:41 -06:00
blk-wbt.h blk-wbt: introduce a new disable state to prevent false positive by rwb_enabled() 2021-06-21 15:03:41 -06:00
blk-zoned.c block: improve handling of all zones reset operation 2021-06-04 12:07:34 -04:00
blk.h block: remove disk_name() 2021-08-02 13:37:28 -06:00
bounce.c block: use memcpy_from_bvec in __blk_queue_bounce 2021-08-02 13:37:28 -06:00
bsg-lib.c block-5.14-2021-07-08 2021-07-09 12:05:33 -07:00
bsg.c block-5.14-2021-07-08 2021-07-09 12:05:33 -07:00
disk-events.c block: add disk sequence number 2021-08-02 13:37:28 -06:00
elevator.c blk: Fix lock inversion between ioc lock and bfqd lock 2021-06-24 18:43:55 -06:00
genhd.c block: add disk sequence number 2021-08-02 13:37:28 -06:00
ioctl.c block: move bd_part_count to struct gendisk 2021-06-01 07:45:27 -06:00
ioprio.c block: Fix sys_ioprio_set(.which=IOPRIO_WHO_PGRP) task iteration 2021-04-08 13:43:53 -06:00
Kconfig block: remove cmdline-parser.c 2021-08-02 13:37:28 -06:00
Kconfig.iosched block/mq-deadline: Add cgroup support 2021-06-21 15:03:41 -06:00
keyslot-manager.c - Fix DM integrity's HMAC support to provide enhanced security of 2021-02-22 10:22:54 -08:00
kyber-iosched.c kyber: fix out of bounds access when preempted 2021-05-11 08:12:14 -06:00
Makefile block: remove cmdline-parser.c 2021-08-02 13:37:28 -06:00
mq-deadline-cgroup.c block/mq-deadline: Add cgroup support 2021-06-21 15:03:41 -06:00
mq-deadline-cgroup.h block/mq-deadline: Add cgroup support 2021-06-21 15:03:41 -06:00
mq-deadline-main.c block/mq-deadline: Remove a WARN_ON_ONCE() call 2021-06-27 16:25:10 -06:00
opal_proto.h block: sed-opal: Change the check condition for regular session validity 2020-03-12 08:00:10 -06:00
scsi_ioctl.c block-5.14-2021-07-08 2021-07-09 12:05:33 -07:00
sed-opal.c block: sed-opal: Change the check condition for regular session validity 2020-03-12 08:00:10 -06:00
t10-pi.c block: use bvec_kmap_local in t10_pi_type1_{prepare,complete} 2021-08-02 13:37:28 -06:00