Received: by 2002:ac0:de83:0:0:0:0:0 with SMTP id b3csp1164415imk; Sun, 3 Jul 2022 19:16:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tm9k6mBglK3/oqpLrPObm1FxbRfsFjMv1LeP5Sl9kRHP7gKTwliZAl1m6b7W5LbqPO/K3q X-Received: by 2002:a17:902:720b:b0:16b:decd:5a66 with SMTP id ba11-20020a170902720b00b0016bdecd5a66mr4646556plb.33.1656900991852; Sun, 03 Jul 2022 19:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656900991; cv=none; d=google.com; s=arc-20160816; b=OdI3iVj0QixH1I09GIBOl5fWoJ3gavo6+L1FV5yTOGsgLeLGdFrsQhk9wuUtePsv+T jZ6D46mWY5Jf4JooEQ7I10H5+p2ZfaeMp6tdBPR/M/nA+rtpAEf8a2adPNlmfM25XPOh uHLlvQD07QVUZdt06XHyTa/4EmaTmNmP5KG/COy+gqA2YsQg0NUFu4bAiL+KaXl7QLH5 4C1PYfR1bruN3vWEJimoPXnB4xr1MP3h2j/NvUSzOewy7KPgm36btFwGEEV/ZiV50Son WEp8UMQL66iGvSo6dU/sazY9C75SPGGNTiHcn8fULmVr0vuU+wOIgMG+OBsaAZk6APEG oB6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=B3aLPDwjpJnxSQ1KUQ7Dm7BQP0bcShCaxYFa6X+qGJo=; b=Hx/vJ53VeHe0kv38lLEMeHUC4TuZPwr07BqNXD1LMW3phutFvdhQeeYbhoLd//0HxH ivvXBRt+QAcd6231/wJIih8CzoYp075rIznUaSVMdshlFd2HHSGUMGk3NQsC0AcRJVvJ alxUYHRGP7ALT+sVzdDuJzzcyC05ITNOVFnw6/QO3kcjAOSmqjTOAhIiGM+8DytT+MMC Ij51P2sOZZfBlyXo+oK7fzOaZIbW/6ILTAfzcjgBvGK2gjTCibDIi5CrF1Uai7Ph579F d3d0lB+TTkPgf5aL32LUn9teLfeyHdMVqgvqJF3zE0Ipw2OsV44OlEQFqEejfBEGmxdn 9Q9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=egxo7Ont; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f14-20020a056a001ace00b0051c306c363csi41790257pfv.143.2022.07.03.19.16.20; Sun, 03 Jul 2022 19:16:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=egxo7Ont; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbiGDCKd (ORCPT + 99 others); Sun, 3 Jul 2022 22:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbiGDCKb (ORCPT ); Sun, 3 Jul 2022 22:10:31 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA42C38A4; Sun, 3 Jul 2022 19:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=B3aLPDwjpJnxSQ1KUQ7Dm7BQP0bcShCaxYFa6X+qGJo=; b=egxo7OntdvK3g9mMz9VdtCRrBK OoSo906h/yFvw8jetwY86USn9PBdj8w6ud4YshUSHa0rEdchWisfc5NF6Zi3IwWWSrWIc9XYrQJwU laaTpmrn+ixfmJTillpCvLq5cfDqJsv9rxnq0jiRq950x74RHmssZjSeoPWSvoLPHb51J7/sK0m3w iBkkVqsR90nBAcdLOVY6ewOoLjSasufC8yj0bRvFNs2mT5GRWwnn7cPZo/+/HtOwV3BzVlNio23C0 XbEv6HoDolzm3dUjYgqcJoK7CemIfyHHTSXCNTbwa/uSEjwYCa7UDr6fTnk7J+w+kAnD7zoI+KkhT KfJgx+dw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8BXV-00GsK3-Pr; Mon, 04 Jul 2022 02:10:17 +0000 Date: Mon, 4 Jul 2022 03:10:17 +0100 From: Matthew Wilcox To: Xiubo Li Cc: Jeff Layton , idryomov@gmail.com, dhowells@redhat.com, vshankar@redhat.com, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, keescook@chromium.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com Subject: Re: [PATCH 1/2] netfs: release the folio lock and put the folio before retrying Message-ID: References: <20220701022947.10716-1-xiubli@redhat.com> <20220701022947.10716-2-xiubli@redhat.com> <30a4bd0e19626f5fb30f19f0ae70fba2debb361a.camel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Mon, Jul 04, 2022 at 09:13:44AM +0800, Xiubo Li wrote: > On 7/1/22 6:38 PM, Jeff Layton wrote: > > I don't know here... I think it might be better to just expect that when > > this function returns an error that the folio has already been unlocked. > > Doing it this way will mean that you will lock and unlock the folio a > > second time for no reason. > > > > Maybe something like this instead? > > > > diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c > > index 42f892c5712e..8ae7b0f4c909 100644 > > --- a/fs/netfs/buffered_read.c > > +++ b/fs/netfs/buffered_read.c > > @@ -353,7 +353,7 @@ int netfs_write_begin(struct netfs_inode *ctx, > > trace_netfs_failure(NULL, NULL, ret, netfs_fail_check_write_begin); > > if (ret == -EAGAIN) > > goto retry; > > - goto error; > > + goto error_unlocked; > > } > > } > > @@ -418,6 +418,7 @@ int netfs_write_begin(struct netfs_inode *ctx, > > error: > > folio_unlock(folio); > > folio_put(folio); > > +error_unlocked: > > _leave(" = %d", ret); > > return ret; > > } > > Then the "afs" won't work correctly: > > 377 static int afs_check_write_begin(struct file *file, loff_t pos, unsigned > len, > 378????????????????????????????????? struct folio *folio, void **_fsdata) > 379 { > 380???????? struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); > 381 > 382???????? return test_bit(AFS_VNODE_DELETED, &vnode->flags) ? -ESTALE : 0; > 383 } > > The "afs" does nothing with the folio lock. It's OK to fix AFS too.