Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1071208pxb; Wed, 6 Apr 2022 08:04:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhyqXOCxK2CbKs5oWo7wMk4h6nnl7KNZ84xgPdOvMwwjfwgclZEt8YXuSXkI0zPk5cRysw X-Received: by 2002:aca:3643:0:b0:2ec:cb84:c5ba with SMTP id d64-20020aca3643000000b002eccb84c5bamr3832559oia.183.1649257439980; Wed, 06 Apr 2022 08:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649257439; cv=none; d=google.com; s=arc-20160816; b=HGy1yBjV70MZ9bJ3PeT6HNL6Quvc7LcXjsCrAGXObOLerYRSEb87fBHMtjEVBm/UGn x+KsRwMmGuEvnKZf82b3U4JVt8VVdg1POg4vxkmMvjt517awu1a8RjLKRW5dbNFfUhV/ RiDxoPNhK4c+BvatDzIc+OIaY7YQecWxoVpwX5IY9FTL/VPx50yFmaoLVNNHG+9WWtM2 N19s7Sj7/koR+JP2VrZrRGToHxKMgY0iVlLGJeGdxTIc4gdl0Hrwz6MaYMYdFt9Hsq1+ iHGW42ntYG265dAa6s9zlmHLrLpAgYru3XHopflO02JZJQe61SMezmZZLaYbRopE/oYi +CKQ== 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=X025ay26HZOFAU9dH/Ru7VEbEW9/ZZDaCp9qRvBJua4=; b=VbxJ0J6L4d6DB2r8u504JYYFg1ItfzpQO7aaPbl2r1b7vem1B2wQKvoVzIX32qyw+c Rtstplpx+5RSjP7EM7OafFd6r5Zk3uiqL1QlgRCfNHTGE7mODyIp2IozUNK8Um3jMB4q 4Dp5iE/2dmy+0t0SLIMxXyjvHHisA3p08PbF+BWWoA3FEOKTBpBhN7TcySiP8FkT7/Q3 cN9ikzQCZtQahMriTLXWzDyJTp0HyCF1/I7GUj1I9wXdgz+X0toMTaO5C78z2uZcv5Eh LM9TzW9nigjfeEbHhRwUJrcvYaPKzQaLyRdNwSt07FU4mDsQQz4TQam01JPHTK5QqxAt hNRg== 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 v22-20020a056870311600b000ddb0fad01asi10185061oaa.287.2022.04.06.08.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:03:59 -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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E1DE232D36; Wed, 6 Apr 2022 05:50:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230498AbiDFMQW (ORCPT + 99 others); Wed, 6 Apr 2022 08:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiDFMOb (ORCPT ); Wed, 6 Apr 2022 08:14:31 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B80F61480CF; Wed, 6 Apr 2022 00:56:39 -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=e01e04426;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0V9LC885_1649231794; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V9LC885_1649231794) by smtp.aliyun-inc.com(127.0.0.1); Wed, 06 Apr 2022 15:56:35 +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 14/20] erofs: register fscache context for primary data blob Date: Wed, 6 Apr 2022 15:56:06 +0800 Message-Id: <20220406075612.60298-15-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 Registers fscache context for primary data blob. Also move the initialization of s_op and related fields forward, since anonymous inode will be allocated under the super block when registering the fscache context. Something worth mentioning about the cleanup routine. 1. The fscache context will instantiate anonymous inodes under the super block. Release these anonymous inodes when .put_super() is called, or we'll get "VFS: Busy inodes after unmount." warning. 2. The fscache context is initialized prior to the root inode. If .kill_sb() is called when mount failed, .put_super() won't be called when root inode has not been initialized yet. Thus .kill_sb() shall also contain the cleanup routine. Signed-off-by: Jeffle Xu --- fs/erofs/internal.h | 1 + fs/erofs/super.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 3a4a344cfed3..eb37b33bce37 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -155,6 +155,7 @@ struct erofs_sb_info { /* fscache support */ struct fscache_volume *volume; + struct erofs_fscache *s_fscache; }; #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 6590ed1b7d3b..9498b899b73b 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -585,6 +585,9 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) int err; sb->s_magic = EROFS_SUPER_MAGIC; + sb->s_flags |= SB_RDONLY | SB_NOATIME; + sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_op = &erofs_sops; if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) { erofs_err(sb, "failed to set erofs blksize"); @@ -605,6 +608,11 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) err = erofs_fscache_register_fs(sb); if (err) return err; + + err = erofs_fscache_register_cookie(sb, &sbi->s_fscache, + sbi->opt.fsid, true); + if (err) + return err; } err = erofs_read_superblock(sb); @@ -619,11 +627,8 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) clear_opt(&sbi->opt, DAX_ALWAYS); } } - sb->s_flags |= SB_RDONLY | SB_NOATIME; - sb->s_maxbytes = MAX_LFS_FILESIZE; - sb->s_time_gran = 1; - sb->s_op = &erofs_sops; + sb->s_time_gran = 1; sb->s_xattr = erofs_xattr_handlers; if (test_opt(&sbi->opt, POSIX_ACL)) @@ -763,6 +768,7 @@ static void erofs_kill_sb(struct super_block *sb) erofs_free_dev_context(sbi->devs); fs_put_dax(sbi->dax_dev); + erofs_fscache_unregister_cookie(&sbi->s_fscache); erofs_fscache_unregister_fs(sb); kfree(sbi); sb->s_fs_info = NULL; @@ -781,6 +787,7 @@ static void erofs_put_super(struct super_block *sb) iput(sbi->managed_cache); sbi->managed_cache = NULL; #endif + erofs_fscache_unregister_cookie(&sbi->s_fscache); } static struct file_system_type erofs_fs_type = { -- 2.27.0