Skip to contentSkip to conversation

-oresize on ro filesystem causes panic

PATCH New Jeff Mahoney 1 participant 1 message Apr 19, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 -oresize on ro filesystem causes panic

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey all -

While developing my io-error patches (posted previously), I skipped the resize stuff, opting to come back to it later, since it involved re-ordering operations so we don't blow ourselves out of the water. Today, I started digging into that code, and found that if -oresize is used when the filesystem is read-only, it will attempt to start a transaction on a read-only filesystem. When CONFIG_REISERFS_CHECK is enabled, this causes an assertion failure.

mount -r /dev/hda8 /mnt
mount -oremount,resize=123456 /mnt
*panic*

The attached patch fixes the problem. It also moves the reiserfs_resize call after the filesystem is made read-write on remount. This is so the following succeeds:

mount -oremount,resize=123456,rw /mnt

- -Jeff

- --
Jeff Mahoney
SuSE Labs
[email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAg+YtLPWxlyuTD7IRAvBXAJ9ruUhuwvqYcYoLLQxv1+76kC4XTQCfYH3E rmTlSJjVWIJc5pVqPpv/F/s=
=aDB6
-----END PGP SIGNATURE-----

fs/reiserfs/resize.c +5 -0
diff -rup linux-2.6.5.kgdb/fs/reiserfs/resize.c linux-2.6.5.kgdb.afs/fs/reiserfs/resize.c
@@ -33,6 +33,11 @@ int reiserfs_resize (struct super_block 
 	int i;
 	int copy_size ;
 
+	if (s->s_flags & MS_RDONLY) {
+		reiserfs_warning (s, "Can't resize read-only filesystem.");
+		return -EINVAL;
+	}
+
 	sb = SB_DISK_SUPER_BLOCK(s);
 
 	if (SB_BLOCK_COUNT(s) >= block_count_new) {
fs/reiserfs/super.c +6 -6
diff -rup linux-2.6.5.kgdb/fs/reiserfs/super.c linux-2.6.5.kgdb.afs/fs/reiserfs/super.c
@@ -890,12 +890,6 @@ static int reiserfs_remount (struct supe
 	  SB_JOURNAL_MAX_TRANS_AGE(s) = commit_max_age;
   }
 
-  if(blocks) {
-    int rc = reiserfs_resize(s, blocks);
-    if (rc != 0)
-      return rc;
-  }
-
   if (*mount_flags & MS_RDONLY) {
     reiserfs_xattr_init (s, *mount_flags);
     /* remount read-only */
@@ -944,6 +938,12 @@ static int reiserfs_remount (struct supe
     reiserfs_xattr_init (s, *mount_flags);
   }
 
+  if(blocks) {
+    int rc = reiserfs_resize(s, blocks);
+    if (rc != 0)
+      return rc;
+  }
+
   return 0;
 }