]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ext4: prevent a fs with errors from being resized
authorYongqiang Yang <xiaoqiangnk@gmail.com>
Wed, 27 Jul 2011 01:39:09 +0000 (21:39 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 27 Jul 2011 01:39:09 +0000 (21:39 -0400)
A filesystem with errors is not allowed to being resized, otherwise,
it is easy to destroy the filesystem.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/resize.c

index 0213f631271ff4ce8814cba83d0dfee418a7b1fc..53d979541b317463dd86a5297a06adebf946cf4b 100644 (file)
@@ -23,6 +23,16 @@ int ext4_resize_begin(struct super_block *sb)
        if (!capable(CAP_SYS_RESOURCE))
                return -EPERM;
 
+       /*
+        * We are not allowed to do online-resizing on a filesystem mounted
+        * with error, because it can destroy the filesystem easily.
+        */
+       if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
+               ext4_warning(sb, "There are errors in the filesystem, "
+                            "so online resizing is not allowed\n");
+               return -EPERM;
+       }
+
        if (test_and_set_bit_lock(EXT4_RESIZING, &EXT4_SB(sb)->s_resize_flags))
                ret = -EBUSY;