From patchwork Mon Jul 18 02:52:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongqiang Yang X-Patchwork-Id: 105145 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 95A81B6F75 for ; Mon, 18 Jul 2011 12:56:50 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752133Ab1GRC4t (ORCPT ); Sun, 17 Jul 2011 22:56:49 -0400 Received: from mail-iw0-f174.google.com ([209.85.214.174]:45447 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736Ab1GRC4s (ORCPT ); Sun, 17 Jul 2011 22:56:48 -0400 Received: by mail-iw0-f174.google.com with SMTP id 6so2719031iwn.19 for ; Sun, 17 Jul 2011 19:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=2caf26N2KuA5mvGiqlA3Fvox9jzvQRInJxDtGmK5AGA=; b=AgnvTfOoVrS7l+hlxlXbof2x6HNGlHr0ydboBFyoWNRoCu9HuNxMXmG/cfLKsJH0ER lGBhAI3j3gMBFaxkGaum/Qm/YvcmkPfjKjm4KhGhKZ7n1LfxTtx119BakVq9HgwzTLlJ TH9aGxUK12MdNYxT/iPtpMoA/NdfJigliZlKQ= Received: by 10.231.67.145 with SMTP id r17mr4085601ibi.176.1310957808320; Sun, 17 Jul 2011 19:56:48 -0700 (PDT) Received: from localhost.localdomain ([159.226.43.42]) by mx.google.com with ESMTPS id y3sm2592761ibc.37.2011.07.17.19.56.45 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jul 2011 19:56:47 -0700 (PDT) From: Yongqiang Yang To: linux-ext4@vger.kernel.org Cc: aedilger@gmail.com, Yongqiang Yang Subject: [PATCH 02/12] ext4: prevent a fs with errors from being resized Date: Mon, 18 Jul 2011 10:52:25 +0800 Message-Id: <1310957555-15617-3-git-send-email-xiaoqiangnk@gmail.com> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1310957555-15617-1-git-send-email-xiaoqiangnk@gmail.com> References: <1310957555-15617-1-git-send-email-xiaoqiangnk@gmail.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org A filesystem with errors is not allowed to being resized, otherwise, it is easy to destroy the filesystem. Signed-off-by: Yongqiang Yang --- fs/ext4/resize.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) 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;