Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4793367rwb; Tue, 8 Aug 2023 14:04:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAkS346nIAoPwYLIImMYUp5pXb8NDB9mhTMRDiS28qa3nZBjr6ywjKScr9m6xR1NWzG3E4 X-Received: by 2002:a5e:a910:0:b0:786:25cf:421f with SMTP id c16-20020a5ea910000000b0078625cf421fmr781545iod.19.1691528686413; Tue, 08 Aug 2023 14:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691528686; cv=none; d=google.com; s=arc-20160816; b=zNNgBoNCpm/4+nu9T+c1lzLN05tP5hi/rmIz9IDaeg/de8rG0tlxnVJxjaurcbyEQa E7L5AtxJf1jLsbJvxMguP6VFGnY8XKmXun7nrp+iQsb6oaqmmNc3Fdp2Oehrdnwbus3q UMjwxzDc7IhbZ+2FstanDo/yqQA8VTlwIqjOQAN6KFBzVrBph1bToBeAoi7IId8tUK5Y ESrKr+BPBJTBVtQkA5NA76EjhCB88a9hkCbREiXX7Bdd3MlQKt8DcHufu96J1QJeEB6G m7Ln69sfcCAyiPm3CqgBrwxyY3+s14nsFCHWQxfiT1JglZvZJBGsjaITGTprSDWxYDZw c5EQ== 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 :dkim-signature; bh=KcOpoqbZgkJsyfWlcpWY5JHgObXtvv0somhVOIZQD4w=; fh=xYYCMLMJ+2IbWglp0JxrsK4EkPiHh2FQHcpFdt441VM=; b=n1tVg4667OIoUNXGg6IEIse64WMqIcR5spO3XCqusp8Aw+sMJswAI5eYywJQplq6qQ aiXFih8zT/3h/pTKgIxSvgelogQieaWSwiMuGtglEBPIgdlE5BXrE4nEXT/QAsLZrA2Q imUVJs6ixcvY9LWvcF6Ls3r8l45apDIxbYtgD0eE+LpxfFINCXhar55igmoP2Jmv37eD w0IYPnowxruRCZYYFVDSBuGkIeUlzWIVcsS/X+JHqpgOKnnsvNk9VASatQrI/Dvfa9Kf Uz63JEXVhPuCFnfQokRcmNEs+crciDHJ/PR5LvDaHXuDi2gGGsS7UH7B6K5T9AFLfooC Asfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Aq9z3o3X; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020a65564b000000b0056382a0bc99si7975655pgs.580.2023.08.08.14.04.30; Tue, 08 Aug 2023 14:04:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Aq9z3o3X; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235678AbjHHVDZ (ORCPT + 99 others); Tue, 8 Aug 2023 17:03:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235282AbjHHVDM (ORCPT ); Tue, 8 Aug 2023 17:03:12 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B4865FA9B; Tue, 8 Aug 2023 11:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=KcOpoqbZgkJsyfWlcpWY5JHgObXtvv0somhVOIZQD4w=; b=Aq9z3o3XGi9OLoFG7ORcEkpiZV zNBw01/HJOmn6epF3CLZolAD6+cPRIbjA38cUsd5BM5UDqqZlCDQ4Nt8rjUtJSq4nhKXmVihmBEgA Q5pLMVqVNPX07YFeyXqxksHTylsr6iVy80QFDF62ReFibCUCMy3/u9njwwcGHTS7C5zKbtgH1kFoO QHNhXqF6nGzEONUlWDZYbiosx+IseNoL47W7tYD2fGk36F7LE4vE7ukOQzYfkuE6y1A/yjqPLs2sz x+JU3WlpyNDV36Gaz0RInOlo5OjcKuIJlwAzodbZWkMDv8p49L/JcWwGCE95NOdHUUnKDqrkDByr2 GXztsAdQ==; Received: from [4.28.11.157] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qTPNN-002vg3-2M; Tue, 08 Aug 2023 16:16:05 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Namjae Jeon , Sungjong Seo , "Theodore Ts'o" , Andreas Dilger , Konstantin Komarov , "Darrick J. Wong" , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, ntfs3@lists.linux.dev, linux-xfs@vger.kernel.org Subject: [PATCH 13/13] ntfs3: free the sbi in ->kill_sb Date: Tue, 8 Aug 2023 09:16:00 -0700 Message-Id: <20230808161600.1099516-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230808161600.1099516-1-hch@lst.de> References: <20230808161600.1099516-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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-ext4@vger.kernel.org As a rule of thumb everything allocated to the fs_context and moved into the super_block should be freed by ->kill_sb so that the teardown handling doesn't need to be duplicated between the fill_super error path and put_super. Implement an ntfs3-specific kill_sb method to do that. Signed-off-by: Christoph Hellwig --- fs/ntfs3/super.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 727138933a9324..5fffddea554f18 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -625,10 +625,6 @@ static void ntfs_put_super(struct super_block *sb) /* Mark rw ntfs as clear, if possible. */ ntfs_set_state(sbi, NTFS_DIRTY_CLEAR); - - put_mount_options(sbi->options); - ntfs3_free_sbi(sbi); - sb->s_fs_info = NULL; } static int ntfs_statfs(struct dentry *dentry, struct kstatfs *buf) @@ -1562,15 +1558,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) put_inode_out: iput(inode); out: - /* - * Free resources here. - * ntfs_fs_free will be called with fc->s_fs_info = NULL - */ - put_mount_options(sbi->options); - ntfs3_free_sbi(sbi); - sb->s_fs_info = NULL; kfree(boot2); - return err; } @@ -1726,13 +1714,24 @@ static int ntfs_init_fs_context(struct fs_context *fc) return -ENOMEM; } +static void ntfs3_kill_sb(struct super_block *sb) +{ + struct ntfs_sb_info *sbi = sb->s_fs_info; + + kill_block_super(sb); + + if (sbi->options) + put_mount_options(sbi->options); + ntfs3_free_sbi(sbi); +} + // clang-format off static struct file_system_type ntfs_fs_type = { .owner = THIS_MODULE, .name = "ntfs3", .init_fs_context = ntfs_init_fs_context, .parameters = ntfs_fs_parameters, - .kill_sb = kill_block_super, + .kill_sb = ntfs3_kill_sb, .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, }; // clang-format on -- 2.39.2