ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [PATCH 2/2] loop: Fix occasional uevent drop
       [not found] <20201112165005.4022502-1-hch@lst.de>
@ 2020-11-12 16:50 ` Christoph Hellwig
  2020-11-12 19:25   ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2020-11-12 16:50 UTC (permalink / raw)
  To: ltp

From: Petr Vorel <pvorel@suse.cz>

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 || break
done

Put back triggering through code called in loop_set_size().

Fix required to add yet another parameter to
set_capacity_revalidate_and_notify().

[1] https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/uevents/uevent01.c

Fixes: 716ad0986cbd ("loop: Switch to set_capacity_revalidate_and_notify")
Reported-by: <ltp@lists.linux.it>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
[hch: rebased on a different change to the prototype of
 set_capacity_revalidate_and_notify]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/loop.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index cb1191d6e945f2..a58084c2ed7ceb 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -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
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH 2/2] loop: Fix occasional uevent drop
  2020-11-12 16:50 ` [LTP] [PATCH 2/2] loop: Fix occasional uevent drop Christoph Hellwig
@ 2020-11-12 19:25   ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2020-11-12 19:25 UTC (permalink / raw)
  To: ltp

Hi Christoph,

> From: Petr Vorel <pvorel@suse.cz>
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).

> 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 || break
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-12 19:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20201112165005.4022502-1-hch@lst.de>
2020-11-12 16:50 ` [LTP] [PATCH 2/2] loop: Fix occasional uevent drop Christoph Hellwig
2020-11-12 19:25   ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).