Skip to contentSkip to conversation

fix ext2/ext3 revision level checks

PATCH New Andreas Dilger 1 participant 1 message Feb 16, 2002 ext2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix ext2/ext3 revision level checks

Hi Dave,
this patch/CSET fixes the revision-level checking for ext2 and ext3.

Without it, we will still try to write the superblock even if we set the mount read-only, we do not return an error code to mount(8) to tell the user that the filesystem cannot be remounted read-write, and we get a false warning when a user tries to mount such a filesystem read-only.

You should just be able to do "|bk receive [linux-2.5 path]" to import the CSET at the end directly into BK if you so desire and your email client can do pipes.

Note that I have compiled this but not run-tested it on 2.5 because I am unable to get 2.5 to finish a build at this time (haven't tried -dj yet)... It is exactly the same patch that I have been using and tested correct behaviour with under 2.4, so it should be OK.

Cheers, Andreas
==========================================================================
[email protected], 2002-02-14 12:01:31-07:00, [email protected]
Don't try to write the superblock or pretend to let a read-write remount succeed if the ext2/ext3 superblock has too high a revision level.

fs/ext2/super.c +12 -9
diff -Nru a/fs/ext2/super.c b/fs/ext2/super.c
@@ -332,14 +332,16 @@
 			      struct ext2_super_block * es,
 			      int read_only)
 {
-	int res = 0;
+	if (read_only)
+		return 0;
+
 	if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
-		printk ("EXT2-fs warning: revision level too high, "
-			"forcing read-only mode\n");
-		res = MS_RDONLY;
+		ext2_warning(sb, __FUNCTION__, "revision level too high, "
+			     "forcing read-only mode");
+		sb->s_flags |= MS_RDONLY;
+		return -EROFS;
 	}
-	if (read_only)
-		return res;
+
 	if (!(sb->u.ext2_sb.s_mount_state & EXT2_VALID_FS))
 		printk ("EXT2-fs warning: mounting unchecked fs, "
 			"running e2fsck is recommended\n");
@@ -374,7 +376,7 @@
 		ext2_check_inodes_bitmap (sb);
 	}
 #endif
-	return res;
+	return 0;
 }
 
 static int ext2_check_descriptors (struct super_block * sb)
@@ -788,8 +790,9 @@
 		 * by e2fsck since we originally mounted the partition.)
 		 */
 		sb->u.ext2_sb.s_mount_state = le16_to_cpu(es->s_state);
-		if (!ext2_setup_super (sb, es, 0))
-			sb->s_flags &= ~MS_RDONLY;
+		if ((ret = ext2_setup_super (sb, es, 0)))
+			return ret;
+		sb->s_flags &= ~MS_RDONLY;
 	}
 	ext2_sync_super(sb, es);
 	return 0;
fs/ext3/super.c +9 -9
diff -Nru a/fs/ext3/super.c b/fs/ext3/super.c
@@ -708,15 +708,14 @@
 			    int read_only)
 {
 	struct ext3_sb_info *sbi = EXT3_SB(sb);
-	int res = 0;
 
 	if (le32_to_cpu(es->s_rev_level) > EXT3_MAX_SUPP_REV) {
-		printk (KERN_ERR "EXT3-fs warning: revision level too high, "
-			"forcing read-only mode\n");
-		res = MS_RDONLY;
+		ext3_warning(sb, __FUNCTION__, "revision level too high, "
+			     "forcing read-only mode");
+		sb->s_flags |= MS_RDONLY;
+		return -EROFS;
 	}
-	if (read_only)
-		return res;
+
 	if (!(sbi->s_mount_state & EXT3_VALID_FS))
 		printk (KERN_WARNING "EXT3-fs warning: mounting unchecked fs, "
 			"running e2fsck is recommended\n");
@@ -775,7 +774,7 @@
 	}
 #endif
 	setup_ro_after(sb);
-	return res;
+	return 0;
 }
 
 static int ext3_check_descriptors (struct super_block * sb)
@@ -1711,8 +1710,9 @@
 			 */
 			ext3_clear_journal_err(sb, es);
 			sbi->s_mount_state = le16_to_cpu(es->s_state);
-			if (!ext3_setup_super (sb, es, 0))
-				sb->s_flags &= ~MS_RDONLY;
+			if ((ret = ext3_setup_super (sb, es, 0)))
+				return ret;
+			sb->s_flags &= ~MS_RDONLY;
 		}
 	}
 	setup_ro_after(sb);

================================================================

This BitKeeper patch contains the following changesets:
1.332
## Wrapped with gzip_uu ##

begin 664 bkpatch13015 M'XL(,X+;#P"]V6:VO;2!2&/WM^Q2&%W9A&\EQT=7');M)+V#8)3O-AH2#& MTMC65I;,C.0D(/K;]XR<BY/6*6F[4%82'EMSYN4]9\XC^1F<&Z6'/9GEQ4QI M\@S>5J8>]HJK\M*]ONGF98T3XZK"B4%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