Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2154967pxb; Fri, 25 Mar 2022 12:04:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaCQK4xtTjatSR06bKNj4ZrRMSmGU1mGQtc3VryBiA8smkTcLtA2CQ4bwx+9pHzb0oUb6+ X-Received: by 2002:a17:90a:4882:b0:1c5:f4e2:989a with SMTP id b2-20020a17090a488200b001c5f4e2989amr14422158pjh.160.1648235067563; Fri, 25 Mar 2022 12:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648235067; cv=none; d=google.com; s=arc-20160816; b=nebdMN8bzkgch6Ufc8KoLVdYiOw1n4F01yx59Yag9C5XLIMpxA1PklKEvdPNQHsKza Yvza2Pa2btgh7lTlz6+0A1mZbjJRmoZmmsji4YoYC8/50Xxyw6gMM6u7wirHGyAT13qP eUSniUZ5aOMRrNrzppxv9E2AFSEFTnfLJnBYqaBW34078ioOVGTCURpgkM63QUiiNybT fUU7tsVtqLIV90qu3fCm2xPX6JZ3LiQhOVK2TB8bCHn+LKXAYgv5BV452Lmi10iWvEXb Miv1QBTVTLOjjcLFrA/dFOYKlX8+v1b8Klfx3yxUgpG0KxdIzkfTWGwRY423B72qFr6X nI6Q== 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=5epBzcxUldde7tXVQkCShS6YBiDg29aBUG2fDBbkEdY=; b=a4AxtclcIiYgDns8AR0shQpeX4HPWWMVJO3XSUY2yoPcD30ANh9+sDHrWGqFmOZBLC 7NyVkXiarVvUAKtCWuREz7Pz6xhhvyajcZMYOzuWG5AMcc7KngYtkLPGN1cim13q7PKj +6vgt8Xv37pTEi74VK9VHpeSQi1H1RAH8yM8DklfGJ2CW6rDKJbii1b13Fz1FCNXYJFU L2EXtggMqLLo81mrzbobaP3eUElU34xTOdb1o5Q6xOYn00yh+H7HVQW1YhQ9dPPUXmnB EyCG3y2ZJGA/ekptQwEv5j9dOkjUreU7CoGGS8KXX0rBsvuhRRoGSeulxHManOuthlcs LLKw== 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 k35-20020a63ff23000000b003816043f094si3118306pgi.649.2022.03.25.12.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:04:27 -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 A0F9E1F1D2D; Fri, 25 Mar 2022 11:12:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356557AbiCYMZT (ORCPT + 99 others); Fri, 25 Mar 2022 08:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359059AbiCYMYp (ORCPT ); Fri, 25 Mar 2022 08:24:45 -0400 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15329D5EBC; Fri, 25 Mar 2022 05:22:51 -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=e01e04407;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0V89zY3j_1648210967; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V89zY3j_1648210967) by smtp.aliyun-inc.com(127.0.0.1); Fri, 25 Mar 2022 20:22:48 +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 15/22] erofs: register cookie context for bootstrap blob Date: Fri, 25 Mar 2022 20:22:16 +0800 Message-Id: <20220325122223.102958-16-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 Registers fscache_cookie for the bootstrap blob file. The bootstrap blob file can be specified by a new mount option, which is going to be introduced by a following patch. Something worth mentioning about the cleanup routine. 1. The init routine is prior to when the root inode gets initialized, and thus the corresponding cleanup routine shall be placed inside .kill_sb() callback. 2. The init routine will instantiate anonymous inodes under the super_block, and thus .put_super() callback shall also contain the cleanup routine. Or we'll get "VFS: Busy inodes after unmount." warning. Signed-off-by: Jeffle Xu --- fs/erofs/internal.h | 3 +++ fs/erofs/super.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 459f31803c3b..d8c886a7491e 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -73,6 +73,7 @@ struct erofs_mount_opts { /* threshold for decompression synchronously */ unsigned int max_sync_decompress_pages; #endif + char *tag; unsigned int mount_opt; }; @@ -151,6 +152,8 @@ struct erofs_sb_info { /* sysfs support */ struct kobject s_kobj; /* /sys/fs/erofs/ */ struct completion s_kobj_unregister; + + struct erofs_fscache *bootstrap; }; #define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 798f0c379e35..de5aeda4aea0 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -598,6 +598,16 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) sbi->devs = ctx->devs; ctx->devs = NULL; + if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && erofs_is_nodev_mode(sb)) { + struct erofs_fscache *bootstrap; + + bootstrap = erofs_fscache_get(sb, ctx->opt.tag, true); + if (IS_ERR(bootstrap)) + return PTR_ERR(bootstrap); + + sbi->bootstrap = bootstrap; + } + err = erofs_read_superblock(sb); if (err) return err; @@ -753,6 +763,7 @@ static void erofs_kill_sb(struct super_block *sb) return; erofs_free_dev_context(sbi->devs); + erofs_fscache_put(sbi->bootstrap); fs_put_dax(sbi->dax_dev); kfree(sbi); sb->s_fs_info = NULL; @@ -771,6 +782,12 @@ static void erofs_put_super(struct super_block *sb) iput(sbi->managed_cache); sbi->managed_cache = NULL; #endif + erofs_fscache_put(sbi->bootstrap); + /* + * Set sbi->bootstrap to NULL, so that the following cleanup routine + * inside .kill_sb() could be skipped then. + */ + sbi->bootstrap = NULL; } static struct file_system_type erofs_fs_type = { -- 2.27.0