Skip to content

Commit 9d8719a

Browse files
raven-autorvalds
authored andcommitted
autofs: change catatonic setting to a bit flag
Change the superblock info. catatonic setting to be part of a flags bit field. Link: http://lkml.kernel.org/r/154296973142.9889.17275721668508589639.stgit@pluto-themaw-net Signed-off-by: Ian Kent <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9bf964c commit 9d8719a

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

fs/autofs/autofs_i.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,18 @@ struct autofs_wait_queue {
103103

104104
#define AUTOFS_SBI_MAGIC 0x6d4a556d
105105

106+
#define AUTOFS_SBI_CATATONIC 0x0001
107+
106108
struct autofs_sb_info {
107109
u32 magic;
108110
int pipefd;
109111
struct file *pipe;
110112
struct pid *oz_pgrp;
111-
int catatonic;
112113
int version;
113114
int sub_version;
114115
int min_proto;
115116
int max_proto;
117+
unsigned int flags;
116118
unsigned long exp_timeout;
117119
unsigned int type;
118120
struct super_block *sb;
@@ -142,7 +144,8 @@ static inline struct autofs_info *autofs_dentry_ino(struct dentry *dentry)
142144
*/
143145
static inline int autofs_oz_mode(struct autofs_sb_info *sbi)
144146
{
145-
return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp;
147+
return ((sbi->flags & AUTOFS_SBI_CATATONIC) ||
148+
task_pgrp(current) == sbi->oz_pgrp);
146149
}
147150

148151
struct inode *autofs_get_inode(struct super_block *, umode_t);

fs/autofs/dev-ioctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
350350
pipefd = param->setpipefd.pipefd;
351351

352352
mutex_lock(&sbi->wq_mutex);
353-
if (!sbi->catatonic) {
353+
if (!(sbi->flags & AUTOFS_SBI_CATATONIC)) {
354354
mutex_unlock(&sbi->wq_mutex);
355355
return -EBUSY;
356356
} else {
@@ -377,7 +377,7 @@ static int autofs_dev_ioctl_setpipefd(struct file *fp,
377377
swap(sbi->oz_pgrp, new_pid);
378378
sbi->pipefd = pipefd;
379379
sbi->pipe = pipe;
380-
sbi->catatonic = 0;
380+
sbi->flags &= ~AUTOFS_SBI_CATATONIC;
381381
}
382382
out:
383383
put_pid(new_pid);

fs/autofs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
227227
sbi->magic = AUTOFS_SBI_MAGIC;
228228
sbi->pipefd = -1;
229229
sbi->pipe = NULL;
230-
sbi->catatonic = 1;
231230
sbi->exp_timeout = 0;
232231
sbi->oz_pgrp = NULL;
233232
sbi->sb = s;
234233
sbi->version = 0;
235234
sbi->sub_version = 0;
235+
sbi->flags = AUTOFS_SBI_CATATONIC;
236236
set_autofs_type_indirect(&sbi->type);
237237
sbi->min_proto = 0;
238238
sbi->max_proto = 0;
@@ -318,7 +318,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
318318
if (ret < 0)
319319
goto fail_fput;
320320
sbi->pipe = pipe;
321-
sbi->catatonic = 0;
321+
sbi->flags &= ~AUTOFS_SBI_CATATONIC;
322322

323323
/*
324324
* Success! Install the root dentry now to indicate completion.

fs/autofs/root.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ static struct dentry *autofs_lookup(struct inode *dir,
510510
sbi = autofs_sbi(dir->i_sb);
511511

512512
pr_debug("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n",
513-
current->pid, task_pgrp_nr(current), sbi->catatonic,
513+
current->pid, task_pgrp_nr(current),
514+
sbi->flags & AUTOFS_SBI_CATATONIC,
514515
autofs_oz_mode(sbi));
515516

516517
active = autofs_lookup_active(dentry);
@@ -563,7 +564,7 @@ static int autofs_dir_symlink(struct inode *dir,
563564
* autofs mount is catatonic but the state of an autofs
564565
* file system needs to be preserved over restarts.
565566
*/
566-
if (sbi->catatonic)
567+
if (sbi->flags & AUTOFS_SBI_CATATONIC)
567568
return -EACCES;
568569

569570
BUG_ON(!ino);
@@ -626,7 +627,7 @@ static int autofs_dir_unlink(struct inode *dir, struct dentry *dentry)
626627
* autofs mount is catatonic but the state of an autofs
627628
* file system needs to be preserved over restarts.
628629
*/
629-
if (sbi->catatonic)
630+
if (sbi->flags & AUTOFS_SBI_CATATONIC)
630631
return -EACCES;
631632

632633
if (atomic_dec_and_test(&ino->count)) {
@@ -714,7 +715,7 @@ static int autofs_dir_rmdir(struct inode *dir, struct dentry *dentry)
714715
* autofs mount is catatonic but the state of an autofs
715716
* file system needs to be preserved over restarts.
716717
*/
717-
if (sbi->catatonic)
718+
if (sbi->flags & AUTOFS_SBI_CATATONIC)
718719
return -EACCES;
719720

720721
spin_lock(&sbi->lookup_lock);
@@ -759,7 +760,7 @@ static int autofs_dir_mkdir(struct inode *dir,
759760
* autofs mount is catatonic but the state of an autofs
760761
* file system needs to be preserved over restarts.
761762
*/
762-
if (sbi->catatonic)
763+
if (sbi->flags & AUTOFS_SBI_CATATONIC)
763764
return -EACCES;
764765

765766
pr_debug("dentry %p, creating %pd\n", dentry, dentry);

fs/autofs/waitq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ void autofs_catatonic_mode(struct autofs_sb_info *sbi)
2020
struct autofs_wait_queue *wq, *nwq;
2121

2222
mutex_lock(&sbi->wq_mutex);
23-
if (sbi->catatonic) {
23+
if (sbi->flags & AUTOFS_SBI_CATATONIC) {
2424
mutex_unlock(&sbi->wq_mutex);
2525
return;
2626
}
2727

2828
pr_debug("entering catatonic mode\n");
2929

30-
sbi->catatonic = 1;
30+
sbi->flags |= AUTOFS_SBI_CATATONIC;
3131
wq = sbi->queues;
3232
sbi->queues = NULL; /* Erase all wait queues */
3333
while (wq) {
@@ -255,7 +255,7 @@ static int validate_request(struct autofs_wait_queue **wait,
255255
struct autofs_wait_queue *wq;
256256
struct autofs_info *ino;
257257

258-
if (sbi->catatonic)
258+
if (sbi->flags & AUTOFS_SBI_CATATONIC)
259259
return -ENOENT;
260260

261261
/* Wait in progress, continue; */
@@ -290,7 +290,7 @@ static int validate_request(struct autofs_wait_queue **wait,
290290
if (mutex_lock_interruptible(&sbi->wq_mutex))
291291
return -EINTR;
292292

293-
if (sbi->catatonic)
293+
if (sbi->flags & AUTOFS_SBI_CATATONIC)
294294
return -ENOENT;
295295

296296
wq = autofs_find_wait(sbi, qstr);
@@ -359,7 +359,7 @@ int autofs_wait(struct autofs_sb_info *sbi,
359359
pid_t tgid;
360360

361361
/* In catatonic mode, we don't wait for nobody */
362-
if (sbi->catatonic)
362+
if (sbi->flags & AUTOFS_SBI_CATATONIC)
363363
return -ENOENT;
364364

365365
/*

0 commit comments

Comments
 (0)