loop uevent fix
Hi Peter and Jens,
this is how I'd slightly respin the patch from Petr on top of the set_capacity_revalidate_and_notify I need for 5.11. Let me know what you think.
PATCH 1/2 block: add a return value to set_capacity_revalidate_and_notify
Return if the function ended up sending an uevent or not.
--- block/genhd.c | 5 ++++- include/linux/genhd.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
block/genhd.c +4 -1
@@ -49,7 +49,7 @@ static void disk_release_events(struct gendisk *disk);* Set disk capacity and notify if the size is not currently * zero and will not be set to zero */ -void set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size, +bool set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size,bool update_bdev) {sector_t capacity =get_capacity (disk);
@@ -62,7 +62,10 @@ void set_capacity_revalidate_and_notify(struct gendisk *disk, sector_t size,char *envp[] = {"RESIZE=1" ,NULL };kobject_uevent_env (&disk_to_dev (disk)->kobj,KOBJ_CHANGE , envp); +return true; } + +return false; }EXPORT_SYMBOL_GPL (set_capacity_revalidate_and_notify);
include/linux/genhd.h +1 -1
@@ -315,7 +315,7 @@ static inline int get_disk_ro(struct gendisk *disk)extern void disk_block_events (struct gendisk *disk);extern void disk_unblock_events (struct gendisk *disk);extern void disk_flush_events (struct gendisk *disk,unsigned int mask); -void set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size, +bool set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size,bool update_bdev);/* drivers/char/random.c */
Signature · 1 line
2.28.0
Re: [PATCH 1/2] block: add a return value to set_capacity_revalidate_and_notify
Hi Christoph,
Quoted 3 lines
Return if the function ended up sending an uevent or not.
Signed-off-by Christoph Hellwig <[email protected]>
Kind regards,
Petr
Quoted 42 lines
--- block/genhd.c | 5 ++++- include/linux/genhd.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)block/genhd.c +4
-1@@ -49,7 +49,7 @@ static void disk_release_events(struct gendisk *disk);* Set disk capacity and notify if the size is not currently * zero and will not be set to zero */ -void set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size, +bool set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size,bool update_bdev) {sector_t capacity =get_capacity (disk);@@ -62,7 +62,10 @@ void set_capacity_revalidate_and_notify(struct gendisk *disk, sector_t size,char *envp[] = {"RESIZE=1" ,NULL };kobject_uevent_env (&disk_to_dev (disk)->kobj,KOBJ_CHANGE , envp); +return true; } + +return false; }EXPORT_SYMBOL_GPL (set_capacity_revalidate_and_notify);include/linux/genhd.h +1
-1@@ -315,7 +315,7 @@ static inline int get_disk_ro(struct gendisk *disk)extern void disk_block_events (struct gendisk *disk);extern void disk_unblock_events (struct gendisk *disk);extern void disk_flush_events (struct gendisk *disk,unsigned int mask); -void set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size, +bool set_capacity_revalidate_and_notify (struct gendisk *disk,sector_t size,bool update_bdev);/* drivers/char/random.c */
PATCH 2/2 loop: Fix occasional uevent drop
In reply to Christoph HellwigFrom: Petr Vorel <[email protected]>
Commit 716ad0986cbd ("loop: Switch to set_capacity_revalidate_and_notify") causes an occasional drop of loop device uevent, which are no longer triggered in loop_set_size() but in a different part of code.
Bug is reproducible with LTP test uevent01 [1]:
i=0; while true; do
i=$((i+1)); echo "== $i =="
lsmod |grep -q loop && rmmod -f loop
./uevent01 || breakdone
Put back triggering through code called in loop_set_size().
Fix required to add yet another parameter toset_capacity_revalidate_and_notify().
[1] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/uevents/uevent01.c
[hch: rebased on a different change to the prototype of
set_capacity_revalidate_and_notify]
--- drivers/block/loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/loop.c +2 -1
@@ -255,7 +255,8 @@ static void loop_set_size(struct loop_device *lo, loff_t size)bd_set_nr_sectors (bdev, size); -set_capacity_revalidate_and_notify (lo->lo_disk, size, false); +if (!set_capacity_revalidate_and_notify (lo->lo_disk, size, false)) +kobject_uevent (&disk_to_dev (bdev->bd_disk)->kobj,KOBJ_CHANGE ); } static inline int
Signature · 1 line
2.28.0
Re: [PATCH 2/2] loop: Fix occasional uevent drop
Hi Christoph,
Quoted 1 line
From: Petr Vorel <[email protected]>
Thanks for rebasing my code. Using loop.c specific code in the file instead of the function is indeed much better.
I also like your cleanup for 5.11 (remove the update_bdev parameter from set_capacity_revalidate_and_notify).
Quoted 10 lines
Commit
716ad0986cbd("loop: Switch toset_capacity_revalidate_and_notify") causes an occasional drop of loop device uevent, which are no longer triggered inloop_set_size()but in a different part of code.Bug is reproducible with LTP test uevent01 [1]:
i=0; while true; do
i=$((i+1)); echo "== $i ==" lsmod |grep -q loop && rmmod -f loop ./uevent01 || break
Quoted 6 lines
done
Put back triggering through code called in
loop_set_size().Fix required to add yet another parameter to
set_capacity_revalidate_and_notify().
This ^ is no longer true and should be removed.
Kind regards,
Petr
Hi Jens, Christoph,
Quoted 5 lines
Hi Peter and Jens,
this is how I'd slightly respin the patch from Petr on top of the
set_capacity_revalidate_and_notifyI need for 5.11. Let me know what you think.
+1, thanks.
From your discussion on my original patch I understand that these 2 fixes will make it to v5.10-rc4. Will they go also to v5.9 stable tree? (it affects also v5.8, but that version is EOL).
Kind regards,
Petr
Jens Axboe
maintainerQuoted 5 lines · Christoph Hellwig
Hi Peter and Jens,
this is how I'd slightly respin the patch from Petr on top of the
set_capacity_revalidate_and_notifyI need for 5.11. Let me know what you think.
LGTM - I've added it for 5.10, marked for 5.9 backport.
Signature · 1 line
Jens Axboe