Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp293245pxb; Fri, 22 Apr 2022 00:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3niesBFJSMlhaUH5PJT0KzXxNtCd6oZIkBsJWlN8urb1O9w7SyhrRpvrtTXjsRAfUmEla X-Received: by 2002:a05:6402:34c9:b0:423:deb7:f69e with SMTP id w9-20020a05640234c900b00423deb7f69emr3412072edc.335.1650612597569; Fri, 22 Apr 2022 00:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650612597; cv=none; d=google.com; s=arc-20160816; b=AYeEaXwhjVB6cpI6iFmWn9tlkiu4muQ/Uy7nRnEmN2SBnKfuntUVZY65CF3ah4vyy0 9oBqiRa+FxZtZH5WnE8j5zu9W7sQjBkKyOcccJqFssuqWh/aCllQR8ASEXJjy37N8JmI zfWQ60SbFYnq1hn1TjcKJS3DFbIkLEloEjQMtauCnpM6vDZeqkLMbj3Rs65moZLxapCE gxrnRhG6iVZ2Xc1koiTTc6jyixMic8kaJtoSTN905xWHhw7Ttk7hUDp5SEkWUdoJP/Px As3SulIQ1gz5tTcCUGyR3jCkaDG3aS474HjTSTnpfidZ+YXl4ugnXiqBsrfdSRB8WckB kQhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=qwvPo6AiWd0sZ80m09JzwZ7IPi5G+1wyp9tYCPAND3w=; b=GfN+Vj/xEMeftq/n6U0TXKrfoxC2eWNd//I/G79973D9afr2tgYLAGQdM21H+ugrS6 ZkpxdoKqyDKKT4ulCzkS/yr4EWatx3EZK7yaoEY/FWVMtSvxGrbhObfhv7R756SL2bYx uC1TsgjWAzxMalRhNHFRWRhsNnsmmNLGpSkN1RBhHJdd2/B/iuVtaZ03AHq9gSxVqgcc +oL7sxvJ+nBMa4IDXI4QZF/pAXcozqPZNiJWd6M73dTLuyBgBLLgGiRGFqvnDEL2Peeg gee/zju6vBnhIcVMxo5j5H1Lb7g5igUp5zvg7pBE/7kjFQs3+x1Rmmug1J+j9ShsaM0g sERw== 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 a1-20020a1709066d4100b006eff1450aebsi5335640ejt.691.2022.04.22.00.29.33; Fri, 22 Apr 2022 00:29:57 -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 S1386247AbiDUH4D (ORCPT + 99 others); Thu, 21 Apr 2022 03:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356531AbiDUH4C (ORCPT ); Thu, 21 Apr 2022 03:56:02 -0400 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E244DFB3; Thu, 21 Apr 2022 00:53:13 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0VAdmSw9_1650527585; Received: from B-P7TQMD6M-0146.local(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VAdmSw9_1650527585) by smtp.aliyun-inc.com(127.0.0.1); Thu, 21 Apr 2022 15:53:08 +0800 Date: Thu, 21 Apr 2022 15:53:05 +0800 From: Gao Xiang To: Jeffle Xu Cc: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, 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: Re: [PATCH v9 10/21] erofs: add fscache mode check helper Message-ID: Mail-Followup-To: Jeffle Xu , dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, 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 References: <20220415123614.54024-1-jefflexu@linux.alibaba.com> <20220415123614.54024-11-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220415123614.54024-11-jefflexu@linux.alibaba.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,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 On Fri, Apr 15, 2022 at 08:36:03PM +0800, Jeffle Xu wrote: > Until then erofs is exactly blockdev based filesystem. > > A new fscache-based mode is going to be introduced for erofs to support > scenarios where on-demand read semantics is needed, e.g. container > image distribution. In this case, erofs could be mounted from data blobs > through fscache. > > Add a helper checking which mode erofs works in, and twist the code in > prep for the following fscache mode. in preparation for the upcoming fscache mode. > > Signed-off-by: Jeffle Xu Reviewed-by: Gao Xiang Thanks, Gao Xiang > --- > fs/erofs/internal.h | 5 +++++ > fs/erofs/super.c | 44 +++++++++++++++++++++++++++++--------------- > 2 files changed, 34 insertions(+), 15 deletions(-) > > diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > index fe9564e5091e..05a97533b1e9 100644 > --- a/fs/erofs/internal.h > +++ b/fs/erofs/internal.h > @@ -161,6 +161,11 @@ struct erofs_sb_info { > #define set_opt(opt, option) ((opt)->mount_opt |= EROFS_MOUNT_##option) > #define test_opt(opt, option) ((opt)->mount_opt & EROFS_MOUNT_##option) > > +static inline bool erofs_is_fscache_mode(struct super_block *sb) > +{ > + return IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && !sb->s_bdev; > +} > + > enum { > EROFS_ZIP_CACHE_DISABLED, > EROFS_ZIP_CACHE_READAHEAD, > diff --git a/fs/erofs/super.c b/fs/erofs/super.c > index 0c4b41130c2f..724d5ff0d78c 100644 > --- a/fs/erofs/super.c > +++ b/fs/erofs/super.c > @@ -259,15 +259,19 @@ static int erofs_init_devices(struct super_block *sb, > } > dis = ptr + erofs_blkoff(pos); > > - bdev = blkdev_get_by_path(dif->path, > - FMODE_READ | FMODE_EXCL, > - sb->s_type); > - if (IS_ERR(bdev)) { > - err = PTR_ERR(bdev); > - break; > + if (!erofs_is_fscache_mode(sb)) { > + bdev = blkdev_get_by_path(dif->path, > + FMODE_READ | FMODE_EXCL, > + sb->s_type); > + if (IS_ERR(bdev)) { > + err = PTR_ERR(bdev); > + break; > + } > + dif->bdev = bdev; > + dif->dax_dev = fs_dax_get_by_bdev(bdev, > + &dif->dax_part_off); > } > - dif->bdev = bdev; > - dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off); > + > dif->blocks = le32_to_cpu(dis->blocks); > dif->mapped_blkaddr = le32_to_cpu(dis->mapped_blkaddr); > sbi->total_blocks += dif->blocks; > @@ -586,21 +590,28 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) > > sb->s_magic = EROFS_SUPER_MAGIC; > > - if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) { > - erofs_err(sb, "failed to set erofs blksize"); > - return -EINVAL; > - } > - > sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); > if (!sbi) > return -ENOMEM; > > sb->s_fs_info = sbi; > sbi->opt = ctx->opt; > - sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->dax_part_off); > sbi->devs = ctx->devs; > ctx->devs = NULL; > > + if (erofs_is_fscache_mode(sb)) { > + sb->s_blocksize = EROFS_BLKSIZ; > + sb->s_blocksize_bits = LOG_BLOCK_SIZE; > + } else { > + if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) { > + erofs_err(sb, "failed to set erofs blksize"); > + return -EINVAL; > + } > + > + sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev, > + &sbi->dax_part_off); > + } > + > err = erofs_read_superblock(sb); > if (err) > return err; > @@ -857,7 +868,10 @@ static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf) > { > struct super_block *sb = dentry->d_sb; > struct erofs_sb_info *sbi = EROFS_SB(sb); > - u64 id = huge_encode_dev(sb->s_bdev->bd_dev); > + u64 id = 0; > + > + if (!erofs_is_fscache_mode(sb)) > + id = huge_encode_dev(sb->s_bdev->bd_dev); > > buf->f_type = sb->s_magic; > buf->f_bsize = EROFS_BLKSIZ; > -- > 2.27.0