From patchwork Wed Dec 6 15:12:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174627 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4170657vqy; Wed, 6 Dec 2023 07:12:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMhLXOEBWf0rMmDh5xqJbmbT1+23/a/My9iNZD5h8xcGCXs3fLi1Vd65GKUZ0jeXoglXjm X-Received: by 2002:a05:6a20:8f07:b0:18f:ee27:aa59 with SMTP id b7-20020a056a208f0700b0018fee27aa59mr312098pzk.10.1701875536363; Wed, 06 Dec 2023 07:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875536; cv=none; d=google.com; s=arc-20160816; b=B/qEDd7kk4wqKfaRHVDsrjU4zurCfSDM0VEcEUX5i7tu310GWqNxHcl+c95/qraDMw QfJj81+ODAke6OrY5RN0FlXvQAdvCGoQxRliucWK09vVSNUzpFQ92+kij1loBXfNm/tY YyugY0JSLDro32suHQ0/3RWCPqTx+sxy4gQqCCxQxgYS/sGOdfqvU5Z1mWPns9lqNkxW OJpbWvVZVfvTV/z8KZI5E6Q59AiZwrprsUh02aZKbGb6z+cJI1/I7RAzUpmU52zYCgWO URaSdDl8dhA2NWbLK4pgPpPNeFuyVwWWcHchZG/R4Yq6uo3wv53JfoeTr8ISrC7M6uOg 0sRg== 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; bh=KEnz3KTE1Z9/osOlDauLKgWtI6LdwFBhWwhEahHqNQo=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=DChdTDPJoc63ohPEJ5VIOUKsWfJE5H6YEt7vX2w4dl5rnuIhyc4DnmwaPNmHQYHnsa vzhqP/YNAl8U5wpCTLKI200l4VyOEqXgPrI9LS9nTveGZHSv5gvLP7jSza9Eh+HAMvNF Fm4VV1q+iYq+FVW7owHvXu3fOUmZ4YRi/LEYp4GvuGKC+1Gpp9meJQF3zLdBPOgg/j75 JYAa9x/g5yfKCCz7p4s6OMbc2a4U3fIbfg5ZtcmeQskGJqUqxN+MrFZAS/KTLz6S5Zxo DOKvE/uC/CEDdWwMxOKjNeDtl3ZmnArL5pPaGUY41NQ9SMLcWvcSW8M4qHsFgmUgZoY7 G3Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=ml0RcwIB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id t32-20020a056a0013a000b006cd8db94631si79605pfg.365.2023.12.06.07.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:12:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=ml0RcwIB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 2917581C0C08; Wed, 6 Dec 2023 07:12:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379228AbjLFPMB (ORCPT + 99 others); Wed, 6 Dec 2023 10:12:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379090AbjLFPMA (ORCPT ); Wed, 6 Dec 2023 10:12:00 -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 52FF1C6; Wed, 6 Dec 2023 07:12:06 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 2AAFC2120; Wed, 6 Dec 2023 15:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875140; bh=KEnz3KTE1Z9/osOlDauLKgWtI6LdwFBhWwhEahHqNQo=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=ml0RcwIB/jbk6KHc50rd9/kLCglaBQgfFiOHbhazURkapxReFpC4vxnpvlYMS8nrP 58adYEG0RnhgyeLDEMwND0AqrD9TZFlz6HTNiuDEmvzUmC5+PXmjU2b3YGybT7p0QH p4lAjZYfowSTC2GQFaBSEjxTjNgDlilQX4n/rSpU= 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:03 +0300 Message-ID: <7ae15d02-7745-4241-8b28-197eebbb6b7b@paragon-software.com> Date: Wed, 6 Dec 2023 18:12:03 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 07/16] fs/ntfs3: Fix multithreaded stress test 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 pete.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 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:12:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545841967640469 X-GMAIL-MSGID: 1784545841967640469 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/attrib.c | 21 ++++++++++++++-------  1 file changed, 14 insertions(+), 7 deletions(-)      CLST hint, svcn, to_alloc, evcn1, next_svcn, asize, end, vcn0, alen; @@ -904,12 +904,8 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,          *len = 0;      up_read(&ni->file.run_lock); -    if (*len) { -        if (*lcn != SPARSE_LCN || !new) -            return 0; /* Fast normal way without allocation. */ -        else if (clen > *len) -            clen = *len; -    } +    if (*len && (*lcn != SPARSE_LCN || !new)) +        return 0; /* Fast normal way without allocation. */      /* No cluster in cache or we need to allocate cluster in hole. */      sbi = ni->mi.sbi; @@ -918,6 +914,17 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,      ni_lock(ni);      down_write(&ni->file.run_lock); +    /* Repeat the code above (under write lock). */ +    if (!run_lookup_entry(run, vcn, lcn, len, NULL)) +        *len = 0; + +    if (*len) { +        if (*lcn != SPARSE_LCN || !new) +            goto out; /* normal way without allocation. */ +        if (clen > *len) +            clen = *len; +    } +      le_b = NULL;      attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL, 0, NULL, &mi_b);      if (!attr_b) { diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 63f70259edc0..4b78b669a3bd 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -886,7 +886,7 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,      struct runs_tree *run = &ni->file.run;      struct ntfs_sb_info *sbi;      u8 cluster_bits; -    struct ATTRIB *attr = NULL, *attr_b; +    struct ATTRIB *attr, *attr_b;      struct ATTR_LIST_ENTRY *le, *le_b;      struct mft_inode *mi, *mi_b;