Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4956431rdb; Fri, 15 Sep 2023 19:07:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbCyMYnAxod7EhPhSvSOEvPF0RDZQb004q/H0bWlLwtTrKekAWOeilknfM98nhn1hQhQtX X-Received: by 2002:a05:6a20:8f29:b0:14c:a2e1:65ec with SMTP id b41-20020a056a208f2900b0014ca2e165ecmr4406153pzk.38.1694830053964; Fri, 15 Sep 2023 19:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694830053; cv=none; d=google.com; s=arc-20160816; b=Z3iNgv7bX+b3fflMh+QCMspLmJoA6v8PnD7GCBz4S/KWMGQZmXmmPMn/Eg+t5LlDds nxpReXyhLMWdBQ5T/Oa15WheWRLZUA9fT+9Ti35YIgzu+Jskrz8+RK3ajW71IH/Dsrxg VwoflowUWM16Qsk2teViqB8hDdtgJFCzu6M0Jrvh+l5PlGtSKQAAcDB1iP43RdSf5oC9 +96qP9XHPffazvEAR4GnduECsQ+HLUoPhQtxdDCgnhYiFSRAsc6yT/RFVzNvCxMudc+o qNXAC9Pl/jd+JbpjuimqsmsG2FRux2VeWdh9LXop6pnvRrg+ToXxxEWStyPLapBbNaHe 3aaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5PWa8bY4dekYeG890jHuH5+xQm9Lpc2bhtlqgPaBIx8=; fh=Exu8p2J0bt/MoYkEByA/Woj5EWTdUoRsvJYmK88z1hY=; b=0rVIAOmfdZdi8SIR7PrEkarEvYcnxq/Xdj5bis2+ON7TlN4GJXe0tWmCji095Pj5+H nqeW8/1N2+PEe7GZ0VauGECW+Q7Wobsyt8pBOzZfEElFXZSn0HPVuCWWZnhAgwe+ZKIR rkhhzkKjF3usivl7IKC2JipbxCqb4yZ+DMgZmmOxd6/pcH29iu2T+sdmfxqMe+X+CPJ7 5N+DC9eWxZMmvDlVJNm1EFbl2G8+MKJjO8T2tbUttoGM6gQT2//tAGr+LHmVwS2M//Tp Nqeaee1rlE4Wv0Z7ZuqumJIyD+14NLsShaVGwzbatjqE2B0+iR5za+DQdg+3YXv1cIpj miYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=m1Ryp53i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id a35-20020a631a63000000b00565218f25c4si3986133pgm.858.2023.09.15.19.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:07:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=m1Ryp53i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BC6C38540AE7; Fri, 15 Sep 2023 11:38:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236707AbjIOSiJ (ORCPT + 99 others); Fri, 15 Sep 2023 14:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236509AbjIOSh3 (ORCPT ); Fri, 15 Sep 2023 14:37:29 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C487115; Fri, 15 Sep 2023 11:37:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5PWa8bY4dekYeG890jHuH5+xQm9Lpc2bhtlqgPaBIx8=; b=m1Ryp53inYiFotTtBpCrbEJqhU mqeis08LHa2btJKQJ+ja28v2D+DIGo1PD25gPHrnN9TPG1PJSfbMS61hIUlhlstpyTQjIqdgbftjX PKnvMQthLiws4zgTBgwNPqwd44Jw2/kSpPLzxZVrlIQ8rgj/8mygtAqjlOPT02FIi3ho27qCUtDV/ sLH8hK+zALH4dBoBCo0Mzh3R1xo9jq3RggHQM6urHIgvQ7FipCt0e/C6ufa3pb1CRKC48NeCwtADq lbN8JXJvVC4a8Xir81JjqXJ8YoGXWIm1YAzIINL4KbLWtMac+XL7H+tLJLi1Ob4XZUQIgjS2ewfGY FaeKtW4w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qhDgj-00BMIN-3p; Fri, 15 Sep 2023 18:37:09 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, torvalds@linux-foundation.org, Nicholas Piggin Subject: [PATCH 01/17] iomap: Hold state_lock over call to ifs_set_range_uptodate() Date: Fri, 15 Sep 2023 19:36:51 +0100 Message-Id: <20230915183707.2707298-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230915183707.2707298-1-willy@infradead.org> References: <20230915183707.2707298-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Fri, 15 Sep 2023 11:38:29 -0700 (PDT) This is really preparation for the next patch, but it lets us call folio_mark_uptodate() in just one place instead of two. Signed-off-by: Matthew Wilcox (Oracle) --- fs/iomap/buffered-io.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index ae8673ce08b1..4c05fd457ee7 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -57,30 +57,32 @@ static inline bool ifs_block_is_uptodate(struct iomap_folio_state *ifs, return test_bit(block, ifs->state); } -static void ifs_set_range_uptodate(struct folio *folio, +static bool ifs_set_range_uptodate(struct folio *folio, struct iomap_folio_state *ifs, size_t off, size_t len) { struct inode *inode = folio->mapping->host; unsigned int first_blk = off >> inode->i_blkbits; unsigned int last_blk = (off + len - 1) >> inode->i_blkbits; unsigned int nr_blks = last_blk - first_blk + 1; - unsigned long flags; - spin_lock_irqsave(&ifs->state_lock, flags); bitmap_set(ifs->state, first_blk, nr_blks); - if (ifs_is_fully_uptodate(folio, ifs)) - folio_mark_uptodate(folio); - spin_unlock_irqrestore(&ifs->state_lock, flags); + return ifs_is_fully_uptodate(folio, ifs); } static void iomap_set_range_uptodate(struct folio *folio, size_t off, size_t len) { struct iomap_folio_state *ifs = folio->private; + unsigned long flags; + bool uptodate = true; - if (ifs) - ifs_set_range_uptodate(folio, ifs, off, len); - else + if (ifs) { + spin_lock_irqsave(&ifs->state_lock, flags); + uptodate = ifs_set_range_uptodate(folio, ifs, off, len); + spin_unlock_irqrestore(&ifs->state_lock, flags); + } + + if (uptodate) folio_mark_uptodate(folio); } -- 2.40.1