From: JeffleXu <jefflexu@linux.alibaba.com>
To: Jia Zhu <zhujia.zj@bytedance.com>, dhowells@redhat.com, xiang@kernel.org
Cc: linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
yinxin.x@bytedance.com
Subject: Re: [External] Re: [PATCH 3/5] cachefiles: resend an open request if the read request's object is closed
Date: Thu, 13 Oct 2022 09:47:11 +0800 [thread overview]
Message-ID: <3051133b-1408-2ccb-b22f-e5ee990bdc4f@linux.alibaba.com> (raw)
In-Reply-To: <c6f5d729-2083-817d-fe7d-b01bce27e39f@bytedance.com>
On 10/12/22 11:37 PM, Jia Zhu wrote:
>
>
> 在 2022/10/12 15:53, JeffleXu 写道:
>>
>>
>> On 10/11/22 9:15 PM, Jia Zhu wrote:
>>> @@ -254,12 +282,18 @@ ssize_t cachefiles_ondemand_daemon_read(struct
>>> cachefiles_cache *cache,
>>> * request distribution fair.
>>> */
>>> xa_lock(&cache->reqs);
>>> - req = xas_find_marked(&xas, UINT_MAX, CACHEFILES_REQ_NEW);
>>> - if (!req && cache->req_id_next > 0) {
>>> - xas_set(&xas, 0);
>>> - req = xas_find_marked(&xas, cache->req_id_next - 1,
>>> CACHEFILES_REQ_NEW);
>>> +retry:
>>> + xas_for_each_marked(&xas, req, xa_max, CACHEFILES_REQ_NEW) {
>>> + if (cachefiles_ondemand_skip_req(req))
>>> + continue;
>>> + break;
>>> }
>>> if (!req) {
>>> + if (cache->req_id_next > 0 && xa_max == ULONG_MAX) {
>>> + xas_set(&xas, 0);
>>> + xa_max = cache->req_id_next - 1;
>>> + goto retry;
>>> + }
>>
>> I would suggest abstracting the "xas_for_each_marked(...,
>> CACHEFILES_REQ_NEW)" part into a helper function to avoid the "goto
>> retry".
>>
> Hi JingBo,
>
> Thanks for your advice. Are the following revises appropriate?
>
> static struct cachefiles_req *cachefiles_ondemand_select_req(struct
> xa_state *xas, unsigned long xa_max)
> {
> struct cachefiles_req *req;
> struct cachefiles_ondemand_info *info;
>
> xas_for_each_marked(xas, req, xa_max, CACHEFILES_REQ_NEW) {
> if (!req || req->msg.opcode != CACHEFILES_OP_READ)
xas_for_each_marked() will guarantee that @req won't be NULL, and thus
the NULL check here in unnecessary. Otherwise LGTM.
> return req;
> info = req->object->private;
> if (info->state == CACHEFILES_ONDEMAND_OBJSTATE_close) {
> cachefiles_ondemand_set_object_reopening(req->object);
> queue_work(fscache_wq, &info->work);
> continue;
> } else if (info->state == CACHEFILES_ONDEMAND_OBJSTATE_reopening) {
> continue;
> }
> return req;
> }
> return NULL;
> }
>
> ...
>
> xa_lock(&cache->reqs);
> req = cachefiles_ondemand_select_req(&xas, ULONG_MAX);
> if (!req && cache->req_id_next > 0) {
> xas_set(&xas, 0);
> req = cachefiles_ondemand_select_req(&xas, cache->req_id_next - 1);
> }
> if (!req) {
> xa_unlock(&cache->reqs);
> return 0;
> }
>>
--
Thanks,
Jingbo
next prev parent reply other threads:[~2022-10-13 1:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 13:15 [PATCH 0/5] Introduce daemon failover mechanism to recover from crashing Jia Zhu
2022-10-11 13:15 ` [PATCH 1/5] cachefiles: introduce object ondemand state Jia Zhu
2022-10-11 13:15 ` [PATCH 2/5] cachefiles: extract ondemand info field from cachefiles_object Jia Zhu
2022-10-11 13:15 ` [PATCH 3/5] cachefiles: resend an open request if the read request's object is closed Jia Zhu
2022-10-12 7:53 ` JeffleXu
2022-10-12 15:37 ` [External] " Jia Zhu
2022-10-13 1:47 ` JeffleXu [this message]
2022-10-11 13:15 ` [PATCH 4/5] cachefiles: narrow the scope of triggering EPOLLIN events in ondemand mode Jia Zhu
2022-10-11 13:15 ` [PATCH 5/5] cachefiles: add restore command to recover inflight ondemand read requests Jia Zhu
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=3051133b-1408-2ccb-b22f-e5ee990bdc4f@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=dhowells@redhat.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
--cc=yinxin.x@bytedance.com \
--cc=zhujia.zj@bytedance.com \
/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
Powered by JetHome