Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3426782ioa; Tue, 26 Apr 2022 03:32:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMxE2rTwkxhMJdA4WOc0aZkh812f0f7bZxvJJRDqRRAwAWvFSxZGTulLF9cDcr+DfeKy8P X-Received: by 2002:a17:906:2709:b0:6f0:13d5:d58f with SMTP id z9-20020a170906270900b006f013d5d58fmr20548319ejc.443.1650969151828; Tue, 26 Apr 2022 03:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650969151; cv=none; d=google.com; s=arc-20160816; b=hWuXWXONFYQyd3eEDwd7+NF9e4L4PS30tttK05j9Whrfo72n/U9KuG9gHFLZsDh292 GsrokbvADmgIL5jzopM2tguqjq43siZj0+fEBm1IDSu/8bbSVw5ngQcesNNY6mVeOxQ9 t/ccTQpjxiDYqA7BEr+syGCFget7T/DiHwhQLUIwLZGbREmi4wyi9IHiMfnY/135KZHl OHCGyzjnC2d+bxPB5pwfuDr345YFWoSQhwaHWSuHQ+L2pJxOjIoZIiqlqwLkOkIUrMh/ 6m3OqjhXaETWn2xwExKN2cpgfyDW+hdXipCwQFTTrlEqRA62t9p7nLjS8NUS50Z6EDiT ca9A== 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=hvbxNtivR7F7u1WyNo7+0j6hWHDXWkYNn3hgD+Cn7xA=; b=yOvbQ0UsM6ZbbxIhTLuW9nDlkktdU+lq7c0OkOMwEZvxYBn6z12k+t5kUyRDHEelx8 fZoGbZVv71UU3cElNUCdvoPgsu6CB65tL8Iw8isL4RvhUIPPAt6zD7y8Dd7daFd0947Y Nxii73xnkoZwj3X/+gS7mILPrFYuUPiuSUmXw14fQ+I+RFQj4OkTOHgEa8GI9AJbZ/aH ooBAV04+LVt3ubXpHBjNiGOt0A5pm3A3pPpIJxKutMFuOsXvG69nWwVxa6/EIyDV/+f2 lNOK4CqOAAifWCsLjZ5T8d5y5l4lFeRBgLmJbEoFreys/6VNKsq4OQBBVWZXXG6OKh/4 4gqw== 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 g18-20020a1709065d1200b006f39f122fbbsi4099540ejt.900.2022.04.26.03.32.08; Tue, 26 Apr 2022 03:32: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; 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 S240958AbiDYMZi (ORCPT + 99 others); Mon, 25 Apr 2022 08:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239940AbiDYMZQ (ORCPT ); Mon, 25 Apr 2022 08:25:16 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A096460A8C; Mon, 25 Apr 2022 05:21:58 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R531e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0VBG8mfh_1650889313; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VBG8mfh_1650889313) by smtp.aliyun-inc.com(127.0.0.1); Mon, 25 Apr 2022 20:21:54 +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, zhangjiachen.jaycee@bytedance.com, zhujia.zj@bytedance.com Subject: [PATCH v10 06/21] cachefiles: enable on-demand read mode Date: Mon, 25 Apr 2022 20:21:28 +0800 Message-Id: <20220425122143.56815-7-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220425122143.56815-1-jefflexu@linux.alibaba.com> References: <20220425122143.56815-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,SPF_HELO_NONE,SPF_PASS, 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 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 5b1d0642c749..aa4efcabb5e3 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -755,11 +755,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; @@ -771,6 +766,18 @@ static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) return -EBUSY; } + if (IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND)) { + if (!strcmp(args, "ondemand")) { + set_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags); + } else if (*args) { + pr_err("Invalid argument to the 'bind' command\n"); + return -EINVAL; + } + } 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