Message ID | 20230802154131.2221419-10-hch@lst.de (mailing list archive) |
---|---|
State | Accepted |
Commit | 6f5fc7de98857c75dad05e9f3fe2e6f358d4583e |
Headers | show |
Series | [f2fs-dev,01/12] fs: export setup_bdev_super | expand |
On Wed 02-08-23 17:41:28, Christoph Hellwig wrote: > Just like get_tree_bdev needs to drop s_umount when opening the main > device, we need to do the same for the ext4 log device to avoid a > potential lock order reversal with s_unmount for the mark_dead path. > > It might be preferable to just drop s_umount over ->fill_super entirely, > but that will require a fairly massive audit first, so we'll do the easy > version here first. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Looks good. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/ext4/super.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index 193d665813b611..2ccb19d345c6dd 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -5854,7 +5854,10 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, > if (WARN_ON_ONCE(!ext4_has_feature_journal(sb))) > return NULL; > > + /* see get_tree_bdev why this is needed and safe */ > + up_write(&sb->s_umount); > bdev = ext4_blkdev_get(j_dev, sb); > + down_write(&sb->s_umount); > if (bdev == NULL) > return NULL; > > -- > 2.39.2 >
On Wed, Aug 02, 2023 at 05:41:28PM +0200, Christoph Hellwig wrote: > Just like get_tree_bdev needs to drop s_umount when opening the main > device, we need to do the same for the ext4 log device to avoid a > potential lock order reversal with s_unmount for the mark_dead path. > > It might be preferable to just drop s_umount over ->fill_super entirely, > but that will require a fairly massive audit first, so we'll do the easy > version here first. > > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- Looks good to me, Reviewed-by: Christian Brauner <brauner@kernel.org>
On Wed, Aug 02, 2023 at 05:41:28PM +0200, Christoph Hellwig wrote: > Just like get_tree_bdev needs to drop s_umount when opening the main > device, we need to do the same for the ext4 log device to avoid a > potential lock order reversal with s_unmount for the mark_dead path. > > It might be preferable to just drop s_umount over ->fill_super entirely, > but that will require a fairly massive audit first, so we'll do the easy > version here first. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 193d665813b611..2ccb19d345c6dd 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5854,7 +5854,10 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb, if (WARN_ON_ONCE(!ext4_has_feature_journal(sb))) return NULL; + /* see get_tree_bdev why this is needed and safe */ + up_write(&sb->s_umount); bdev = ext4_blkdev_get(j_dev, sb); + down_write(&sb->s_umount); if (bdev == NULL) return NULL;
Just like get_tree_bdev needs to drop s_umount when opening the main device, we need to do the same for the ext4 log device to avoid a potential lock order reversal with s_unmount for the mark_dead path. It might be preferable to just drop s_umount over ->fill_super entirely, but that will require a fairly massive audit first, so we'll do the easy version here first. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/ext4/super.c | 3 +++ 1 file changed, 3 insertions(+)