Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2149562pxb; Fri, 25 Mar 2022 11:59:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8C1bHb9wdDCeyTVwpJO871Zh7Eibk7lwxf1JqWoDfahao4SKRzqaENM4xQFC9rnFuvwxB X-Received: by 2002:a17:90b:4b02:b0:1c7:1bc3:690b with SMTP id lx2-20020a17090b4b0200b001c71bc3690bmr26563078pjb.174.1648234755444; Fri, 25 Mar 2022 11:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648234755; cv=none; d=google.com; s=arc-20160816; b=CMB+7Bh4SjyzgyFfCAWnf4Obe355sRKCOC/g5MDmP7UYt/ooZyzjwWxsnzCI7Y7NUq tT4fTMhxgI5elFnVKHrtYvK7gIvVtJpoiNu2Z0L831PHbUslwl1I9k77uSXSaJJ3RoHK aGApQyg9aHQlt/fStbFmGhSdGGd94ER/0YC5gkHdsgCvYlKEDKQFDDAzIbDBMz5TYdR/ vQm2uAp3Mfk5vZMnI0cJZfLrlwl6VyQRY0yeyAIqAOTS43ctICuOn03Ffopg4AFT3can b3I7sMOsZInEtxVCZUc506z3WsSg2dtQHlkqymZdyh/SRJvEsPNiZFMWNElUoMe81fpy i1yQ== 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=Pbg3cI+biOiX5nRG7EMJCzDjjrwwLWDl5yZCVvImzQ0=; b=JrFBcE2JAweDlcvSfBkgqTnFiFjLjGDXZX7+U9Ntsp6S8daUuG7hQLm6+oOB9pJqLQ jZuiMLIFd9YhlPEX5FXwqoKLePEVNHqwvHbO39XS8wehGbkc5X+JIrC7E1NZ1oxYygaG 2hZ6myv7vuh/NFoP+OUWpPpCiagpyl8DrXoHgpKv1FHJsAUwiPLQHFLjWKuzDdODHGoW ZkdlRswFaKnivJ9BpgXAV3yXQ3XTw2QhydMP3iXJHpMGpM1i3QYKCefPMTtixzwV9Ujc 1OYw3AR1RGPpXyt+bADFzuqYj027XwIInHgVbwhL+eRxo3usbaPAPf/KTuMHsTVk9Cke Mfdg== 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 b25-20020a656699000000b003816043eedbsi3099498pgw.208.2022.03.25.11.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:59:15 -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 109E41E376C; Fri, 25 Mar 2022 11:10:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359052AbiCYM0A (ORCPT + 99 others); Fri, 25 Mar 2022 08:26:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358987AbiCYMYP (ORCPT ); Fri, 25 Mar 2022 08:24:15 -0400 Received: from out199-14.us.a.mail.aliyun.com (out199-14.us.a.mail.aliyun.com [47.90.199.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 427D9D5561; Fri, 25 Mar 2022 05:22:39 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0V89qR-b_1648210953; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V89qR-b_1648210953) by smtp.aliyun-inc.com(127.0.0.1); Fri, 25 Mar 2022 20:22:34 +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 v6 06/22] cachefiles: enable on-demand read mode Date: Fri, 25 Mar 2022 20:22:07 +0800 Message-Id: <20220325122223.102958-7-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220325122223.102958-1-jefflexu@linux.alibaba.com> References: <20220325122223.102958-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 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 91b88a499737..2c38c5361bda 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -741,11 +741,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; @@ -757,6 +752,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