Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: create __sb_write_started() helper

Similar to sb_write_started() for use by other sb freeze levels.

Unlike the boolean sb_write_started(), this helper returns a tristate
to distiguish the cases of lockdep disabled or unknown lock state.

This is needed for fanotify "pre content" events.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/r/20231122122715.2561213-15-amir73il@gmail.com
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Amir Goldstein and committed by
Christian Brauner
8802e580 6ae65439

+15 -1
+15 -1
include/linux/fs.h
··· 1645 1645 #define __sb_writers_release(sb, lev) \ 1646 1646 percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_) 1647 1647 1648 + /** 1649 + * __sb_write_started - check if sb freeze level is held 1650 + * @sb: the super we write to 1651 + * @level: the freeze level 1652 + * 1653 + * > 0 sb freeze level is held 1654 + * 0 sb freeze level is not held 1655 + * < 0 !CONFIG_LOCKDEP/LOCK_STATE_UNKNOWN 1656 + */ 1657 + static inline int __sb_write_started(const struct super_block *sb, int level) 1658 + { 1659 + return lockdep_is_held_type(sb->s_writers.rw_sem + level - 1, 1); 1660 + } 1661 + 1648 1662 static inline bool sb_write_started(const struct super_block *sb) 1649 1663 { 1650 - return lockdep_is_held_type(sb->s_writers.rw_sem + SB_FREEZE_WRITE - 1, 1); 1664 + return __sb_write_started(sb, SB_FREEZE_WRITE); 1651 1665 } 1652 1666 1653 1667 /**