Message ID | 5a8a19efe9f19b3e11026f57835614731aeeb62d.1648448228.git.naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | protect relocation with sb_start_write | expand |
On Mon, Mar 28, 2022 at 03:29:21PM +0900, Naohiro Aota wrote: > Add a function sb_write_started() to return if sb_start_write() is > properly called. It is used in the next commit. > > Reviewed-by: Filipe Manana <fdmanana@suse.com> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> > --- > include/linux/fs.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 27746a3da8fd..57fedc4af4a1 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1732,6 +1732,11 @@ static inline bool __sb_start_write_trylock(struct super_block *sb, int level) > #define __sb_writers_release(sb, lev) \ > percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_) > > +static inline bool sb_write_started(struct super_block *sb) The argument can be made const. Also, the subject "fs: add check functions for sb_start_{write,pagefault,intwrite}" is now oudated, since only sb_write_started() is added. Thanks. > +{ > + return lockdep_is_held_type(sb->s_writers.rw_sem + SB_FREEZE_WRITE - 1, 1); > +} > + > /** > * sb_end_write - drop write access to a superblock > * @sb: the super we wrote to > -- > 2.35.1 >
diff --git a/include/linux/fs.h b/include/linux/fs.h index 27746a3da8fd..57fedc4af4a1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1732,6 +1732,11 @@ static inline bool __sb_start_write_trylock(struct super_block *sb, int level) #define __sb_writers_release(sb, lev) \ percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_) +static inline bool sb_write_started(struct super_block *sb) +{ + return lockdep_is_held_type(sb->s_writers.rw_sem + SB_FREEZE_WRITE - 1, 1); +} + /** * sb_end_write - drop write access to a superblock * @sb: the super we wrote to