From patchwork Mon Feb 12 01:20:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 871837 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zfntT1NH3z9t34 for ; Mon, 12 Feb 2018 12:21:05 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932352AbeBLBUv (ORCPT ); Sun, 11 Feb 2018 20:20:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:45233 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932311AbeBLBUv (ORCPT ); Sun, 11 Feb 2018 20:20:51 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E4380AC69; Mon, 12 Feb 2018 01:20:49 +0000 (UTC) From: NeilBrown To: tytso@mit.edu Date: Mon, 12 Feb 2018 12:20:43 +1100 Cc: linux-ext4@vger.kernel.org, lustre Subject: [e2fsprogs PATCH] tune2fs: don't recover journal if device is busy. Message-ID: <871shrrok4.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org tune2fs currently replays the journal if it needs recovery and the filesystem isn't mounted. The test for "is the filesystem mounted" isn't completely robust. Lustre makes use of ext4 filesystems in a way that they are mounted without being visible in /proc/mounts or similar. This usage can easily be detected by attempting to open the device with O_EXCL. tune2fs already does this and the EXT2_MF_BUSY flag is set if open(O_EXCL) fails. Several uses other than lustre mounts could cause O_EXCL to fail, but in any case it seems unwise to recover the journal when something else is keeping the device busy. So add an extra test to avoid journal recovery when the device is busy. This fixes some problems with lustre usage. Signed-off-by: NeilBrown Reviewed-by: Darrick J. Wong --- Note: it seems wrong to recover the journal *after* making changes to the superblock - there is a good chance that recovering the journal will over-write those changes. This is what was happening that lead me to this problem. Shouldn't journal recovery happen *first*?? Thanks, NeilBrown --- misc/tune2fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/tune2fs.c b/misc/tune2fs.c index c33fb9d80b10..703e55b6b972 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -3337,7 +3337,7 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n" } #else /* Recover the journal if possible. */ - if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) && + if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & (EXT2_MF_BUSY | EXT2_MF_MOUNTED)) && ext2fs_has_feature_journal_needs_recovery(fs->super)) { errcode_t err;