From patchwork Fri Aug 12 16:42:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Czerner X-Patchwork-Id: 109875 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 5594AB6F62 for ; Sat, 13 Aug 2011 02:43:24 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751718Ab1HLQnU (ORCPT ); Fri, 12 Aug 2011 12:43:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51233 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751682Ab1HLQnR (ORCPT ); Fri, 12 Aug 2011 12:43:17 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7CGhGqm020008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 12 Aug 2011 12:43:16 -0400 Received: from dhcp-27-109.brq.redhat.com (dhcp-1-248.brq.redhat.com [10.34.1.248]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7CGh9pN009448; Fri, 12 Aug 2011 12:43:15 -0400 From: Lukas Czerner To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger@dilger.ca, Lukas Czerner Subject: [PATCH 4/5 v2] e2fsck: do not attempt to discard if -n was specified Date: Fri, 12 Aug 2011 18:42:59 +0200 Message-Id: <1313167380-3283-4-git-send-email-lczerner@redhat.com> In-Reply-To: <1313167380-3283-1-git-send-email-lczerner@redhat.com> References: <1313167380-3283-1-git-send-email-lczerner@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If '-n' option is specified there should be no changes made to the file system hence we should not attempt to discard the file system. This commit adds a check into the e2fsck_discard_blocks() condition so it skip discard if E2F_OPT_NO flag is set. Signed-off-by: Lukas Czerner --- v2: This is the actually the first version of the patch e2fsck/pass5.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c index f9d746c..cf37556 100644 --- a/e2fsck/pass5.c +++ b/e2fsck/pass5.c @@ -87,7 +87,8 @@ static void e2fsck_discard_blocks(e2fsck_t ctx, io_manager manager, if (ext2fs_test_changed(ctx->fs)) ctx->options &= ~E2F_OPT_DISCARD; - if ((ctx->options & E2F_OPT_DISCARD) && + if (!(ctx->options & E2F_OPT_NO) && + (ctx->options & E2F_OPT_DISCARD) && (io_channel_discard(fs->io, start, count))) ctx->options &= ~E2F_OPT_DISCARD; } @@ -331,11 +332,9 @@ redo_counts: if (first_free > i) first_free = i; } else { - if ((i > first_free) && - (ctx->options & E2F_OPT_DISCARD)) { + if (i > first_free) e2fsck_discard_blocks(ctx, manager, first_free, (i - first_free)); - } first_free = ext2fs_blocks_count(fs->super); } blocks ++;