From patchwork Thu Sep 21 07:03:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 142850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5078726vqi; Thu, 21 Sep 2023 12:13:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETZ8OTiKXeCUePhdpIeL/xiz8PrAi69qdyRVSdu+UEQq9plewwNen/zlKmrR6Bc8ydPEmL X-Received: by 2002:a05:6a20:729b:b0:15a:6733:24e2 with SMTP id o27-20020a056a20729b00b0015a673324e2mr808117pzk.25.1695323604930; Thu, 21 Sep 2023 12:13:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695323604; cv=none; d=google.com; s=arc-20160816; b=ANUgsq8QPdobsXSArSfnlra1sCRNVk7/enn8Ar+Carx+IKMbTPm7o1OlY/iinXOjPq u7xAWXOifH4m+mEMUIIO2dADsV5eNJT9kl2C+hj4KCm0MpEhINNlLioLLH9/J29tZc0A AADDvDvLtJ/q+RCWNF/CHTUeChkg3q8E+HTO2AO3JzhvSX4WcPK0UmKc1pO8MXr5nUS4 QKjRdcYo8/XnTisAESpn1MP2vv6qNGepS3JG5KrA0pP8i0wm5JRmp1RFDJa1mrnthD0V /Y7G7m9hMJeYmEw6PuKweNLCVY25c7lHKGnfcdV+tuG+fiiYFh+NjotuQOh3lTgKivIP ltbQ== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject; bh=cG/9BQFlv/L4jyOo38H5cZPQdh9yQlVijN6aCcoHRnk=; fh=Vd00GRLUNDtgftEBzBaifz0ZIGFRdtawsvTRUw5VTu8=; b=STMJkHch7M+0V/DdgDGdDzL2IGBcINP2iJpk3ihj2EOt9LXilabJygxRSqSiHTdto0 p6vVh2bmTx1EoUBg8rIieKHqZLQ30tkI7NSretv45a7JgloxhWybLSA/jb0ecEPNcgDy 7G9AQnE4om2Vzj30aihbddVlQXPWi0zko2C0fr3Qgf5XSEDBzSAqA8ROraKEBXE9LS8k eo55IUo3mdfXXYRnvkp3d2rz1YEt4TjxkSXQgIrdzfP+/D8zZnXSs+YR00KFPQeq6zTq Hut3NmA7IKVvJhjjue9Eo9SuPmymtjN/Go0YCB+uj71bfFpZbqC3OJSykLnKpr4aIKq8 MlSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k33-20020a634b61000000b00578c9144919si2070681pgl.254.2023.09.21.12.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 12:13:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E65A48059892; Thu, 21 Sep 2023 11:57:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229493AbjIUS5b (ORCPT + 28 others); Thu, 21 Sep 2023 14:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbjIUS5A (ORCPT ); Thu, 21 Sep 2023 14:57:00 -0400 Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [IPv6:2403:5800:3:25::1001]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 431708FB3E; Thu, 21 Sep 2023 11:51:05 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 7F837100321; Thu, 21 Sep 2023 17:03:46 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at smtp01.aussiebb.com.au Received: from smtp01.aussiebb.com.au ([127.0.0.1]) by localhost (smtp01.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cS9HrQngyQhG; Thu, 21 Sep 2023 17:03:46 +1000 (AEST) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id 7620310056B; Thu, 21 Sep 2023 17:03:46 +1000 (AEST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from donald.themaw.net (180-150-90-198.b4965a.per.nbn.aussiebb.net [180.150.90.198]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id A40B81002AE; Thu, 21 Sep 2023 17:03:45 +1000 (AEST) Subject: [PATCH 3/8] autofs - refactor super block info init From: Ian Kent To: Al Viro , Christian Brauner Cc: autofs mailing list , linux-fsdevel , Kernel Mailing List , Bill O'Donnell , Miklos Szeredi , David Howells Date: Thu, 21 Sep 2023 15:03:45 +0800 Message-ID: <169527982522.27328.18413711550740966247.stgit@donald.themaw.net> In-Reply-To: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> References: <169527971702.27328.16272807830250040704.stgit@donald.themaw.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 21 Sep 2023 11:57:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777675644237622779 X-GMAIL-MSGID: 1777675644237622779 Move the allocation and initialisation of the super block info struct to its own function. Signed-off-by: Ian Kent --- fs/autofs/inode.c | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index e279e275b0a5..992d6cb29707 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -171,11 +171,6 @@ static int parse_options(char *options, root->i_uid = current_uid(); root->i_gid = current_gid(); - sbi->min_proto = AUTOFS_MIN_PROTO_VERSION; - sbi->max_proto = AUTOFS_MAX_PROTO_VERSION; - - sbi->pipefd = -1; - if (!options) return 1; @@ -248,41 +243,49 @@ static int parse_options(char *options, return (sbi->pipefd < 0); } -int autofs_fill_super(struct super_block *s, void *data, int silent) +static struct autofs_sb_info *autofs_alloc_sbi(void) { - struct inode *root_inode; - struct dentry *root; struct autofs_sb_info *sbi; - struct autofs_info *ino; - int pgrp = 0; - bool pgrp_set = false; - int ret = -EINVAL; sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) - return -ENOMEM; - pr_debug("starting up, sbi = %p\n", sbi); + return NULL; - s->s_fs_info = sbi; sbi->magic = AUTOFS_SBI_MAGIC; - sbi->pipefd = -1; - sbi->pipe = NULL; - sbi->exp_timeout = 0; - sbi->oz_pgrp = NULL; - sbi->sb = s; - sbi->version = 0; - sbi->sub_version = 0; sbi->flags = AUTOFS_SBI_CATATONIC; + sbi->min_proto = AUTOFS_MIN_PROTO_VERSION; + sbi->max_proto = AUTOFS_MAX_PROTO_VERSION; + sbi->pipefd = -1; + set_autofs_type_indirect(&sbi->type); - sbi->min_proto = 0; - sbi->max_proto = 0; mutex_init(&sbi->wq_mutex); mutex_init(&sbi->pipe_mutex); spin_lock_init(&sbi->fs_lock); - sbi->queues = NULL; spin_lock_init(&sbi->lookup_lock); INIT_LIST_HEAD(&sbi->active_list); INIT_LIST_HEAD(&sbi->expiring_list); + + return sbi; +} + +int autofs_fill_super(struct super_block *s, void *data, int silent) +{ + struct inode *root_inode; + struct dentry *root; + struct autofs_sb_info *sbi; + struct autofs_info *ino; + int pgrp = 0; + bool pgrp_set = false; + int ret = -EINVAL; + + sbi = autofs_alloc_sbi(); + if (!sbi) + return -ENOMEM; + + pr_debug("starting up, sbi = %p\n", sbi); + + sbi->sb = s; + s->s_fs_info = sbi; s->s_blocksize = 1024; s->s_blocksize_bits = 10; s->s_magic = AUTOFS_SUPER_MAGIC;