Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp376083pxb; Thu, 31 Mar 2022 07:26:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPQ6SRKT7aePZEG5+2QM1ZskzeSsCOQ0CX6Gz0FAbRq6MrMwvFTmcuNJMW464p0zmYxGkY X-Received: by 2002:aa7:c683:0:b0:418:f5f3:9684 with SMTP id n3-20020aa7c683000000b00418f5f39684mr16925876edq.184.1648736778891; Thu, 31 Mar 2022 07:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648736778; cv=none; d=google.com; s=arc-20160816; b=ovh8Al2msRfXYJSbJffEA1zv4woftFzpWT8YT87MPALbB5zgWKh9XPlcSkEEPbCzkp jdMS6DcFsfgl8M/yNJnbj3ijt6oxq+WAmK3fbIC22kVUB3GOjZ5X8E/C4569alPQyGsb 6NNcd4Q9fv+JI6OHjF20LsNCCCj6OE1ICcAYuLQzlzS+h/cVHqMZFow96unuE5zUeSUn +VGWNLf3+SChFLVJ/UcyMgtIqnuLsTFfIGSbYRe/C+295JtdxGvvBvWTDh5cLnGkCdYg QdoUVrEHB//RGfO6yBlCJYmzoHj8/Jg4T35x4J/kS5kt/DQ54dFSs5FwHiOPcgR5xAao Xb+Q== 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; bh=BHGkf3XeLjTusAiXrB1o8IbqG0nJiVGcAjtNDR1dYWY=; b=w/3frMRr+cGaUtLOV8btJEXnL8UTkQ11TkqhIcHd9ssMJROLDUCnszj1x8cY7DdJpd VTYQKYJREXMWhxJMgo5JXA+/utWkbvZw1m8VYba2jyOPDRMML7v6YItrrNdMh2/LIhC9 qPw794DHRoI2sIkvGuPDAntmVbSWwuRqVarNKEu3R8So02q1YMEKygwsvVuZWs3VPjbM qJU2BFcOLxTNh7uLtfKdJSQ950vPzkiROulXyMSyIvqi4wKrc9/THf9i+gX+hHFFtYxj 0WtXz6qof9LSaHVaXkBsC2UDUmfmjdm/+x1ZDtl9/hTs84vzEDcAh7sfEbEibVPogJXi pyxw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l23-20020a056402125700b00418c2b5bdd3si24034778edw.181.2022.03.31.07.25.51; Thu, 31 Mar 2022 07:26:18 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235436AbiCaMAT (ORCPT + 99 others); Thu, 31 Mar 2022 08:00:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235384AbiCaL7w (ORCPT ); Thu, 31 Mar 2022 07:59:52 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9836A208C26; Thu, 31 Mar 2022 04:58:05 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0V8imT7F_1648727881; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V8imT7F_1648727881) by smtp.aliyun-inc.com(127.0.0.1); Thu, 31 Mar 2022 19:58:02 +0800 From: Jeffle Xu To: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: 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, tianzichen@kuaishou.com, fannaihao@baidu.com Subject: [PATCH v7 05/19] cachefiles: enable on-demand read mode Date: Thu, 31 Mar 2022 19:57:39 +0800 Message-Id: <20220331115753.89431-6-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220331115753.89431-1-jefflexu@linux.alibaba.com> References: <20220331115753.89431-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 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. Signed-off-by: Jeffle Xu --- fs/cachefiles/daemon.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index d155a6da90d3..bd902a4c4cd8 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -738,11 +738,6 @@ static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) cache->brun_percent >= 100) return -ERANGE; - if (*args) { - pr_err("'bind' command doesn't take an argument\n"); - return -EINVAL; - } - if (!cache->rootdirname) { pr_err("No cache directory specified\n"); return -EINVAL; @@ -754,6 +749,14 @@ static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) return -EBUSY; } + if (IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND) && + !strcmp(args, "ondemand")) { + set_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags); + } else if (*args) { + pr_err("'bind' command doesn't take an argument\n"); + return -EINVAL; + } + /* Make sure we have copies of the tag string */ if (!cache->tag) { /* -- 2.27.0