Re: [PATCH 2/2] block: clear the holder releated fields on late disk_add failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Christoph!

在 2022/10/18 15:38, Christoph Hellwig 写道:
Zero out the pointers to the holder related kobjects so that
bd_unlink_disk_holder does the right thing when dm cleans up the delayed
holders after add_disk fails.


I'm planning to do the similar thing in the normal path:

1) in del_gendisk: (add a new api kobject_put_and_test)

if (kobject_put_and_test(bd_holder_dir/slave_dir))
	bd_holder_dir/slave_dir = NULL;

2) in bd_link_disk_holder, get bd_holder_dir first:

if (!kobject_get_unless_zero(bd_holder_dir))
	return -ENODEV;
...
bd_find_holder_disk()

Do you think this is ok?

Thanks,
Kuai

Fixes: 89f871af1b26 ("dm: delay registering the gendisk")
Reported-by: Yu Kuai <yukuai1@xxxxxxxxxxxxxxx>
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
  block/genhd.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/block/genhd.c b/block/genhd.c
index 6123005154b2a..734c2e74f42e3 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -530,8 +530,10 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
  	bd_unregister_all_holders(disk);
  out_put_slave_dir:
  	kobject_put(disk->slave_dir);
+	disk->slave_dir = NULL;
  out_put_holder_dir:
  	kobject_put(disk->part0->bd_holder_dir);
+	disk->part0->bd_holder_dir = NULL;
  out_del_integrity:
  	blk_integrity_del(disk);
  out_del_block_link:





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux