Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp60491lfe; Fri, 15 Apr 2022 19:30:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFSYlbRUCH3s5fU0Y4OdueloZCjZFcDO/iA3nzVjY22jzfhkdhH2caBBBdxCcWOQSUYXVf X-Received: by 2002:a17:90b:2790:b0:1cb:5cb5:f8ab with SMTP id pw16-20020a17090b279000b001cb5cb5f8abmr1848958pjb.190.1650076237361; Fri, 15 Apr 2022 19:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650076237; cv=none; d=google.com; s=arc-20160816; b=G4KstILQPC/H4+MqKQDrPBXmxR0iCixqJrU9kcHkAwvyQRbdDQz4T0CRBs29Z3SexA 94N8lxF+VVoTvxuWAlAlxH3Mc15FlC6UPhuqYbtp1u5aukJo/INYfalETINPYecf2oQt P/kK9jXBZFZRzJ8spEut0OiYIwAjapx1Tjm+sO82tePHp9//IKvkNj579AD+VG5G3qKB jeO7D1P9dcKtvCexLz65rpbmbIn8fpmS4ZWbYAVL4SHau8omuLEXXNyHuVpqUtbHp4xh D5cQDexv1mG9JBKqrXp9JcSVtzMqO8sW7wmzwwJwu1vQhd5Mx4lZeC9vmb8Abfcj+N3F zfhA== 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=kTvVmuKZTm/2tn+3ZvOAIZeLhrFuJE6VJ+0aJy/okDk=; b=Cn0vQAZXPTjzi25rwlcNiN7wgDuxMqrAPZr7Xbt5KIXQfNjRsEhsaBpbFtfWSPoPiw xKISTLMWtymJkRkILNsAtVx1enZ+wneCtBzQGjzxX8884oOWL3fWFCkL3Y4OeVispcSq 6F3R9Hh4i9ftipDzxguGPv30fbC13eEXLv7y1IhKSPVMe8S3yCq2RpCrxpztYfVMeKy1 FCwlIIPNW/Pn/O9Bzv4T7QzuYfuj0YATPlT2EvTZHu7U2yzDqERqUUS1C72kzFdiABnI AuRfd9wne1Zm1COkRoWUEI84yHgqJVIG9R15OevsD+OMqArp4cMT0pUcIlOx7n/4Dj1A 89kA== 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 me8-20020a17090b17c800b001cf9b0e74b8si3773034pjb.183.2022.04.15.19.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:30:37 -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 39B4216AA53; Fri, 15 Apr 2022 18:45:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353738AbiDOMj5 (ORCPT + 99 others); Fri, 15 Apr 2022 08:39:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353690AbiDOMj1 (ORCPT ); Fri, 15 Apr 2022 08:39:27 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DE74C6EE9; Fri, 15 Apr 2022 05:36:43 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R281e4;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=19;SR=0;TI=SMTPD_---0VA7Cc3m_1650026199; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VA7Cc3m_1650026199) by smtp.aliyun-inc.com(127.0.0.1); Fri, 15 Apr 2022 20:36:40 +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 15/21] erofs: register fscache context for primary data blob Date: Fri, 15 Apr 2022 20:36:08 +0800 Message-Id: <20220415123614.54024-16-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 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 Reviewed-by: Gao Xiang --- 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 5867cb63fd74..386658416159 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 fd8daa447237..61dc900295f9 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -589,6 +589,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; sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) @@ -606,6 +609,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; } else { if (!sb_set_blocksize(sb, EROFS_BLKSIZ)) { erofs_err(sb, "failed to set erofs blksize"); @@ -628,11 +636,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)) @@ -772,6 +777,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; @@ -790,6 +796,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