Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2261310pxp; Mon, 21 Mar 2022 15:14:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7KtGIF96+A/pbIP2E8/wOR6SnJwtuxP5wRQOR+Av0rI1RYwm5LoByCcJzcQVmVk8P4AkU X-Received: by 2002:a17:90b:4f8e:b0:1c7:3652:21bc with SMTP id qe14-20020a17090b4f8e00b001c7365221bcmr1400235pjb.38.1647900854972; Mon, 21 Mar 2022 15:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647900854; cv=none; d=google.com; s=arc-20160816; b=SB5k42cFzxoOZjXm5MHYt/jUM02yDkDZUysuu4IrH58sXdA8+79mu8sGAY97UDfIch zFcn8k9GavuIOSG3ndWjCLabHZ1FwtaA6ROluKvO0P8Q65eITfnNXMPg+tQVpsg8IZpD /iRwAgnVBWZv1dq53tlYzByg9klnAtxdpNelcSyKm5W7a9XRVRdeYP7cCnRQHmjfzJhN 6xuiNDXSri7uGDIpTExDd3ud/HJSdROOICNxwPzJicrfg3XQY193fHXmMCdKXW73iaa0 1p7RQcsQj8CxQt/LftlxWKBZdKxcYbguft7ZM7v+UWsqBdoHI/PryQ3qR/8zrB3gBwy+ QdDA== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=vnrgGfjmMQgFQ3vvjOVGG8o3Y+EwzQ0BEwnxyxKrpg0=; b=gcElr8+aDZKxmOhVRhE3EUOSmw5nQ0G/nS0aXiTpAuA7Cimw2uKRxmMW3RHyQ0gj0p gZUUE2iE847RQ5sRAhjXbzpsLR2/lUOaJHHuUsM2oLz91nqJcefMYJnbRD5q0lw1xDle HyyrDe7qTjRkvA8i9ScekP8PHNXb/nSUKy9Z2cXVAukzJ0hKK2xi+S3jGD8EhA/PbfV/ vb3s5tCo9tkvhr2V7QPUYUI/w5Xl78wDpIiB8Ods1I8A7neTUV+mrztJHTQO6EbkOP9P uI+8OQqcmxM+IX826CF8uj1eIR4Ojb2TRnSLJ+AFwUluM4x6C93V9s1GoTuQ0vJOFJuu jCSg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bg6-20020a056a02010600b003816043ef48si17375226pgb.317.2022.03.21.15.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:14:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A188361AB1; Mon, 21 Mar 2022 14:32:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345218AbiCUOZK (ORCPT + 99 others); Mon, 21 Mar 2022 10:25:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352856AbiCUOXI (ORCPT ); Mon, 21 Mar 2022 10:23:08 -0400 Received: from out199-4.us.a.mail.aliyun.com (out199-4.us.a.mail.aliyun.com [47.90.199.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88201AF51C; Mon, 21 Mar 2022 07:17:23 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R431e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0V7rRN9d_1647872182; Received: from 192.168.31.65(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V7rRN9d_1647872182) by smtp.aliyun-inc.com(127.0.0.1); Mon, 21 Mar 2022 22:16:23 +0800 Message-ID: Date: Mon, 21 Mar 2022 22:16:22 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v5 03/22] cachefiles: introduce on-demand read mode Content-Language: en-US To: David Howells Cc: linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, torvalds@linux-foundation.org, gregkh@linuxfoundation.org, willy@infradead.org, linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org, luodaowen.backend@bytedance.com References: <20220316131723.111553-4-jefflexu@linux.alibaba.com> <20220316131723.111553-1-jefflexu@linux.alibaba.com> <1027872.1647869684@warthog.procyon.org.uk> From: JeffleXu In-Reply-To: <1027872.1647869684@warthog.procyon.org.uk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 Hi, Thanks for reviewing. On 3/21/22 9:34 PM, David Howells wrote: > Jeffle Xu wrote: > >> Fscache/cachefiles used to serve as a local cache for remote fs. This >> patch, along with the following patches, introduces a new on-demand read >> mode for cachefiles, which can boost the scenario where on-demand read >> semantics is needed, e.g. container image distribution. >> >> The essential difference between the original mode and on-demand read >> mode is that, in the original mode, when cache miss, netfs itself will >> fetch data from remote, and then write the fetched data into cache file. >> While in on-demand read mode, a user daemon is responsible for fetching >> data and then writing to the cache file. >> >> This patch only adds the command to enable on-demand read mode. An optional >> parameter to "bind" command is added. On-demand mode will be turned on when >> this optional argument matches "ondemand" exactly, i.e. "bind >> ondemand". Otherwise cachefiles will keep working in the original mode. > > You're not really adding a command, per se. Also, I would recommend > starting the paragraph with a verb. How about: > > Make it possible to enable on-demand read mode by adding an > optional parameter to the "bind" command. On-demand mode will be > turned on when this parameter is "ondemand", i.e. "bind ondemand". > Otherwise cachefiles will work in the original mode. > > Also, I'd add a note something like the following: > > This is implemented as a variation on the bind command so that it > can't be turned on accidentally in /etc/cachefilesd.conf when > cachefilesd isn't expecting it. Alright, looks much better :) > >> The following patches will implement the data plane of on-demand read >> mode. > > I would remove this line. If ondemand mode is not fully implemented in > cachefiles at this point, I would be tempted to move this to the end of the > cachefiles subset of the patchset. That said, I'm not sure it can be made > to do anything much before that point. Alright. > >> +#ifdef CONFIG_CACHEFILES_ONDEMAND >> +static inline void cachefiles_ondemand_open(struct cachefiles_cache *cache) >> +{ >> + xa_init_flags(&cache->reqs, XA_FLAGS_ALLOC); >> + rwlock_init(&cache->reqs_lock); >> +} > > Just merge that into the caller. > >> +static inline void cachefiles_ondemand_release(struct cachefiles_cache *cache) >> +{ >> + xa_destroy(&cache->reqs); >> +} > > Ditto. > >> +static inline >> +bool cachefiles_ondemand_daemon_bind(struct cachefiles_cache *cache, char *args) >> +{ >> + if (!strcmp(args, "ondemand")) { >> + set_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags); >> + return true; >> + } >> + >> + return false; >> +} >> ... >> + if (!cachefiles_ondemand_daemon_bind(cache, args) && *args) { >> + pr_err("'bind' command doesn't take an argument\n"); >> + return -EINVAL; >> + } >> + > > I would merge these together, I think, and say something like "Ondemand > mode not enabled in kernel" if CONFIG_CACHEFILES_ONDEMAND=n. > The reason why I extract all these logic into small sized function is that, the **callers** can call cachefiles_ondemand_daemon_bind() directly without any clause like: ``` #ifdef CONFIG_CACHEFILES_ONDEMAND ... #else ... ``` Another choice is like ``` if (IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND)) ... else ... ``` -- Thanks, Jeffle