Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1049430pxb; Wed, 6 Apr 2022 07:32:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlpFvWRyGDDZrszhasiMEZc2GfGG6XGs+tjtyzb2iw0ALc/sdiyv9uK08TuC62TcIeOZDf X-Received: by 2002:a05:6a00:14d5:b0:4fb:2adf:dcdd with SMTP id w21-20020a056a0014d500b004fb2adfdcddmr9230452pfu.72.1649255537747; Wed, 06 Apr 2022 07:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649255537; cv=none; d=google.com; s=arc-20160816; b=kfVcVaoa8OBC7xkFjmbpYUyCgm2Fx9UFRt1ZOMpPylIRnRk4rKXrB6tLwVmM/4y6xC zYY8gsqtLVNkD/uF9u3BpnbOk/60mIgQNfZ/PA4sz86egicwtgd9xOFA8dJKXc9r/MXK rVgt2VWrlJqf6XVMvL9dxy7VFh/CZRHRhz1T0/PJwyVhnoz/G1n4PS8pNpxqsRyqRhUk 2aaTK3bUH+xFZy32ZgolW4VYzCvHxwiUPKtVGjDi+1Uqrz/HV7b8F4dGNNjYr7kya+ZH aX2CcSine9fwVJUTQhP2PcgpZGAf9W05xL1Cv1pCVKxFR9htqHghbCdOHJ1Lan0qqJQk qZTA== 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=w9lyBorGotnguDzSq8J4s1dfD1CmtJBSmazvcxBF0E/AchXWDJHQvI5y+Qkju3rPVo 4D5oujgTKhZwgvKX7CJxh3hj0dsZjvhIsaKGRYVzrV5y0BoVfldXaqZ39lxXu8vbRR9R lEdqzm3KyWpSQtu8KSiQojH7CF/FtLR6UF1WBeaYpeXqxZuMg+NKGAk6j8pW5ylj5ffm YjnH5tuoqFXD+UGS3ZT50Ky7BobpbR0LjlE0yl56cQCAYvpMLLBuh/VV4Z2tY15cbsyn DIBkc7wCLi4IIqovlpx4XCzwGY9d8UytMhgRTNS5qLAQ44eMIZonuAhEjwdowOv8+fgh 51JA== 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 i18-20020a170902c95200b00155c6577751si17814845pla.33.2022.04.06.07.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:32:17 -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 5235856339C; Wed, 6 Apr 2022 05:13:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231556AbiDFMPR (ORCPT + 99 others); Wed, 6 Apr 2022 08:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231205AbiDFMOD (ORCPT ); Wed, 6 Apr 2022 08:14:03 -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 D32E1127592; Wed, 6 Apr 2022 00:56:28 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;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=18;SR=0;TI=SMTPD_---0V9LC84J_1649231782; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V9LC84J_1649231782) by smtp.aliyun-inc.com(127.0.0.1); Wed, 06 Apr 2022 15:56:23 +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 v8 06/20] cachefiles: enable on-demand read mode Date: Wed, 6 Apr 2022 15:55:58 +0800 Message-Id: <20220406075612.60298-7-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220406075612.60298-1-jefflexu@linux.alibaba.com> References: <20220406075612.60298-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 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