From patchwork Wed Feb 28 11:22:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10247301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6598260594 for ; Wed, 28 Feb 2018 11:23:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54B9C28B95 for ; Wed, 28 Feb 2018 11:23:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4979828C6D; Wed, 28 Feb 2018 11:23:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C175B28BC4 for ; Wed, 28 Feb 2018 11:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752249AbeB1LXB (ORCPT ); Wed, 28 Feb 2018 06:23:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:57360 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752241AbeB1LXA (ORCPT ); Wed, 28 Feb 2018 06:23:00 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 46CDDABB3; Wed, 28 Feb 2018 11:22:59 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 1EB541E0500; Wed, 28 Feb 2018 12:22:59 +0100 (CET) From: Jan Kara To: Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= , Jan Kara Subject: [PATCH] udf: Do not mark possibly inconsistent filesystems as closed Date: Wed, 28 Feb 2018 12:22:55 +0100 Message-Id: <20180228112255.25089-1-jack@suse.cz> X-Mailer: git-send-email 2.13.6 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If logical volume integrity descriptor contains non-closed integrity type when mounting the volume, there are high chances that the volume is not consistent (device was detached before the filesystem was unmounted). Warn when mounting such volume and don't touch integrity type of the volume so that fsck can recognize it and check such filesystem. Signed-off-by: Jan Kara --- fs/udf/super.c | 8 ++++++-- fs/udf/udf_sb.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 2d4929fa884d..bf5f6084dcb2 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1988,7 +1988,10 @@ static void udf_open_lvid(struct super_block *sb) lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; ktime_get_real_ts(&ts); udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts); - lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN); + if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE) + lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN); + else + UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT); lvid->descTag.descCRC = cpu_to_le16( crc_itu_t(0, (char *)lvid + sizeof(struct tag), @@ -2028,7 +2031,8 @@ static void udf_close_lvid(struct super_block *sb) lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); - lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); + if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT)) + lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); lvid->descTag.descCRC = cpu_to_le16( crc_itu_t(0, (char *)lvid + sizeof(struct tag), diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 9dcb475fc74e..9dd3e1b9619e 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h @@ -29,6 +29,7 @@ #define UDF_FLAG_SESSION_SET 15 #define UDF_FLAG_LASTBLOCK_SET 16 #define UDF_FLAG_BLOCKSIZE_SET 17 +#define UDF_FLAG_INCONSISTENT 18 #define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 #define UDF_PART_FLAG_UNALLOC_TABLE 0x0002