From patchwork Wed Dec 6 15:12:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4171092vqy; Wed, 6 Dec 2023 07:12:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMYxooSIcm/EagOkzW+GFYmJQ9RtjAcLNjZVLPeFSDPteB0/FIf5M+uWFnUOJpa2dzkcjm X-Received: by 2002:a05:6a20:a303:b0:18b:cd15:b832 with SMTP id x3-20020a056a20a30300b0018bcd15b832mr651576pzk.42.1701875569578; Wed, 06 Dec 2023 07:12:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875569; cv=none; d=google.com; s=arc-20160816; b=fHNvR9P0kICCwu59VeKkH8HY+02TOPMy0f1Fm/iFiqjLAHvGI8xl6robpHQ2dzah9U oxp8PgDapF40Zdrq27t+foBUDwWpzBLm/BTws57o9aONEcaT41Ajl7kvM7UJEvrK952o PFbdXG+Blk7OdgJuSv/JygMj2jAdRi1bo5OBZkZpJqSuVFredKeHzTinT/2GODJYPz5v JTdg/v6q0k72gKWKlBPSae3TCwcqwNtAKzlggjCK1N6YFJ8RKpdpLewfR/PlRr0Z398C uA/iB2t4YYGJ+r+n29wqSYhvuunzCXrDBbh7LsiI7NKFXE0pWxvoixtH1POc5ssUN+4W 8ROQ== 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=uNOivJvRpFbPgTjjVYSC1qoe7uSyIYuTw1rYbo9Hp0w=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=fxhQwBZD0qR7LNo/+0L9wO0TXpyIQz11qdSzm4RqrOSKzg2gmawG29tNLRPnfIgGsg SbJD6CVLF8WVYEJbhDE3Doi17g+3GgXBjfJ6F+q/Xi6m/SbR9zlr9MiCpaMo6xXkwrSN tDN+QlqKF5RG9lZGscRyz+B2ME3DuYLQxoXAAi8QHZB1KMWI6KJ8XP3MHHzJ+ts/YKhf LIOv/HSBCkp9NIfkPstESmx+S7TppfQytVag94DUdfUES62oPjVslH59Cdf7WEi5Hvbe VtxhQY7i433SR+f88o8wTSzVk+drRBd6DYrOHtbTmZf+lKz1zdEHXKg7ZLJgAY/TpDf7 4hVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="bj/RGX+6"; dkim=pass header.i=@paragon-software.com header.s=mail header.b=EDu7HbCK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id fd34-20020a056a002ea200b006be04b8c3basi91762pfb.178.2023.12.06.07.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:12:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="bj/RGX+6"; dkim=pass header.i=@paragon-software.com header.s=mail header.b=EDu7HbCK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 8DE538030E7B; Wed, 6 Dec 2023 07:12:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442399AbjLFPMh (ORCPT + 99 others); Wed, 6 Dec 2023 10:12:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379090AbjLFPMg (ORCPT ); Wed, 6 Dec 2023 10:12:36 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92A799A; Wed, 6 Dec 2023 07:12:42 -0800 (PST) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 6CBA71E1A; Wed, 6 Dec 2023 15:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875176; bh=uNOivJvRpFbPgTjjVYSC1qoe7uSyIYuTw1rYbo9Hp0w=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=bj/RGX+6H/0ra5+wZHFHw7x8ZHxC4RWyNh6puOtIUKz5QvQUmsZ0xpgJCSi/3kgd8 CIsytNXKjsTuT5Mx61jzLyhwiQnJd83CIzQ/z1e9e85Gj6tRy0SUOh6XKrUueruEHx 18Yo98VSLGmUOGFrBa2t/w8+BTvfuN+wPVYQ0NHY= 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 AF2152117; Wed, 6 Dec 2023 15:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875560; bh=uNOivJvRpFbPgTjjVYSC1qoe7uSyIYuTw1rYbo9Hp0w=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=EDu7HbCK/E19/EVWbQReaNUWjnJLDH4T6JYEPDGhrvSGr5wZUxVJQM4lhLYJD/t0W oR+i7ET+/BXRId+BZ8LmBGtxuI6ob1ldfPfm/VIOAwEHZKDQULAHXsEE6jT94qMOJ2 9BGkKHDpMtgzU6Cv1q/cZpWUFN0QVVDb06lPOESw= Received: from [172.16.192.129] (192.168.211.144) 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; Wed, 6 Dec 2023 18:12:40 +0300 Message-ID: <29a1087c-c903-488c-993a-2e3c23c2d4d2@paragon-software.com> Date: Wed, 6 Dec 2023 18:12:40 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 09/16] fs/ntfs3: Correct use bh_read Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) 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,T_SCC_BODY_TEXT_LINE 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: 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]); Wed, 06 Dec 2023 07:12:46 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545876816059506 X-GMAIL-MSGID: 1784545876816059506 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/file.c  | 19 +++++++++----------  fs/ntfs3/inode.c |  7 +++----  2 files changed, 12 insertions(+), 14 deletions(-)      } diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index a5a30a24ce5d..5691f04e6751 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -188,6 +188,7 @@ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to)      u32 bh_next, bh_off, to;      sector_t iblock;      struct folio *folio; +    bool dirty = false;      for (; idx < idx_end; idx += 1, from = 0) {          page_off = (loff_t)idx << PAGE_SHIFT; @@ -223,29 +224,27 @@ static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vbo_to)              /* Ok, it's mapped. Make sure it's up-to-date. */              if (folio_test_uptodate(folio))                  set_buffer_uptodate(bh); - -            if (!buffer_uptodate(bh)) { -                err = bh_read(bh, 0); -                if (err < 0) { -                    folio_unlock(folio); -                    folio_put(folio); -                    goto out; -                } +            else if (bh_read(bh, 0) < 0) { +                err = -EIO; +                folio_unlock(folio); +                folio_put(folio); +                goto out;              }              mark_buffer_dirty(bh); -          } while (bh_off = bh_next, iblock += 1,               head != (bh = bh->b_this_page));          folio_zero_segment(folio, from, to); +        dirty = true;          folio_unlock(folio);          folio_put(folio);          cond_resched();      }  out: -    mark_inode_dirty(inode); +    if (dirty) +        mark_inode_dirty(inode);      return err;  } diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index fa6c7965473c..bba0208c4afd 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -345,9 +345,7 @@ static struct inode *ntfs_read_mft(struct inode *inode,              inode->i_size = le16_to_cpu(rp.SymbolicLinkReparseBuffer                                  .PrintNameLength) /                      sizeof(u16); -              ni->i_valid = inode->i_size; -              /* Clear directory bit. */              if (ni->ni_flags & NI_FLAG_DIR) {                  indx_clear(&ni->dir); @@ -653,9 +651,10 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,              off = vbo & (PAGE_SIZE - 1);              folio_set_bh(bh, folio, off); -            err = bh_read(bh, 0); -            if (err < 0) +            if (bh_read(bh, 0) < 0) { +                err = -EIO;                  goto out; +            }              folio_zero_segment(folio, off + voff, off + block_size);          }