[PATCH 13/13] ext4: Replace EXT4_FLAGS_SHUTDOWN flag with a generic SB_I_SHUTDOWN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of using private ext4 EXT4_FLAGS_SHUTDOWN flag, use a generic
variant SB_I_SHUTDOWN. As a bonus VFS will now refuse modification
attempts for the filesystem when the flag is set.

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
 fs/ext4/ext4.h  |  3 +--
 fs/ext4/ioctl.c |  6 +++---
 fs/ext4/super.c | 11 +++++------
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 08acd152261e..7a3ea125ec86 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2240,12 +2240,11 @@ extern int ext4_feature_set_ok(struct super_block *sb, int readonly);
  * Superblock flags
  */
 #define EXT4_FLAGS_RESIZING	0
-#define EXT4_FLAGS_SHUTDOWN	1
 #define EXT4_FLAGS_BDEV_IS_DAX	2
 
 static inline int ext4_forced_shutdown(struct super_block *sb)
 {
-	return test_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags);
+	return sb_test_iflag(sb, SB_I_SHUTDOWN);
 }
 
 /*
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index e8bf5972dd47..086bc239ff33 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -822,18 +822,18 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags)
 		ret = bdev_freeze(sb->s_bdev);
 		if (ret)
 			return ret;
-		set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags);
+		sb_set_iflag(sb, SB_I_SHUTDOWN);
 		bdev_thaw(sb->s_bdev);
 		break;
 	case EXT4_GOING_FLAGS_LOGFLUSH:
-		set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags);
+		sb_set_iflag(sb, SB_I_SHUTDOWN);
 		if (sbi->s_journal && !is_journal_aborted(sbi->s_journal)) {
 			(void) ext4_force_commit(sb);
 			jbd2_journal_abort(sbi->s_journal, -ESHUTDOWN);
 		}
 		break;
 	case EXT4_GOING_FLAGS_NOLOGFLUSH:
-		set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags);
+		sb_set_iflag(sb, SB_I_SHUTDOWN);
 		if (sbi->s_journal && !is_journal_aborted(sbi->s_journal))
 			jbd2_journal_abort(sbi->s_journal, -ESHUTDOWN);
 		break;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b5b2f17f1b65..928d8eb266f0 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -701,7 +701,7 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
 		WARN_ON_ONCE(1);
 
 	if (!continue_fs && !sb_rdonly(sb)) {
-		set_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags);
+		sb_set_iflag(sb, SB_I_SHUTDOWN);
 		if (journal)
 			jbd2_journal_abort(journal, -EIO);
 	}
@@ -735,11 +735,10 @@ static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
 
 	ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
 	/*
-	 * EXT4_FLAGS_SHUTDOWN was set which stops all filesystem
-	 * modifications. We don't set SB_RDONLY because that requires
-	 * sb->s_umount semaphore and setting it without proper remount
-	 * procedure is confusing code such as freeze_super() leading to
-	 * deadlocks and other problems.
+	 * SB_I_SHUTDOWN was set which stops all filesystem modifications. We
+	 * don't set SB_RDONLY because that requires sb->s_umount semaphore and
+	 * setting it without proper remount procedure is confusing code such
+	 * as freeze_super() leading to deadlocks and other problems.
 	 */
 }
 
-- 
2.35.3





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux