Thread (10 messages) 10 messages, 4 authors, 2024-02-06

Re: [PATCH 1/2] md: fix WARN_ON if create symlink fail in bind_rdev_to_array()

From: Song Liu <song@kernel.org>
Date: 2023-12-25 01:11:15
Also in: lkml

On Thu, Dec 21, 2023 at 5:17 PM Li Nan [off-list ref] wrote:


在 2023/12/22 2:58, Song Liu 写道:
[...]
quoted
In general, I would like to avoid adding flags if possible.
This flag is mainly used to fix deadlock in next patch. Or should we
export bd_find_holder_disk()? Link hodler if it return NULL.
just like:

   rdev_for_each_rcu
     if (!bd_find_holder_disk)
       bd_link_disk_holder
I was thinking we will not need the flag if we fail bind_rdev_to_array()
on error (below).
quoted
quoted
  };

  static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index e05858653a41..d6612b922c76 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2526,7 +2526,8 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev)
                 sysfs_get_dirent_safe(rdev->kobj.sd, "bad_blocks");

         list_add_rcu(&rdev->same_set, &mddev->disks);
-       bd_link_disk_holder(rdev->bdev, mddev->gendisk);
+       if (!bd_link_disk_holder(rdev->bdev, mddev->gendisk))
+               set_bit(SymlinkCreated, &rdev->flags);
Shall we just fail bind_rdev_to_array() if bd_link_disk_holder()
returns non-zero?
I keep this action because of commit 00bcb4ac7ee7 ("md: reduce
dependence on sysfs."). Fail bind_rdev_to_array is good to me.
I wonder whether the assumption in 00bcb4ac7ee7 is still true. If
bd_link_disk_holder() fails for valid reasons, we need to handle it
properly (set a flag, check the flag on unlink, etc.). If we only fail
bd_link_disk_holder() on extreme cases (ENOMEM, etc.), we can
just fail bind_rdev_to_array().

Thanks,
Song
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help