From: Xiubo Li <xiubli@redhat.com>
To: Jeff Layton <jlayton@kernel.org>,
idryomov@gmail.com, dhowells@redhat.com
Cc: vshankar@redhat.com, linux-kernel@vger.kernel.org,
ceph-devel@vger.kernel.org, willy@infradead.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
Date: Mon, 4 Jul 2022 14:58:33 +0800 [thread overview]
Message-ID: <c2eea9eb-e4b2-efdf-8edc-a929ac276c19@redhat.com> (raw)
In-Reply-To: <30a4bd0e19626f5fb30f19f0ae70fba2debb361a.camel@kernel.org>
On 7/1/22 6:38 PM, Jeff Layton wrote:
> On Fri, 2022-07-01 at 10:29 +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> The lower layer filesystem should always make sure the folio is
>> locked and do the unlock and put the folio in netfs layer.
>>
>> URL: https://tracker.ceph.com/issues/56423
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>> fs/netfs/buffered_read.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
>> index 42f892c5712e..257fd37c2461 100644
>> --- a/fs/netfs/buffered_read.c
>> +++ b/fs/netfs/buffered_read.c
>> @@ -351,8 +351,11 @@ int netfs_write_begin(struct netfs_inode *ctx,
>> ret = ctx->ops->check_write_begin(file, pos, len, folio, _fsdata);
>> if (ret < 0) {
>> trace_netfs_failure(NULL, NULL, ret, netfs_fail_check_write_begin);
>> - if (ret == -EAGAIN)
>> + if (ret == -EAGAIN) {
>> + folio_unlock(folio);
>> + folio_put(folio);
>> goto retry;
>> + }
>> goto error;
>> }
>> }
> 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:
Should we also put the folio in ceph and afs ? Won't it introduce
something like use-after-free bug ?
Maybe we should unlock it in ceph and afs and put it in netfs layer.
-- Xiubo
> _leave(" = %d", ret);
> return ret;
> }
>
next prev parent reply other threads:[~2022-07-04 6:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 2:29 [PATCH 0/2] netfs, ceph: fix the crash when unlocking the folio xiubli
2022-07-01 2:29 ` [PATCH 1/2] netfs: release the folio lock and put the folio before retrying xiubli
2022-07-01 10:38 ` Jeff Layton
2022-07-04 1:13 ` Xiubo Li
2022-07-04 2:10 ` Matthew Wilcox
2022-07-04 2:40 ` Xiubo Li
2022-07-04 6:58 ` Xiubo Li [this message]
2022-07-05 13:21 ` David Howells
2022-07-05 13:41 ` Jeff Layton
2022-07-06 0:58 ` Xiubo Li
2022-07-01 2:29 ` [PATCH 2/2] ceph: do not release the folio lock in kceph xiubli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c2eea9eb-e4b2-efdf-8edc-a929ac276c19@redhat.com \
--to=xiubli@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-cachefs@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vshankar@redhat.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).