From: NeilBrown Date: Sat, 24 Feb 2018 19:56:06 +0000 (-0500) Subject: tune2fs: don't recover journal if device is busy. X-Git-Tag: debian/1.44.4-1~12^2~5 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;ds=sidebyside;h=ee8b61e9b0acf23759f83fb255f720cdfbd8f233;p=tools%2Fe2fsprogs.git tune2fs: don't recover journal if device is busy. 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 Signed-off-by: Theodore Ts'o Reviewed-by: Darrick J. Wong --- diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 7bbd610..a3374ab 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -3226,7 +3226,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;