Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp54141lfe; Fri, 15 Apr 2022 19:09:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxQHsUJqpAnc7rkcV2RGcgnc00K6U9gY8k/pfqqxgsh2PYaEJki5KWh0H1pRY3whGeD/0X X-Received: by 2002:a65:55c4:0:b0:381:71f9:cd35 with SMTP id k4-20020a6555c4000000b0038171f9cd35mr1342596pgs.94.1650074970941; Fri, 15 Apr 2022 19:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650074970; cv=none; d=google.com; s=arc-20160816; b=DTAXke+c+8TZ+4yoZUneiQ/wqR9+9S4joFQihEI7TvP8uLlriPjTw4HnYH1XVQSiRF WMcBG74O+XH/3xJMz4C8UoBhFiRPeW0U7Rezx2A+XSC6A/WWHkgLrHnyP7t+veSJ3tEB 6KMUy7hRvz3A8xCvoWmfCMtC48Bf6yXGvgUNj+VgGGDEcfYo+TGW5+Qye5DcsyneChLe JtKB+iANI8fiz6POKiEBFia26xcn+kbRciV3vryTtAdpvGJ/qJB1y/JsxMMctW37SVH4 lCNcSpa1mje018m93UnBjvmHCB5wukxy/AhOtq/+tF6XOmA5nbglixa0JHj3rw2GJ4j+ EygA== 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=TJajwpgWUykxkfmKFI63S/9a/APM2+sCO9EyW05IWJI=; b=E9StwMQIHJ5DRPkIrJtimM3o5rqmo7V/bhgnRAbSkEw/WVxLwRtt9oPmBYAqZdT2ms KiNe8R2ve4AKQxX+4QTvLKTCaSXmPlFxF4SIE9dwXhQb82ZV1sazqygjuLC3Oq07+Hxx 8oO6PHmXJH6wjClSCefMlhE9Ej6erAsoM1b7fYnJ4zjjw5gVm+ix2Ua3IqH0vcRBMi5a m+xAHX9QEn+So5capv6wa2LfDKoF3kEyPObkJtf5sHDRwji88ttScJKi79O654mpGqlC zFWgyc3R8vIToE7kqyBYX8Qyo7YIaLPRZohJgebM3mV44oiKP9d7V22wnmgjJFDaLPUd aP1A== 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 j126-20020a625584000000b004fa7c00d299si2818044pfb.139.2022.04.15.19.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:09:30 -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 AF2D0141449; Fri, 15 Apr 2022 18:27:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345879AbiDOMjn (ORCPT + 99 others); Fri, 15 Apr 2022 08:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350256AbiDOMjZ (ORCPT ); Fri, 15 Apr 2022 08:39:25 -0400 Received: from out199-7.us.a.mail.aliyun.com (out199-7.us.a.mail.aliyun.com [47.90.199.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29A383389C; Fri, 15 Apr 2022 05:36:31 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R761e4;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=19;SR=0;TI=SMTPD_---0VA7Ug.q_1650026184; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VA7Ug.q_1650026184) by smtp.aliyun-inc.com(127.0.0.1); Fri, 15 Apr 2022 20:36:25 +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 Subject: [PATCH v9 06/21] cachefiles: enable on-demand read mode Date: Fri, 15 Apr 2022 20:35:59 +0800 Message-Id: <20220415123614.54024-7-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220415123614.54024-1-jefflexu@linux.alibaba.com> References: <20220415123614.54024-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 ++++++++----- fs/cachefiles/io.c | 11 ----------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 2e946e4eb65a..c8bde21ace6a 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -758,11 +758,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; @@ -774,6 +769,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) { /* diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c index ccf77a969653..000a28f46e59 100644 --- a/fs/cachefiles/io.c +++ b/fs/cachefiles/io.c @@ -95,7 +95,6 @@ static int cachefiles_read(struct netfs_cache_resources *cres, file, file_inode(file)->i_ino, start_pos, len, i_size_read(file_inode(file))); -retry: /* If the caller asked us to seek for data before doing the read, then * we should do that now. If we find a gap, we fill it with zeros. */ @@ -120,16 +119,6 @@ static int cachefiles_read(struct netfs_cache_resources *cres, if (read_hole == NETFS_READ_HOLE_FAIL) goto presubmission_error; - if (read_hole == NETFS_READ_HOLE_ONDEMAND) { - ret = cachefiles_ondemand_read(object, off, len); - if (ret) - goto presubmission_error; - - /* fail the read if no progress achieved */ - read_hole = NETFS_READ_HOLE_FAIL; - goto retry; - } - iov_iter_zero(len, iter); skipped = len; ret = 0; -- 2.27.0