From: Yongqiang Yang Date: Wed, 27 Jul 2011 01:39:09 +0000 (-0400) Subject: ext4: prevent a fs with errors from being resized X-Git-Tag: upstream/snapshot3+hdmi~9398^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce723c31b58f54fb865036805475ee7a8c5dc173;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git ext4: prevent a fs with errors from being resized A filesystem with errors is not allowed to being resized, otherwise, it is easy to destroy the filesystem. Signed-off-by: Yongqiang Yang Signed-off-by: "Theodore Ts'o" --- diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 0213f63..53d9795 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -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;