super.c (f044c8847bb61eff5e1e95b6f6bb950e7f4a73a4) super.c (49566f6f06b38d7c1a5c7eacc8a38c6ea2e36549)
1/* AFS superblock handling
2 *
3 * Copyright (c) 2002, 2007 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

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

389 _leave(" = 0");
390 return 0;
391
392error:
393 _leave(" = %d", ret);
394 return ret;
395}
396
1/* AFS superblock handling
2 *
3 * Copyright (c) 2002, 2007 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

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

389 _leave(" = 0");
390 return 0;
391
392error:
393 _leave(" = %d", ret);
394 return ret;
395}
396
397static struct afs_super_info *afs_alloc_sbi(struct afs_mount_params *params)
398{
399 struct afs_super_info *as;
400
401 as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
402 if (as) {
403 as->net = afs_get_net(params->net);
404 as->cell = afs_get_cell(params->cell);
405 }
406 return as;
407}
408
409static void afs_destroy_sbi(struct afs_super_info *as)
410{
411 if (as) {
412 afs_put_volume(as->net, as->volume);
413 afs_put_cell(as->cell);
414 afs_put_net(as->net);
415 kfree(as);
416 }
417}
418
397/*
398 * get an AFS superblock
399 */
400static struct dentry *afs_mount(struct file_system_type *fs_type,
419/*
420 * get an AFS superblock
421 */
422static struct dentry *afs_mount(struct file_system_type *fs_type,
401 int flags, const char *dev_name, void *options)
423 int flags, const char *dev_name, void *options)
402{
403 struct afs_mount_params params;
404 struct super_block *sb;
405 struct afs_volume *vol;
406 struct key *key;
424{
425 struct afs_mount_params params;
426 struct super_block *sb;
427 struct afs_volume *vol;
428 struct key *key;
407 char *new_opts = kstrdup(options, GFP_KERNEL);
408 struct afs_super_info *as;
409 int ret;
410
411 _enter(",,%s,%p", dev_name, options);
412
413 memset(&params, 0, sizeof(params));
414 params.net = &__afs_net;
415

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

432 key = afs_request_key(params.cell);
433 if (IS_ERR(key)) {
434 _leave(" = %ld [key]", PTR_ERR(key));
435 ret = PTR_ERR(key);
436 goto error;
437 }
438 params.key = key;
439
429 struct afs_super_info *as;
430 int ret;
431
432 _enter(",,%s,%p", dev_name, options);
433
434 memset(&params, 0, sizeof(params));
435 params.net = &__afs_net;
436

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

453 key = afs_request_key(params.cell);
454 if (IS_ERR(key)) {
455 _leave(" = %ld [key]", PTR_ERR(key));
456 ret = PTR_ERR(key);
457 goto error;
458 }
459 params.key = key;
460
461 /* allocate a superblock info record */
462 ret = -ENOMEM;
463 as = afs_alloc_sbi(&params);
464 if (!as)
465 goto error;
466
440 /* parse the device name */
441 vol = afs_volume_lookup(&params);
442 if (IS_ERR(vol)) {
443 ret = PTR_ERR(vol);
444 goto error;
445 }
467 /* parse the device name */
468 vol = afs_volume_lookup(&params);
469 if (IS_ERR(vol)) {
470 ret = PTR_ERR(vol);
471 goto error;
472 }
446
447 /* allocate a superblock info record */
448 ret = -ENOMEM;
449 as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
450 if (!as)
451 goto error_vol;
452
453 as->net = afs_get_net(params.net);
454 as->volume = vol;
455
456 /* allocate a deviceless superblock */
457 sb = sget(fs_type, afs_test_super, afs_set_super, flags, as);
458 if (IS_ERR(sb)) {
459 ret = PTR_ERR(sb);
460 goto error_as;
461 }
462
463 if (!sb->s_root) {
464 /* initial superblock/root creation */
465 _debug("create");
466 ret = afs_fill_super(sb, &params);
467 if (ret < 0)
468 goto error_sb;
473 as->volume = vol;
474
475 /* allocate a deviceless superblock */
476 sb = sget(fs_type, afs_test_super, afs_set_super, flags, as);
477 if (IS_ERR(sb)) {
478 ret = PTR_ERR(sb);
479 goto error_as;
480 }
481
482 if (!sb->s_root) {
483 /* initial superblock/root creation */
484 _debug("create");
485 ret = afs_fill_super(sb, &params);
486 if (ret < 0)
487 goto error_sb;
488 as = NULL;
469 sb->s_flags |= MS_ACTIVE;
470 } else {
471 _debug("reuse");
472 ASSERTCMP(sb->s_flags, &, MS_ACTIVE);
489 sb->s_flags |= MS_ACTIVE;
490 } else {
491 _debug("reuse");
492 ASSERTCMP(sb->s_flags, &, MS_ACTIVE);
473 afs_put_volume(params.net, vol);
474 kfree(as);
493 afs_destroy_sbi(as);
494 as = NULL;
475 }
476
477 afs_put_cell(params.cell);
495 }
496
497 afs_put_cell(params.cell);
478 kfree(new_opts);
498 key_put(params.key);
479 _leave(" = 0 [%p]", sb);
480 return dget(sb->s_root);
481
482error_sb:
483 deactivate_locked_super(sb);
499 _leave(" = 0 [%p]", sb);
500 return dget(sb->s_root);
501
502error_sb:
503 deactivate_locked_super(sb);
484 goto error;
485error_as:
504error_as:
486 afs_put_net(as->net);
487 kfree(as);
488error_vol:
489 afs_put_volume(params.net, vol);
505 afs_destroy_sbi(as);
490error:
491 afs_put_cell(params.cell);
492 key_put(params.key);
506error:
507 afs_put_cell(params.cell);
508 key_put(params.key);
493 kfree(new_opts);
494 _leave(" = %d", ret);
495 return ERR_PTR(ret);
496}
497
498static void afs_kill_super(struct super_block *sb)
499{
500 struct afs_super_info *as = sb->s_fs_info;
509 _leave(" = %d", ret);
510 return ERR_PTR(ret);
511}
512
513static void afs_kill_super(struct super_block *sb)
514{
515 struct afs_super_info *as = sb->s_fs_info;
501 struct afs_net *net = as->net;
502
503 kill_anon_super(sb);
516
517 kill_anon_super(sb);
504 afs_put_volume(net, as->volume);
505 kfree(as);
518 afs_destroy_sbi(as);
506}
507
508/*
509 * initialise an inode cache slab element prior to any use
510 */
511static void afs_i_init_once(void *_vnode)
512{
513 struct afs_vnode *vnode = _vnode;

--- 96 unchanged lines hidden ---
519}
520
521/*
522 * initialise an inode cache slab element prior to any use
523 */
524static void afs_i_init_once(void *_vnode)
525{
526 struct afs_vnode *vnode = _vnode;

--- 96 unchanged lines hidden ---