Message ID | 1f95ab55-ce05-4c11-8c14-8df260514208@paragon-software.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1834482vqu; Tue, 26 Sep 2023 04:20:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIdkMIIvcmMN9+NVMvlZwTlUw6okjk/iTnsfrAZqXUiAh8cReSThvqnAqslrF/IEQa3yHx X-Received: by 2002:a25:d78d:0:b0:d84:e754:d541 with SMTP id o135-20020a25d78d000000b00d84e754d541mr8631940ybg.4.1695727234556; Tue, 26 Sep 2023 04:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695727234; cv=none; d=google.com; s=arc-20160816; b=hSDPum5P6GtyAh7cx5Jve+TEa97P4pLsrZ0vl+TW5sCGSRj3tGV1Z/o5dzAENtS04Z QJkw5sl3ivfDq8qoTLrnCVbDBUU70/OCpGOFCmJhBkQqQ0vv6gR9zKbZEyXOGb8hwNG+ 3lLVAr1fGQiv4jCnrB9GYpyT3WhYjYTfWgovVvsL26uvaPcvQZhblweQ8+wjxnAGm2Id IBrQXAerGkADxu+2i/MxlQ7CiskX9oNeh0+eKbadvfQNk7sopqt0tPmsOGVDg1/xpLsu ysX1vNughIAfmHFOPgsX+0buToXGv7Pj60dtANTXcqM2vcg9ApiU/8mcRabathyK5gPE hk1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=Nf2tlL8ndkT5fumOF9aSaoVeSNGQzhIY6kDh91oVRUE=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=xEnmbgDwciCYV7sgIYGb+n4CCi3GbdEj5K3dijQsxBDdOQI6UPaOu+7s4ftWK+e1QR BBPywqU60QoeJz5t0NOMR9eFRb9Zktxp5dF5VcEFS1ZSEPHcfH6F39tFYfjSEpWawLEB FLkGugNWM/Eua13sQLEkYrpMzy5Zrp94W9vhMW6ioEJcKU9R6tzqwI/fN7vZ590UMaRf PmbBBcWLrlYHUXwQOSoTkbEonq6dSswMT+uYK/mQYglOxNMy8pSUPCwP0V9aCa3zZpN7 +b3Sujp4/OepbJowht0O+rVhu+gnmhKvkudPlqL8QAdeeFBuU14YoVaXgun7LizTk4js KOvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=ncv0G8ar; dkim=pass header.i=@paragon-software.com header.s=mail header.b=iiibi4AD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o66-20020a634145000000b005657ba564bdsi4841720pga.826.2023.09.26.04.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 04:20:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=ncv0G8ar; dkim=pass header.i=@paragon-software.com header.s=mail header.b=iiibi4AD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CF7D1808A8EE; Tue, 26 Sep 2023 02:56:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbjIZJ4R (ORCPT <rfc822;ruipengqi7@gmail.com> + 27 others); Tue, 26 Sep 2023 05:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233553AbjIZJ4J (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 26 Sep 2023 05:56:09 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99E5B1BB; Tue, 26 Sep 2023 02:55:55 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 6DAF221BC; Tue, 26 Sep 2023 09:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1695721803; bh=Nf2tlL8ndkT5fumOF9aSaoVeSNGQzhIY6kDh91oVRUE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=ncv0G8arOqm3X0jid+4L2MVE689rRbad7e+k+2BtujmZbDit/pHvyARgZuZx771R8 G/gat1h2aicoRanLAt5Kgn0z0Vtgcy1QHRdoGKO9Wev7FT3X2wi0O54CLxk46+waT6 tAL85kb0QqmYZYfglW65WrgRuZDzW3+v3hnWcVbg= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id BC64A1D45; Tue, 26 Sep 2023 09:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1695722153; bh=Nf2tlL8ndkT5fumOF9aSaoVeSNGQzhIY6kDh91oVRUE=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=iiibi4ADh06yd/BR2C+7DGZUaIaGB5nAQx2rdMPVvbAHFhoW2q0ApmU24dyT7+e/V SHf1Z9nkn0L5Y96wEVu+wEa/PxzC5SI8UzgatQ9S+FCm4geVL0Tip2yPrqTutDdc6E 0h4Ox3DQLEdMQEdWIIyfRU7i0lv4LVt9yMs00yDY= Received: from [172.16.192.129] (192.168.211.137) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Tue, 26 Sep 2023 12:55:53 +0300 Message-ID: <1f95ab55-ce05-4c11-8c14-8df260514208@paragon-software.com> Date: Tue, 26 Sep 2023 12:55:53 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/8] fs/ntfs3: Fix alternative boot searching Content-Language: en-US From: Konstantin Komarovc <almaz.alexandrovich@paragon-software.com> To: <ntfs3@lists.linux.dev> CC: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org> References: <7c217d7d-6ee4-4603-b5f1-ebe7b68cf430@paragon-software.com> In-Reply-To: <7c217d7d-6ee4-4603-b5f1-ebe7b68cf430@paragon-software.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [192.168.211.137] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 26 Sep 2023 02:56:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778098880231111701 X-GMAIL-MSGID: 1778098880231111701 |
Series |
fs/ntfs3: Bugfix and refactoring
|
|
Commit Message
Konstantin Komarov
Sept. 26, 2023, 9:55 a.m. UTC
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
fs/ntfs3/super.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
struct MFT_REC *rec;
@@ -855,6 +855,9 @@ static int ntfs_init_from_boot(struct super_block
*sb, u32 sector_size,
u32 boot_off = 0;
const char *hint = "Primary boot";
+ /* Save original dev_size. Used with alternative boot. */
+ dev_size0 = dev_size;
+
sbi->volume.blocks = dev_size >> PAGE_SHIFT;
bh = ntfs_bread(sb, 0);
@@ -1087,9 +1090,9 @@ static int ntfs_init_from_boot(struct super_block
*sb, u32 sector_size,
}
out:
- if (err == -EINVAL && !bh->b_blocknr && dev_size > PAGE_SHIFT) {
+ if (err == -EINVAL && !bh->b_blocknr && dev_size0 > PAGE_SHIFT) {
u32 block_size = min_t(u32, sector_size, PAGE_SIZE);
- u64 lbo = dev_size - sizeof(*boot);
+ u64 lbo = dev_size0 - sizeof(*boot);
/*
* Try alternative boot (last sector)
@@ -1103,6 +1106,7 @@ static int ntfs_init_from_boot(struct super_block
*sb, u32 sector_size,
boot_off = lbo & (block_size - 1);
hint = "Alternative boot";
+ dev_size = dev_size0; /* restore original size. */
goto check_boot;
}
brelse(bh);
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 71c80c578feb..d2951b23f52a 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -846,7 +846,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, struct ntfs_sb_info *sbi = sb->s_fs_info; int err; u32 mb, gb, boot_sector_size, sct_per_clst, record_size; - u64 sectors, clusters, mlcn, mlcn2; + u64 sectors, clusters, mlcn, mlcn2, dev_size0; struct NTFS_BOOT *boot; struct buffer_head *bh;