super.c (63b6f0b827d6b40e53bac5abc8150fa117d27bec) super.c (b134d687dd9369bb2407a23c6ecc9e0a15d8bb20)
1/* AFS superblock handling
2 *
3 * Copyright (c) 2002, 2007, 2018 Red Hat, Inc. All rights reserved.
4 *
5 * This software may be freely redistributed under the terms of the
6 * GNU General Public License.
7 *
8 * You should have received a copy of the GNU General Public License

--- 31 unchanged lines hidden (view full) ---

40static const struct fs_parameter_description afs_fs_parameters;
41
42struct file_system_type afs_fs_type = {
43 .owner = THIS_MODULE,
44 .name = "afs",
45 .init_fs_context = afs_init_fs_context,
46 .parameters = &afs_fs_parameters,
47 .kill_sb = afs_kill_super,
1/* AFS superblock handling
2 *
3 * Copyright (c) 2002, 2007, 2018 Red Hat, Inc. All rights reserved.
4 *
5 * This software may be freely redistributed under the terms of the
6 * GNU General Public License.
7 *
8 * You should have received a copy of the GNU General Public License

--- 31 unchanged lines hidden (view full) ---

40static const struct fs_parameter_description afs_fs_parameters;
41
42struct file_system_type afs_fs_type = {
43 .owner = THIS_MODULE,
44 .name = "afs",
45 .init_fs_context = afs_init_fs_context,
46 .parameters = &afs_fs_parameters,
47 .kill_sb = afs_kill_super,
48 .fs_flags = 0,
48 .fs_flags = FS_RENAME_DOES_D_MOVE,
49};
50MODULE_ALIAS_FS("afs");
51
52int afs_net_id;
53
54static const struct super_operations afs_super_ops = {
55 .statfs = afs_statfs,
56 .alloc_inode = afs_alloc_inode,

--- 5 unchanged lines hidden (view full) ---

62};
63
64static struct kmem_cache *afs_inode_cachep;
65static atomic_t afs_count_active_inodes;
66
67enum afs_param {
68 Opt_autocell,
69 Opt_dyn,
49};
50MODULE_ALIAS_FS("afs");
51
52int afs_net_id;
53
54static const struct super_operations afs_super_ops = {
55 .statfs = afs_statfs,
56 .alloc_inode = afs_alloc_inode,

--- 5 unchanged lines hidden (view full) ---

62};
63
64static struct kmem_cache *afs_inode_cachep;
65static atomic_t afs_count_active_inodes;
66
67enum afs_param {
68 Opt_autocell,
69 Opt_dyn,
70 Opt_flock,
70 Opt_source,
71};
72
73static const struct fs_parameter_spec afs_param_specs[] = {
74 fsparam_flag ("autocell", Opt_autocell),
75 fsparam_flag ("dyn", Opt_dyn),
71 Opt_source,
72};
73
74static const struct fs_parameter_spec afs_param_specs[] = {
75 fsparam_flag ("autocell", Opt_autocell),
76 fsparam_flag ("dyn", Opt_dyn),
77 fsparam_enum ("flock", Opt_flock),
76 fsparam_string("source", Opt_source),
77 {}
78};
79
78 fsparam_string("source", Opt_source),
79 {}
80};
81
82static const struct fs_parameter_enum afs_param_enums[] = {
83 { Opt_flock, "local", afs_flock_mode_local },
84 { Opt_flock, "openafs", afs_flock_mode_openafs },
85 { Opt_flock, "strict", afs_flock_mode_strict },
86 { Opt_flock, "write", afs_flock_mode_write },
87 {}
88};
89
80static const struct fs_parameter_description afs_fs_parameters = {
81 .name = "kAFS",
82 .specs = afs_param_specs,
90static const struct fs_parameter_description afs_fs_parameters = {
91 .name = "kAFS",
92 .specs = afs_param_specs,
93 .enums = afs_param_enums,
83};
84
85/*
86 * initialise the filesystem
87 */
88int __init afs_fs_init(void)
89{
90 int ret;

--- 86 unchanged lines hidden (view full) ---

177}
178
179/*
180 * Display the mount options in /proc/mounts.
181 */
182static int afs_show_options(struct seq_file *m, struct dentry *root)
183{
184 struct afs_super_info *as = AFS_FS_S(root->d_sb);
94};
95
96/*
97 * initialise the filesystem
98 */
99int __init afs_fs_init(void)
100{
101 int ret;

--- 86 unchanged lines hidden (view full) ---

188}
189
190/*
191 * Display the mount options in /proc/mounts.
192 */
193static int afs_show_options(struct seq_file *m, struct dentry *root)
194{
195 struct afs_super_info *as = AFS_FS_S(root->d_sb);
196 const char *p = NULL;
185
186 if (as->dyn_root)
187 seq_puts(m, ",dyn");
188 if (test_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(d_inode(root))->flags))
189 seq_puts(m, ",autocell");
197
198 if (as->dyn_root)
199 seq_puts(m, ",dyn");
200 if (test_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(d_inode(root))->flags))
201 seq_puts(m, ",autocell");
202 switch (as->flock_mode) {
203 case afs_flock_mode_unset: break;
204 case afs_flock_mode_local: p = "local"; break;
205 case afs_flock_mode_openafs: p = "openafs"; break;
206 case afs_flock_mode_strict: p = "strict"; break;
207 case afs_flock_mode_write: p = "write"; break;
208 }
209 if (p)
210 seq_printf(m, ",flock=%s", p);
211
190 return 0;
191}
192
193/*
194 * Parse the source name to get cell name, volume name, volume type and R/W
195 * selector.
196 *
197 * This can be one of the following:

--- 112 unchanged lines hidden (view full) ---

310 case Opt_autocell:
311 ctx->autocell = true;
312 break;
313
314 case Opt_dyn:
315 ctx->dyn_root = true;
316 break;
317
212 return 0;
213}
214
215/*
216 * Parse the source name to get cell name, volume name, volume type and R/W
217 * selector.
218 *
219 * This can be one of the following:

--- 112 unchanged lines hidden (view full) ---

332 case Opt_autocell:
333 ctx->autocell = true;
334 break;
335
336 case Opt_dyn:
337 ctx->dyn_root = true;
338 break;
339
340 case Opt_flock:
341 ctx->flock_mode = result.uint_32;
342 break;
343
318 default:
319 return -EINVAL;
320 }
321
322 _leave(" = 0");
323 return 0;
324}
325

--- 96 unchanged lines hidden (view full) ---

422 sb->s_flags |= SB_RDONLY;
423 } else {
424 sprintf(sb->s_id, "%llu", as->volume->vid);
425 afs_activate_volume(as->volume);
426 fid.vid = as->volume->vid;
427 fid.vnode = 1;
428 fid.vnode_hi = 0;
429 fid.unique = 1;
344 default:
345 return -EINVAL;
346 }
347
348 _leave(" = 0");
349 return 0;
350}
351

--- 96 unchanged lines hidden (view full) ---

448 sb->s_flags |= SB_RDONLY;
449 } else {
450 sprintf(sb->s_id, "%llu", as->volume->vid);
451 afs_activate_volume(as->volume);
452 fid.vid = as->volume->vid;
453 fid.vnode = 1;
454 fid.vnode_hi = 0;
455 fid.unique = 1;
430 inode = afs_iget(sb, ctx->key, &fid, NULL, NULL, NULL);
456 inode = afs_iget(sb, ctx->key, &fid, NULL, NULL, NULL, NULL);
431 }
432
433 if (IS_ERR(inode))
434 return PTR_ERR(inode);
435
436 if (ctx->autocell || as->dyn_root)
437 set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags);
438

--- 22 unchanged lines hidden (view full) ---

461static struct afs_super_info *afs_alloc_sbi(struct fs_context *fc)
462{
463 struct afs_fs_context *ctx = fc->fs_private;
464 struct afs_super_info *as;
465
466 as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
467 if (as) {
468 as->net_ns = get_net(fc->net_ns);
457 }
458
459 if (IS_ERR(inode))
460 return PTR_ERR(inode);
461
462 if (ctx->autocell || as->dyn_root)
463 set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags);
464

--- 22 unchanged lines hidden (view full) ---

487static struct afs_super_info *afs_alloc_sbi(struct fs_context *fc)
488{
489 struct afs_fs_context *ctx = fc->fs_private;
490 struct afs_super_info *as;
491
492 as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
493 if (as) {
494 as->net_ns = get_net(fc->net_ns);
495 as->flock_mode = ctx->flock_mode;
469 if (ctx->dyn_root) {
470 as->dyn_root = true;
471 } else {
472 as->cell = afs_get_cell(ctx->cell);
473 as->volume = __afs_get_volume(ctx->volume);
474 }
475 }
476 return as;

--- 68 unchanged lines hidden (view full) ---

545 goto error_sb;
546 sb->s_flags |= SB_ACTIVE;
547 } else {
548 _debug("reuse");
549 ASSERTCMP(sb->s_flags, &, SB_ACTIVE);
550 }
551
552 fc->root = dget(sb->s_root);
496 if (ctx->dyn_root) {
497 as->dyn_root = true;
498 } else {
499 as->cell = afs_get_cell(ctx->cell);
500 as->volume = __afs_get_volume(ctx->volume);
501 }
502 }
503 return as;

--- 68 unchanged lines hidden (view full) ---

572 goto error_sb;
573 sb->s_flags |= SB_ACTIVE;
574 } else {
575 _debug("reuse");
576 ASSERTCMP(sb->s_flags, &, SB_ACTIVE);
577 }
578
579 fc->root = dget(sb->s_root);
580 trace_afs_get_tree(as->cell, as->volume);
553 _leave(" = 0 [%p]", sb);
554 return 0;
555
556error_sb:
557 deactivate_locked_super(sb);
558error:
559 _leave(" = %d", ret);
560 return ret;

--- 90 unchanged lines hidden (view full) ---

651#ifdef CONFIG_AFS_FSCACHE
652 vnode->cache = NULL;
653#endif
654
655 vnode->flags = 1 << AFS_VNODE_UNSET;
656 vnode->cb_type = 0;
657 vnode->lock_state = AFS_VNODE_LOCK_NONE;
658
581 _leave(" = 0 [%p]", sb);
582 return 0;
583
584error_sb:
585 deactivate_locked_super(sb);
586error:
587 _leave(" = %d", ret);
588 return ret;

--- 90 unchanged lines hidden (view full) ---

679#ifdef CONFIG_AFS_FSCACHE
680 vnode->cache = NULL;
681#endif
682
683 vnode->flags = 1 << AFS_VNODE_UNSET;
684 vnode->cb_type = 0;
685 vnode->lock_state = AFS_VNODE_LOCK_NONE;
686
687 init_rwsem(&vnode->rmdir_lock);
688
659 _leave(" = %p", &vnode->vfs_inode);
660 return &vnode->vfs_inode;
661}
662
663static void afs_i_callback(struct rcu_head *head)
664{
665 struct inode *inode = container_of(head, struct inode, i_rcu);
666 struct afs_vnode *vnode = AFS_FS_I(inode);

--- 72 unchanged lines hidden ---
689 _leave(" = %p", &vnode->vfs_inode);
690 return &vnode->vfs_inode;
691}
692
693static void afs_i_callback(struct rcu_head *head)
694{
695 struct inode *inode = container_of(head, struct inode, i_rcu);
696 struct afs_vnode *vnode = AFS_FS_I(inode);

--- 72 unchanged lines hidden ---