fs: introduce super write guard
Subsystems (4)
Christian Brauner
maintainercover fs: introduce super write guard
Hey,
I'm in the process of adding a few more guards for vfs constructs. I've chosen the easy case of super_start_write() and super_end_write() and converted eligible callers. I think long-term we can move a lot of the manual placement to completely rely on guards - where sensible.
Christian
---
Christian Brauner (8):
fs: add super_write_guard
btrfs: use super write guard in btrfs_reclaim_bgs_work()
btrfs: use super write guard btrfs_run_defrag_inode()
btrfs: use super write guard in sb_start_write()
ext4: use super write guard in write_mmp_block()
btrfs: use super write guard in relocating_repair_kthread()
open: use super write guard in do_ftruncate()
xfs: use super write guard in xfs_file_ioctl()
fs/btrfs/block-group.c | 3 +-- fs/btrfs/defrag.c | 7 +++---- fs/btrfs/volumes.c | 7 ++++--- fs/ext4/mmp.c | 8 ++------ fs/open.c | 9 +++------ fs/xfs/xfs_ioctl.c | 6 ++---- include/linux/fs.h | 5 +++++ 7 files changed, 20 insertions(+), 25 deletions(-)
---
base-commit: dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa
change-id: 20251104-work-guards-fe3d7a09e258
Christian Brauner
maintainerRFC PATCH 1/8 fs: add super_write_guard
--- include/linux/fs.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/fs.h +5 -0
@@ -2052,6 +2052,11 @@ static inline void sb_start_write(struct super_block *sb)__sb_start_write (sb,SB_FREEZE_WRITE ); } +DEFINE_GUARD (super_write, + struct super_block *, +sb_start_write (_T), + sb_end_write(_T)) +static inline bool sb_start_write_trylock (struct super_block *sb) {return __sb_start_write_trylock (sb,SB_FREEZE_WRITE );
Signature · 1 line
2.47.3
Re: [PATCH RFC 1/8] fs: add super_write_guard
Quoted 1 line · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>
Yeah, I think this can be a win. Feel free to add:
Honza
Quoted 24 lines
--- include/linux/fs.h | 5 +++++ 1 file changed, 5 insertions(+)include/linux/fs.h +5
-0@@ -2052,6 +2052,11 @@ static inline void sb_start_write(struct super_block *sb)__sb_start_write (sb,SB_FREEZE_WRITE ); } +DEFINE_GUARD (super_write, + struct super_block *, +sb_start_write (_T), + sb_end_write(_T)) +static inline bool sb_start_write_trylock (struct super_block *sb) {return __sb_start_write_trylock (sb,SB_FREEZE_WRITE );Signature · 2 lines
-- 2.47.3
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Christian Brauner
maintainerRFC PATCH 2/8 btrfs: use super write guard in btrfs_reclaim_bgs_work()
In reply to Christian Brauner--- fs/btrfs/block-group.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/block-group.c +1 -2
@@ -1850,7 +1850,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)if (!btrfs_should_reclaim (fs_info))return ; -sb_start_write (fs_info->sb); +guard (super_write)(fs_info->sb);if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) {sb_end_write (fs_info->sb);
@@ -2030,7 +2030,6 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)list_splice_tail (&retry_list, &fs_info->reclaim_bgs);spin_unlock (&fs_info->unused_bgs_lock);btrfs_exclop_finish (fs_info); -sb_end_write (fs_info->sb); }void btrfs_reclaim_bgs (struct btrfs_fs_info *fs_info)
Signature · 1 line
2.47.3
Re: [PATCH RFC 2/8] btrfs: use super write guard in btrfs_reclaim_bgs_work()
Quoted 10 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/btrfs/block-group.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/block-group.c +0
-0
fs/btrfs/block-group.c void btrfs_reclaim_bgs_work(struct work_struct *work) · line 1856
Quoted 8 lines
fs/btrfs/block-group.c +1
-1@@ -1850,7 +1850,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)if (!btrfs_should_reclaim (fs_info))return ; -sb_start_write (fs_info->sb); +guard (super_write)(fs_info->sb);if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) {sb_end_write (fs_info->sb);
This one is still left using the old scheme, and there is another one in the mutex_trylock() branch.
I'm wondering how safe is the new scope based auto freeing.
Like when the freeing function is called? Will it break the existing freeing/locking sequence in other locations?
For this call site, sb_end_write() is always called last so it's fine.
Thanks,
Qu
Quoted 9 lines
fs/btrfs/block-group.c +0
-1@@ -2030,7 +2030,6 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)list_splice_tail (&retry_list, &fs_info->reclaim_bgs);spin_unlock (&fs_info->unused_bgs_lock);btrfs_exclop_finish (fs_info); -sb_end_write (fs_info->sb); }void btrfs_reclaim_bgs (struct btrfs_fs_info *fs_info)
Re: [PATCH RFC 2/8] btrfs: use super write guard in btrfs_reclaim_bgs_work()
Quoted 23 lines · Qu Wenruo
Quoted 10 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/btrfs/block-group.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/btrfs/block-group.c +0
-0fs/btrfs/block-group.c void btrfs_reclaim_bgs_work(struct work_struct *work) · line 1856
Quoted 8 lines
fs/btrfs/block-group.c +1
-1@@ -1850,7 +1850,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)if (!btrfs_should_reclaim (fs_info))return ; -sb_start_write (fs_info->sb); +guard (super_write)(fs_info->sb);if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) {sb_end_write (fs_info->sb);This one is still left using the old scheme, and there is another one in the
mutex_trylock()branch.
Quoted 6 lines
I'm wondering how safe is the new scope based auto freeing.
Like when the freeing function is called? Will it break the existing freeing/locking sequence in other locations?
For this call site,
sb_end_write()is always called last so it's fine.
It needs to be used sensibly. In this case it matches the original semantics. Well, up to the part where a guard just consumes additional stack/register storing the sb pointer. That is the price which needs to be accounted for.
--nX
Quoted 14 lines
Thanks,
QuQuoted 9 lines
fs/btrfs/block-group.c +0
-1@@ -2030,7 +2030,6 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)list_splice_tail (&retry_list, &fs_info->reclaim_bgs);spin_unlock (&fs_info->unused_bgs_lock);btrfs_exclop_finish (fs_info); -sb_end_write (fs_info->sb); }void btrfs_reclaim_bgs (struct btrfs_fs_info *fs_info)
Christian Brauner
maintainerRFC PATCH 3/8 btrfs: use super write guard btrfs_run_defrag_inode()
In reply to Christian Brauner--- fs/btrfs/defrag.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/btrfs/defrag.c +3 -4
@@ -254,10 +254,9 @@ static int btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, range.extent_thresh = defrag->extent_thresh;file_ra_state_init (ra, inode->vfs_inode.i_mapping); -sb_start_write (fs_info->sb); - ret =btrfs_defrag_file (inode, ra, &range, defrag->transid, -BTRFS_DEFRAG_BATCH ); -sb_end_write (fs_info->sb); +scoped_guard (super_write, fs_info->sb) + ret = btrfs_defrag_file(inode, ra, &range, + defrag->transid,BTRFS_DEFRAG_BATCH );iput (&inode->vfs_inode);if (ret <0 )
Signature · 1 line
2.47.3
Re: [PATCH RFC 3/8] btrfs: use super write guard btrfs_run_defrag_inode()
Quoted 11 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/btrfs/defrag.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)fs/btrfs/defrag.c +0
-0
fs/btrfs/defrag.c static int btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, · line 259
Quoted 10 lines
fs/btrfs/defrag.c +3
-4@@ -254,10 +254,9 @@ static int btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, range.extent_thresh = defrag->extent_thresh;file_ra_state_init (ra, inode->vfs_inode.i_mapping); -sb_start_write (fs_info->sb); - ret =btrfs_defrag_file (inode, ra, &range, defrag->transid, -BTRFS_DEFRAG_BATCH ); -sb_end_write (fs_info->sb); +scoped_guard (super_write, fs_info->sb) + ret = btrfs_defrag_file(inode, ra, &range, + defrag->transid,BTRFS_DEFRAG_BATCH );
We accept lines with up to ~100 characters in btrfs code.
--nX
Quoted 8 lines
fs/btrfs/defrag.c +0
-1iput (&inode->vfs_inode);if (ret <0 ) --2.47.3
Re: [PATCH RFC 3/8] btrfs: use super write guard btrfs_run_defrag_inode()
In reply to Christian BraunerQuoted 10 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/btrfs/defrag.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)fs/btrfs/defrag.c +0
-0
fs/btrfs/defrag.c static int btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, · line 259
Quoted 10 lines
fs/btrfs/defrag.c +3
-4@@ -254,10 +254,9 @@ static int btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info, range.extent_thresh = defrag->extent_thresh;file_ra_state_init (ra, inode->vfs_inode.i_mapping); -sb_start_write (fs_info->sb); - ret =btrfs_defrag_file (inode, ra, &range, defrag->transid, -BTRFS_DEFRAG_BATCH ); -sb_end_write (fs_info->sb); +scoped_guard (super_write, fs_info->sb) + ret = btrfs_defrag_file(inode, ra, &range, + defrag->transid,BTRFS_DEFRAG_BATCH );
Please use explicit { } around scoped_guard() in btrfs code. It makes the scope more obvious.
Christian Brauner
maintainerRFC PATCH 4/8 btrfs: use super write guard in sb_start_write()
In reply to Christian Brauner--- fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/volumes.c +2 -1
@@ -4660,7 +4660,8 @@ static int balance_kthread(void *data)struct btrfs_fs_info *fs_info = data;int ret =0 ; -sb_start_write (fs_info->sb); +guard (super_write)(fs_info->sb); +mutex_lock (&fs_info->balance_mutex);if (fs_info->balance_ctl) ret =btrfs_balance (fs_info, fs_info->balance_ctl,NULL );
Signature · 1 line
2.47.3
Re: [PATCH RFC 4/8] btrfs: use super write guard in sb_start_write()
Quoted 11 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/btrfs/volumes.c +0
-0
fs/btrfs/volumes.c static int balance_kthread(void *data) · line 4667
Quoted 9 lines
fs/btrfs/volumes.c +2
-1@@ -4660,7 +4660,8 @@ static int balance_kthread(void *data)struct btrfs_fs_info *fs_info = data;int ret =0 ; -sb_start_write (fs_info->sb); +guard (super_write)(fs_info->sb); +mutex_lock (&fs_info->balance_mutex);if (fs_info->balance_ctl) ret =btrfs_balance (fs_info, fs_info->balance_ctl,NULL );
this missed sb_end_write call removal
Christian Brauner
maintainerRe: [PATCH RFC 4/8] btrfs: use super write guard in sb_start_write()
Quoted 14 lines · Mateusz Guzik
Quoted 13 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/btrfs/volumes.c +0
-0@@ -4660,7 +4660,8 @@ static int balance_kthread(void *data)struct btrfs_fs_info *fs_info = data;int ret =0 ;
Quoted 9 lines
fs/btrfs/volumes.c static int balance_kthread(void *data) · line 4667
Quoted 7 lines
fs/btrfs/volumes.c +2
-1-sb_start_write (fs_info->sb); +guard (super_write)(fs_info->sb); +mutex_lock (&fs_info->balance_mutex);if (fs_info->balance_ctl) ret =btrfs_balance (fs_info, fs_info->balance_ctl,NULL );this missed
sb_end_writecall removal
Thanks, fixed!
Christian Brauner
maintainerRFC PATCH 5/8 ext4: use super write guard in write_mmp_block()
In reply to Christian Brauner--- fs/ext4/mmp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
fs/ext4/mmp.c +2 -6
@@ -57,16 +57,12 @@ static int write_mmp_block_thawed(struct super_block *sb,static int write_mmp_block (struct super_block *sb,struct buffer_head *bh) { -int err; -/* * We protect against freezing so that we don't create dirty buffers * on frozen filesystem. */ -sb_start_write (sb); - err =write_mmp_block_thawed (sb, bh); -sb_end_write (sb); -return err; + scoped_guard(super_write, sb) +return write_mmp_block_thawed (sb, bh); }/*
Signature · 1 line
2.47.3
Re: [PATCH RFC 5/8] ext4: use super write guard in write_mmp_block()
Quoted 1 line · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 31 lines
--- fs/ext4/mmp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)fs/ext4/mmp.c +2
-6@@ -57,16 +57,12 @@ static int write_mmp_block_thawed(struct super_block *sb,static int write_mmp_block (struct super_block *sb,struct buffer_head *bh) { -int err; -/* * We protect against freezing so that we don't create dirty buffers * on frozen filesystem. */ -sb_start_write (sb); - err =write_mmp_block_thawed (sb, bh); -sb_end_write (sb); -return err; + scoped_guard(super_write, sb) +return write_mmp_block_thawed (sb, bh); }/* Signature · 2 lines
-- 2.47.3
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH RFC 5/8] ext4: use super write guard in write_mmp_block()
In reply to Christian BraunerQuoted 4 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/ext4/mmp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
Re: [PATCH RFC 5/8] ext4: use super write guard in write_mmp_block()
In reply to Christian BraunerQuoted 16 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/ext4/mmp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)fs/ext4/mmp.c +0
-2@@ -57,16 +57,12 @@ static int write_mmp_block_thawed(struct super_block *sb,static int write_mmp_block (struct super_block *sb,struct buffer_head *bh) { -int err; -
fs/ext4/mmp.c static int write_mmp_block_thawed(struct super_block *sb, · line 65
Quoted 10 lines
fs/ext4/mmp.c +2
-4/* * We protect against freezing so that we don't create dirty buffers * on frozen filesystem. */ -sb_start_write (sb); - err =write_mmp_block_thawed (sb, bh); -sb_end_write (sb); -return err; + scoped_guard(super_write, sb) +return write_mmp_block_thawed (sb, bh);
Why the scoped_guard here? Should the simple guard(super_write)(sb) be just as fine here?
--nX
Quoted 8 lines
fs/ext4/mmp.c +0
-1}/* -- 2.47.3
Jan Kara
reviewerRe: [PATCH RFC 5/8] ext4: use super write guard in write_mmp_block()
Quoted 22 lines · Daniel Vacek
Quoted 21 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/ext4/mmp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)fs/ext4/mmp.c +0
-3@@ -57,16 +57,12 @@ static int write_mmp_block_thawed(struct super_block *sb,static int write_mmp_block (struct super_block *sb,struct buffer_head *bh) { -int err; -/* * We protect against freezing so that we don't create dirty buffers * on frozen filesystem. */ -sb_start_write (sb);
Quoted 8 lines
fs/ext4/mmp.c static int write_mmp_block_thawed(struct super_block *sb, · line 65
Quoted 5 lines
fs/ext4/mmp.c +2
-3- err =write_mmp_block_thawed (sb, bh); -sb_end_write (sb); -return err; + scoped_guard(super_write, sb) +return write_mmp_block_thawed (sb, bh);Why the
scoped_guardhere? Should the simple guard(super_write)(sb) be just as fine here?
Not sure about Ted but I prefer scoped_guard() to plain guard() because the scoping makes it more visually obvious where the unlocking happens. Of course there has to be a balance as the indentation level can go through the roof but that's not the case here...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH RFC 5/8] ext4: use super write guard in write_mmp_block()
Quoted 33 lines · Jan Kara
Quoted 22 lines · Daniel Vacek
Quoted 21 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/ext4/mmp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)fs/ext4/mmp.c +0
-3@@ -57,16 +57,12 @@ static int write_mmp_block_thawed(struct super_block *sb,static int write_mmp_block (struct super_block *sb,struct buffer_head *bh) { -int err; -/* * We protect against freezing so that we don't create dirty buffers * on frozen filesystem. */ -sb_start_write (sb);Quoted 8 lines
fs/ext4/mmp.c static int write_mmp_block_thawed(struct super_block *sb, · line 65
Quoted 5 lines
fs/ext4/mmp.c +2
-3- err =write_mmp_block_thawed (sb, bh); -sb_end_write (sb); -return err; + scoped_guard(super_write, sb) +return write_mmp_block_thawed (sb, bh);Why the
scoped_guardhere? Should the simple guard(super_write)(sb) be just as fine here?
Quoted 4 lines
Not sure about Ted but I prefer
scoped_guard()to plainguard()because the scoping makes it more visually obvious where the unlocking happens. Of course there has to be a balance as the indentation level can go through the roof but that's not the case here...
In a general case I completely agree. Though here you can see the end of the block right on the next line so it looks quite obvious to me how far the guarded region spans.
But the question is whether to use the guards at all. To me it's a huge change in reading and understanding the code as more things are implied and not explicit. Such implied things result in additional cognitive load. I guess we can handle it eventually. Yet we can fail from time to time and it is likely we will, at least in the beginning.
Well, my point is this is a new style we're not used to, yet. It just takes time to adapt. (And usually a few failures to do so.)
--nX
Quoted 4 lines
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
Christian Brauner
maintainerRFC PATCH 6/8 btrfs: use super write guard in relocating_repair_kthread()
In reply to Christian Brauner--- fs/btrfs/volumes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/volumes.c +2 -2
@@ -8178,7 +8178,8 @@ static int relocating_repair_kthread(void *data) target = cache->start;btrfs_put_block_group (cache); -sb_start_write (fs_info->sb); +guard (super_write)(fs_info->sb); +if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) { btrfs_info(fs_info, "zoned: skip relocating block group %llu to repair: EBUSY",
@@ -8211,7 +8212,6 @@ static int relocating_repair_kthread(void *data)btrfs_put_block_group (cache);mutex_unlock (&fs_info->reclaim_bgs_lock);btrfs_exclop_finish (fs_info); -sb_end_write (fs_info->sb);return ret; }
Signature · 1 line
2.47.3
Christian Brauner
maintainerRFC PATCH 7/8 open: use super write guard in do_ftruncate()
In reply to Christian Brauner--- fs/open.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
fs/open.c +3 -6
@@ -191,12 +191,9 @@ int do_ftruncate(struct file *file, loff_t length, int small)if (error)return error; -sb_start_write (inode->i_sb); - error =do_truncate (file_mnt_idmap (file), dentry, length, -ATTR_MTIME |ATTR_CTIME , file); -sb_end_write (inode->i_sb); - -return error; + scoped_guard(super_write, inode->i_sb) +return do_truncate (file_mnt_idmap (file), dentry, length, +ATTR_MTIME |ATTR_CTIME , file); }int do_sys_ftruncate (unsigned int fd,loff_t length,int small)
Signature · 1 line
2.47.3
Re: [PATCH RFC 7/8] open: use super write guard in do_ftruncate()
Quoted 1 line · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 28 lines
--- fs/open.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)fs/open.c +3
-6@@ -191,12 +191,9 @@ int do_ftruncate(struct file *file, loff_t length, int small)if (error)return error; -sb_start_write (inode->i_sb); - error =do_truncate (file_mnt_idmap (file), dentry, length, -ATTR_MTIME |ATTR_CTIME , file); -sb_end_write (inode->i_sb); - -return error; + scoped_guard(super_write, inode->i_sb) +return do_truncate (file_mnt_idmap (file), dentry, length, +ATTR_MTIME |ATTR_CTIME , file); }int do_sys_ftruncate (unsigned int fd,loff_t length,int small)Signature · 2 lines
-- 2.47.3
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH RFC 7/8] open: use super write guard in do_ftruncate()
In reply to Christian BraunerQuoted 13 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/open.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)fs/open.c +0
-0@@ -191,12 +191,9 @@ int do_ftruncate(struct file *file, loff_t length, int small)if (error)return error;
fs/open.c int do_ftruncate(struct file *file, loff_t length, int small) · line 196
Quoted 10 lines
fs/open.c +3
-6-sb_start_write (inode->i_sb); - error =do_truncate (file_mnt_idmap (file), dentry, length, -ATTR_MTIME |ATTR_CTIME , file); -sb_end_write (inode->i_sb); - -return error; + scoped_guard(super_write, inode->i_sb) +return do_truncate (file_mnt_idmap (file), dentry, length, +ATTR_MTIME |ATTR_CTIME , file);
Again, why scoped_guard? It does not make sense, or do I miss something?
--nX
Quoted 8 lines
fs/open.c +0
-1}int do_sys_ftruncate (unsigned int fd,loff_t length,int small) --2.47.3
Christian Brauner
maintainerRFC PATCH 8/8 xfs: use super write guard in xfs_file_ioctl()
In reply to Christian Brauner--- fs/xfs/xfs_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/xfs/xfs_ioctl.c +2 -4
@@ -1408,10 +1408,8 @@ xfs_file_ioctl(trace_xfs_ioc_free_eofblocks (mp, &icw, _RET_IP_); -sb_start_write (mp->m_super); - error =xfs_blockgc_free_space (mp, &icw); -sb_end_write (mp->m_super); -return error; + scoped_guard(super_write, mp->m_super) +return xfs_blockgc_free_space (mp, &icw); }case XFS_IOC_EXCHANGE_RANGE :
Signature · 1 line
2.47.3
Re: [PATCH RFC 8/8] xfs: use super write guard in xfs_file_ioctl()
Quoted 10 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/xfs/xfs_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/xfs/xfs_ioctl.c +0
-0
fs/xfs/xfs_ioctl.c xfs_file_ioctl( · line 1412
Quoted 9 lines
fs/xfs/xfs_ioctl.c +2
-4@@ -1408,10 +1408,8 @@ xfs_file_ioctl(trace_xfs_ioc_free_eofblocks (mp, &icw, _RET_IP_); -sb_start_write (mp->m_super); - error =xfs_blockgc_free_space (mp, &icw); -sb_end_write (mp->m_super); -return error; + scoped_guard(super_write, mp->m_super) +return xfs_blockgc_free_space (mp, &icw);
Can we go full on Java?
#define with_sb_write(sb) scoped_guard(super_write, (sb))
with_sb_write(mp->m_super) return xfs_blockgc_free_space(mp, &icw);
I still keep seeing scoped_guard() as a function call, not the sort of thing that starts a new block.
[If I missed the bikeshedding war over this, I'll let this go]
--D
Quoted 8 lines
fs/xfs/xfs_ioctl.c +0
-0}case XFS_IOC_EXCHANGE_RANGE :Signature · 2 lines
-- 2.47.3
Christian Brauner
maintainerRe: [PATCH RFC 8/8] xfs: use super write guard in xfs_file_ioctl()
Quoted 25 lines · Darrick J. Wong
Quoted 10 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/xfs/xfs_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/xfs/xfs_ioctl.c +0
-0fs/xfs/xfs_ioctl.c xfs_file_ioctl( · line 1412
Quoted 9 lines
fs/xfs/xfs_ioctl.c +2
-4@@ -1408,10 +1408,8 @@ xfs_file_ioctl(trace_xfs_ioc_free_eofblocks (mp, &icw, _RET_IP_); -sb_start_write (mp->m_super); - error =xfs_blockgc_free_space (mp, &icw); -sb_end_write (mp->m_super); -return error; + scoped_guard(super_write, mp->m_super) +return xfs_blockgc_free_space (mp, &icw);Can we go full on Java?
#define
with_sb_write(sb)scoped_guard(super_write, (sb))
Quoted 7 lines
with_sb_write(mp->m_super) return xfs_blockgc_free_space(mp, &icw);I still keep seeing
scoped_guard()as a function call, not the sort of thing that starts a new block.[If I missed the bikeshedding war over this, I'll let this go]
It's an option and what I did for the creds stuff. The thing is thought that scoped_guard() is more widespread by now and thus probably easier to grasp for readers that are familiar with it. I'm not married to it.
Re: [PATCH RFC 8/8] xfs: use super write guard in xfs_file_ioctl()
Quoted 29 lines · Christian Brauner
Quoted 28 lines · Darrick J. Wong
Quoted 10 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/xfs/xfs_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/xfs/xfs_ioctl.c +0
-0fs/xfs/xfs_ioctl.c xfs_file_ioctl( · line 1412
Quoted 9 lines
fs/xfs/xfs_ioctl.c +2
-4@@ -1408,10 +1408,8 @@ xfs_file_ioctl(trace_xfs_ioc_free_eofblocks (mp, &icw, _RET_IP_); -sb_start_write (mp->m_super); - error =xfs_blockgc_free_space (mp, &icw); -sb_end_write (mp->m_super); -return error; + scoped_guard(super_write, mp->m_super) +return xfs_blockgc_free_space (mp, &icw);Can we go full on Java?
#define
with_sb_write(sb)scoped_guard(super_write, (sb))with_sb_write(mp->m_super) return xfs_blockgc_free_space(mp, &icw);
Quoted 8 lines
Quoted 4 lines
I still keep seeing
scoped_guard()as a function call, not the sort of thing that starts a new block.[If I missed the bikeshedding war over this, I'll let this go]
It's an option and what I did for the creds stuff. The thing is thought that
scoped_guard()is more widespread by now and thus probably easier to grasp for readers that are familiar with it. I'm not married to it.
The wait_ macro would maintain sb_.*_write greppability, though I don't know how important that might be.
--D
Re: [PATCH RFC 8/8] xfs: use super write guard in xfs_file_ioctl()
In reply to Christian BraunerQuoted 11 lines · Christian Brauner
Signed-off-by Christian Brauner <[email protected]>--- fs/xfs/xfs_ioctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/xfs/xfs_ioctl.c +0
-0
fs/xfs/xfs_ioctl.c xfs_file_ioctl( · line 1412
Quoted 9 lines
fs/xfs/xfs_ioctl.c +2
-4@@ -1408,10 +1408,8 @@ xfs_file_ioctl(trace_xfs_ioc_free_eofblocks (mp, &icw, _RET_IP_); -sb_start_write (mp->m_super); - error =xfs_blockgc_free_space (mp, &icw); -sb_end_write (mp->m_super); -return error; + scoped_guard(super_write, mp->m_super) +return xfs_blockgc_free_space (mp, &icw);
Again, scope_guard where not needed, right?
--nX
Quoted 8 lines
fs/xfs/xfs_ioctl.c +0
-1}case XFS_IOC_EXCHANGE_RANGE : --2.47.3