@@ -75,7 +75,7 @@ static int ext4_journal_check_start(struct super_block *sb)
if (WARN_ON_ONCE(sb_rdonly(sb)))
return -EROFS;
- WARN_ON(sb->s_writers.frozen == SB_FREEZE_COMPLETE);
+ WARN_ON(sb_is_frozen(sb));
journal = EXT4_SB(sb)->s_journal;
/*
* Special case here: if the journal has aborted behind our
@@ -156,7 +156,7 @@ static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf)
static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
{
struct super_block *sb = sdp->sd_vfs;
- int frozen = (sb->s_writers.frozen == SB_UNFROZEN) ? 0 : 1;
+ int frozen = sb_is_unfrozen(sb) ? 0 : 1;
return snprintf(buf, PAGE_SIZE, "%d\n", frozen);
}
@@ -890,11 +890,12 @@ static struct super_block *quotactl_block(const char __user *special, int cmd)
sb = user_get_super(dev, excl);
if (!sb)
return ERR_PTR(-ENODEV);
- if (thawed && sb->s_writers.frozen != SB_UNFROZEN) {
+ if (thawed && !sb_is_unfrozen(sb)) {
if (excl)
up_write(&sb->s_umount);
else
up_read(&sb->s_umount);
+
/* Wait for sb to unfreeze */
sb_start_write(sb);
sb_end_write(sb);
@@ -1029,7 +1029,7 @@ int reconfigure_super(struct fs_context *fc)
if (fc->sb_flags_mask & ~MS_RMT_MASK)
return -EINVAL;
- if (sb->s_writers.frozen != SB_UNFROZEN)
+ if (!(sb_is_unfrozen(sb)))
return -EBUSY;
retval = security_sb_remount(sb, fc->security);
@@ -1053,7 +1053,7 @@ int reconfigure_super(struct fs_context *fc)
__super_lock_excl(sb);
if (!sb->s_root)
return 0;
- if (sb->s_writers.frozen != SB_UNFROZEN)
+ if (!sb_is_unfrozen(sb))
return -EBUSY;
remount_ro = !sb_rdonly(sb);
}
@@ -2009,7 +2009,7 @@ int freeze_super(struct super_block *sb, enum freeze_holder who)
atomic_inc(&sb->s_active);
retry:
- if (sb->s_writers.frozen == SB_FREEZE_COMPLETE) {
+ if (sb_is_frozen(sb)) {
if (may_freeze(sb, who))
ret = !!WARN_ON_ONCE(freeze_inc(sb, who) == 1);
else
@@ -2019,7 +2019,7 @@ int freeze_super(struct super_block *sb, enum freeze_holder who)
return ret;
}
- if (sb->s_writers.frozen != SB_UNFROZEN) {
+ if (sb_is_unfrozen(sb)) {
ret = wait_for_partially_frozen(sb);
if (ret) {
deactivate_locked_super(sb);
@@ -269,8 +269,7 @@ xfs_trans_alloc(
* Zero-reservation ("empty") transactions can't modify anything, so
* they're allowed to run while we're frozen.
*/
- WARN_ON(resp->tr_logres > 0 &&
- mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
+ WARN_ON(resp->tr_logres > 0 && sb_is_frozen(mp->m_super));
ASSERT(!(flags & XFS_TRANS_RES_FDBLKS) ||
xfs_has_lazysbcount(mp));
@@ -1971,6 +1971,28 @@ static inline bool sb_start_intwrite_trylock(struct super_block *sb)
return __sb_start_write_trylock(sb, SB_FREEZE_FS);
}
+/**
+ * sb_is_frozen - is superblock frozen
+ * @sb: the super to check
+ *
+ * Returns true if the super is frozen.
+ */
+static inline bool sb_is_frozen(struct super_block *sb)
+{
+ return sb->s_writers.frozen == SB_FREEZE_COMPLETE;
+}
+
+/**
+ * sb_is_unfrozen - is superblock unfrozen
+ * @sb: the super to check
+ *
+ * Returns true if the super is unfrozen.
+ */
+static inline bool sb_is_unfrozen(struct super_block *sb)
+{
+ return sb->s_writers.frozen == SB_UNFROZEN;
+}
+
bool inode_owner_or_capable(struct mnt_idmap *idmap,
const struct inode *inode);