Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4864814iob; Mon, 9 May 2022 03:32:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU+bYkJQ8NdkL9iKqGIeL23b1idoUwCR+hJSbXhjg1v3Tq9YO6BycCqyJYXRJ7JbN3DQyb X-Received: by 2002:a05:6638:d0a:b0:32b:b579:6875 with SMTP id q10-20020a0566380d0a00b0032bb5796875mr7086949jaj.291.1652092335910; Mon, 09 May 2022 03:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652092335; cv=none; d=google.com; s=arc-20160816; b=lDOzjA4OWyB+VHkEqse09uscM+Kw0Y0BiuuiYTgIFG0rE4K34PB4Sc83m3UMZjEv8E LZEzc4pw1N5EzNWot7wZuHzLysnjeG2u1u/sdLLFKeb13fPJhgLCUcADPdNJberLjTUc 6lx9LPaaCmIRXVssJ10VijNa1PvQJlDaorj4Nd4DiyZjtTjChtLr9ehixF3LO4nGwTLb IloOJsPxKl4UCYvD/McCght8kw7qJJt2+Ah+x4chEuVVamlo6We8fb66RvZRIDG9ilHF UbIpC8tlN144T8ukSGgYaOrDbdXaqJrUvKTl2oyr/SSfm++1m04sXoeOSVU81unNtJLR 9Nvg== 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=wWY+hF5KqtlYdbaAHicEmA+TeScgCcZgfrBBiJX7abp+NC7pnosWtrVtRsun3Si2Kx iC6+U5en5ZyD7hKCmy1ZIUqfM5ePscN54AlGzxNX7rXvKrEQxD+7fECCpXB6D9DUlHdr JK02/Ean0/ItxjRB0Et7ihm4qAAAes8FaRQf7yd2Z0mLDWrgXfOl21sxQOrv4zlZww+n 2uijKRuvP5pQ6mrGYSPtzDSbHXqtCb3TSoUD9UV3E5C8HWkKtze5SHBR3gBTw4wNESnq vKa+dmuU3Yw6C2TCUDGR4XE5mZ2fvhtPGG/2jPpgox5QCXp+GwDnuEcLT55e5PWFUBl0 cC3Q== 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:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s4-20020a02c504000000b003266326586dsi7313990jam.145.2022.05.09.03.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 03:32:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 45DF3200F4E; Mon, 9 May 2022 03:02:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236724AbiEIHxv (ORCPT + 99 others); Mon, 9 May 2022 03:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234913AbiEIHox (ORCPT ); Mon, 9 May 2022 03:44:53 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D549C17050; Mon, 9 May 2022 00:40:58 -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=e01e04394;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0VCgwz9P_1652082038; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VCgwz9P_1652082038) by smtp.aliyun-inc.com(127.0.0.1); Mon, 09 May 2022 15:40:39 +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, yinxin.x@bytedance.com, zhangjiachen.jaycee@bytedance.com, zhujia.zj@bytedance.com Subject: [PATCH v11 06/22] cachefiles: enable on-demand read mode Date: Mon, 9 May 2022 15:40:12 +0800 Message-Id: <20220509074028.74954-7-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220509074028.74954-1-jefflexu@linux.alibaba.com> References: <20220509074028.74954-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 | 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