diff mbox series

[v4,2/3] fs: add a check function for sb_start_write()

Message ID ccccf0efac8d017dd4edbe34259296b83f6371dd.1648535838.git.naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series protect relocation with sb_start_write | expand

Commit Message

Naohiro Aota March 29, 2022, 6:55 a.m. UTC
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 mbox series

Patch

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 27746a3da8fd..1f3df6e8a74d 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(const 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