Skip to content

Commit a746743

Browse files
raven-aubrauner
authored andcommitted
autofs: refactor super block info init
Move the allocation and initialisation of the super block info struct to its own function. Signed-off-by: Ian Kent <raven@themaw.net> Reviewed-by: Bill O'Donnell <bodonnel@redhat.com> Message-Id: <20230922041215.13675-4-raven@themaw.net> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 546694b commit a746743

1 file changed

Lines changed: 28 additions & 25 deletions

File tree

fs/autofs/inode.c

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ static int parse_options(char *options,
171171
root->i_uid = current_uid();
172172
root->i_gid = current_gid();
173173

174-
sbi->min_proto = AUTOFS_MIN_PROTO_VERSION;
175-
sbi->max_proto = AUTOFS_MAX_PROTO_VERSION;
176-
177-
sbi->pipefd = -1;
178-
179174
if (!options)
180175
return 1;
181176

@@ -248,41 +243,49 @@ static int parse_options(char *options,
248243
return (sbi->pipefd < 0);
249244
}
250245

251-
int autofs_fill_super(struct super_block *s, void *data, int silent)
246+
static struct autofs_sb_info *autofs_alloc_sbi(void)
252247
{
253-
struct inode *root_inode;
254-
struct dentry *root;
255248
struct autofs_sb_info *sbi;
256-
struct autofs_info *ino;
257-
int pgrp = 0;
258-
bool pgrp_set = false;
259-
int ret = -EINVAL;
260249

261250
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
262251
if (!sbi)
263-
return -ENOMEM;
264-
pr_debug("starting up, sbi = %p\n", sbi);
252+
return NULL;
265253

266-
s->s_fs_info = sbi;
267254
sbi->magic = AUTOFS_SBI_MAGIC;
268-
sbi->pipefd = -1;
269-
sbi->pipe = NULL;
270-
sbi->exp_timeout = 0;
271-
sbi->oz_pgrp = NULL;
272-
sbi->sb = s;
273-
sbi->version = 0;
274-
sbi->sub_version = 0;
275255
sbi->flags = AUTOFS_SBI_CATATONIC;
256+
sbi->min_proto = AUTOFS_MIN_PROTO_VERSION;
257+
sbi->max_proto = AUTOFS_MAX_PROTO_VERSION;
258+
sbi->pipefd = -1;
259+
276260
set_autofs_type_indirect(&sbi->type);
277-
sbi->min_proto = 0;
278-
sbi->max_proto = 0;
279261
mutex_init(&sbi->wq_mutex);
280262
mutex_init(&sbi->pipe_mutex);
281263
spin_lock_init(&sbi->fs_lock);
282-
sbi->queues = NULL;
283264
spin_lock_init(&sbi->lookup_lock);
284265
INIT_LIST_HEAD(&sbi->active_list);
285266
INIT_LIST_HEAD(&sbi->expiring_list);
267+
268+
return sbi;
269+
}
270+
271+
int autofs_fill_super(struct super_block *s, void *data, int silent)
272+
{
273+
struct inode *root_inode;
274+
struct dentry *root;
275+
struct autofs_sb_info *sbi;
276+
struct autofs_info *ino;
277+
int pgrp = 0;
278+
bool pgrp_set = false;
279+
int ret = -EINVAL;
280+
281+
sbi = autofs_alloc_sbi();
282+
if (!sbi)
283+
return -ENOMEM;
284+
285+
pr_debug("starting up, sbi = %p\n", sbi);
286+
287+
sbi->sb = s;
288+
s->s_fs_info = sbi;
286289
s->s_blocksize = 1024;
287290
s->s_blocksize_bits = 10;
288291
s->s_magic = AUTOFS_SUPER_MAGIC;

0 commit comments

Comments
 (0)