super.c (86cb2ec7b22a0a89b8660110dc03321fadbef45f) | super.c (3b2ce58b0f3c1633750529713be0e467282abd78) |
---|---|
1/* 2 * super.c - NILFS module and super block management. 3 * 4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 95 unchanged lines hidden (view full) --- 104 * function should be used instead. 105 * 106 * The segment constructor must not call this function because it can 107 * kill itself. 108 */ 109void nilfs_error(struct super_block *sb, const char *function, 110 const char *fmt, ...) 111{ | 1/* 2 * super.c - NILFS module and super block management. 3 * 4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 95 unchanged lines hidden (view full) --- 104 * function should be used instead. 105 * 106 * The segment constructor must not call this function because it can 107 * kill itself. 108 */ 109void nilfs_error(struct super_block *sb, const char *function, 110 const char *fmt, ...) 111{ |
112 struct nilfs_sb_info *sbi = NILFS_SB(sb); | 112 struct the_nilfs *nilfs = sbi->s_nilfs; |
113 struct va_format vaf; 114 va_list args; 115 116 va_start(args, fmt); 117 118 vaf.fmt = fmt; 119 vaf.va = &args; 120 121 printk(KERN_CRIT "NILFS error (device %s): %s: %pV\n", 122 sb->s_id, function, &vaf); 123 124 va_end(args); 125 126 if (!(sb->s_flags & MS_RDONLY)) { 127 nilfs_set_error(sbi); 128 | 113 struct va_format vaf; 114 va_list args; 115 116 va_start(args, fmt); 117 118 vaf.fmt = fmt; 119 vaf.va = &args; 120 121 printk(KERN_CRIT "NILFS error (device %s): %s: %pV\n", 122 sb->s_id, function, &vaf); 123 124 va_end(args); 125 126 if (!(sb->s_flags & MS_RDONLY)) { 127 nilfs_set_error(sbi); 128 |
129 if (nilfs_test_opt(sbi, ERRORS_RO)) { | 129 if (nilfs_test_opt(nilfs, ERRORS_RO)) { |
130 printk(KERN_CRIT "Remounting filesystem read-only\n"); 131 sb->s_flags |= MS_RDONLY; 132 } 133 } 134 | 130 printk(KERN_CRIT "Remounting filesystem read-only\n"); 131 sb->s_flags |= MS_RDONLY; 132 } 133 } 134 |
135 if (nilfs_test_opt(sbi, ERRORS_PANIC)) | 135 if (nilfs_test_opt(nilfs, ERRORS_PANIC)) |
136 panic("NILFS (device %s): panic forced after error\n", 137 sb->s_id); 138} 139 140void nilfs_warning(struct super_block *sb, const char *function, 141 const char *fmt, ...) 142{ 143 struct va_format vaf; --- 47 unchanged lines hidden (view full) --- 191 192static int nilfs_sync_super(struct nilfs_sb_info *sbi, int flag) 193{ 194 struct the_nilfs *nilfs = sbi->s_nilfs; 195 int err; 196 197 retry: 198 set_buffer_dirty(nilfs->ns_sbh[0]); | 136 panic("NILFS (device %s): panic forced after error\n", 137 sb->s_id); 138} 139 140void nilfs_warning(struct super_block *sb, const char *function, 141 const char *fmt, ...) 142{ 143 struct va_format vaf; --- 47 unchanged lines hidden (view full) --- 191 192static int nilfs_sync_super(struct nilfs_sb_info *sbi, int flag) 193{ 194 struct the_nilfs *nilfs = sbi->s_nilfs; 195 int err; 196 197 retry: 198 set_buffer_dirty(nilfs->ns_sbh[0]); |
199 if (nilfs_test_opt(sbi, BARRIER)) { | 199 if (nilfs_test_opt(nilfs, BARRIER)) { |
200 err = __sync_dirty_buffer(nilfs->ns_sbh[0], 201 WRITE_SYNC | WRITE_FLUSH_FUA); 202 } else { 203 err = sync_dirty_buffer(nilfs->ns_sbh[0]); 204 } 205 206 if (unlikely(err)) { 207 printk(KERN_ERR --- 317 unchanged lines hidden (view full) --- 525 buf->f_fsid.val[1] = (u32)(id >> 32); 526 527 return 0; 528} 529 530static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 531{ 532 struct super_block *sb = vfs->mnt_sb; | 200 err = __sync_dirty_buffer(nilfs->ns_sbh[0], 201 WRITE_SYNC | WRITE_FLUSH_FUA); 202 } else { 203 err = sync_dirty_buffer(nilfs->ns_sbh[0]); 204 } 205 206 if (unlikely(err)) { 207 printk(KERN_ERR --- 317 unchanged lines hidden (view full) --- 525 buf->f_fsid.val[1] = (u32)(id >> 32); 526 527 return 0; 528} 529 530static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 531{ 532 struct super_block *sb = vfs->mnt_sb; |
533 struct nilfs_sb_info *sbi = NILFS_SB(sb); | 533 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; |
534 struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; 535 | 534 struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; 535 |
536 if (!nilfs_test_opt(sbi, BARRIER)) | 536 if (!nilfs_test_opt(nilfs, BARRIER)) |
537 seq_puts(seq, ",nobarrier"); 538 if (root->cno != NILFS_CPTREE_CURRENT_CNO) 539 seq_printf(seq, ",cp=%llu", (unsigned long long)root->cno); | 537 seq_puts(seq, ",nobarrier"); 538 if (root->cno != NILFS_CPTREE_CURRENT_CNO) 539 seq_printf(seq, ",cp=%llu", (unsigned long long)root->cno); |
540 if (nilfs_test_opt(sbi, ERRORS_PANIC)) | 540 if (nilfs_test_opt(nilfs, ERRORS_PANIC)) |
541 seq_puts(seq, ",errors=panic"); | 541 seq_puts(seq, ",errors=panic"); |
542 if (nilfs_test_opt(sbi, ERRORS_CONT)) | 542 if (nilfs_test_opt(nilfs, ERRORS_CONT)) |
543 seq_puts(seq, ",errors=continue"); | 543 seq_puts(seq, ",errors=continue"); |
544 if (nilfs_test_opt(sbi, STRICT_ORDER)) | 544 if (nilfs_test_opt(nilfs, STRICT_ORDER)) |
545 seq_puts(seq, ",order=strict"); | 545 seq_puts(seq, ",order=strict"); |
546 if (nilfs_test_opt(sbi, NORECOVERY)) | 546 if (nilfs_test_opt(nilfs, NORECOVERY)) |
547 seq_puts(seq, ",norecovery"); | 547 seq_puts(seq, ",norecovery"); |
548 if (nilfs_test_opt(sbi, DISCARD)) | 548 if (nilfs_test_opt(nilfs, DISCARD)) |
549 seq_puts(seq, ",discard"); 550 551 return 0; 552} 553 554static const struct super_operations nilfs_sops = { 555 .alloc_inode = nilfs_alloc_inode, 556 .destroy_inode = nilfs_destroy_inode, --- 32 unchanged lines hidden (view full) --- 589 {Opt_norecovery, "norecovery"}, 590 {Opt_discard, "discard"}, 591 {Opt_nodiscard, "nodiscard"}, 592 {Opt_err, NULL} 593}; 594 595static int parse_options(char *options, struct super_block *sb, int is_remount) 596{ | 549 seq_puts(seq, ",discard"); 550 551 return 0; 552} 553 554static const struct super_operations nilfs_sops = { 555 .alloc_inode = nilfs_alloc_inode, 556 .destroy_inode = nilfs_destroy_inode, --- 32 unchanged lines hidden (view full) --- 589 {Opt_norecovery, "norecovery"}, 590 {Opt_discard, "discard"}, 591 {Opt_nodiscard, "nodiscard"}, 592 {Opt_err, NULL} 593}; 594 595static int parse_options(char *options, struct super_block *sb, int is_remount) 596{ |
597 struct nilfs_sb_info *sbi = NILFS_SB(sb); | 597 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; |
598 char *p; 599 substring_t args[MAX_OPT_ARGS]; 600 601 if (!options) 602 return 1; 603 604 while ((p = strsep(&options, ",")) != NULL) { 605 int token; 606 if (!*p) 607 continue; 608 609 token = match_token(p, tokens, args); 610 switch (token) { 611 case Opt_barrier: | 598 char *p; 599 substring_t args[MAX_OPT_ARGS]; 600 601 if (!options) 602 return 1; 603 604 while ((p = strsep(&options, ",")) != NULL) { 605 int token; 606 if (!*p) 607 continue; 608 609 token = match_token(p, tokens, args); 610 switch (token) { 611 case Opt_barrier: |
612 nilfs_set_opt(sbi, BARRIER); | 612 nilfs_set_opt(nilfs, BARRIER); |
613 break; 614 case Opt_nobarrier: | 613 break; 614 case Opt_nobarrier: |
615 nilfs_clear_opt(sbi, BARRIER); | 615 nilfs_clear_opt(nilfs, BARRIER); |
616 break; 617 case Opt_order: 618 if (strcmp(args[0].from, "relaxed") == 0) 619 /* Ordered data semantics */ | 616 break; 617 case Opt_order: 618 if (strcmp(args[0].from, "relaxed") == 0) 619 /* Ordered data semantics */ |
620 nilfs_clear_opt(sbi, STRICT_ORDER); | 620 nilfs_clear_opt(nilfs, STRICT_ORDER); |
621 else if (strcmp(args[0].from, "strict") == 0) 622 /* Strict in-order semantics */ | 621 else if (strcmp(args[0].from, "strict") == 0) 622 /* Strict in-order semantics */ |
623 nilfs_set_opt(sbi, STRICT_ORDER); | 623 nilfs_set_opt(nilfs, STRICT_ORDER); |
624 else 625 return 0; 626 break; 627 case Opt_err_panic: | 624 else 625 return 0; 626 break; 627 case Opt_err_panic: |
628 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_PANIC); | 628 nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_PANIC); |
629 break; 630 case Opt_err_ro: | 629 break; 630 case Opt_err_ro: |
631 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_RO); | 631 nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_RO); |
632 break; 633 case Opt_err_cont: | 632 break; 633 case Opt_err_cont: |
634 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_CONT); | 634 nilfs_write_opt(nilfs, ERROR_MODE, ERRORS_CONT); |
635 break; 636 case Opt_snapshot: 637 if (is_remount) { 638 printk(KERN_ERR 639 "NILFS: \"%s\" option is invalid " 640 "for remount.\n", p); 641 return 0; 642 } 643 break; 644 case Opt_norecovery: | 635 break; 636 case Opt_snapshot: 637 if (is_remount) { 638 printk(KERN_ERR 639 "NILFS: \"%s\" option is invalid " 640 "for remount.\n", p); 641 return 0; 642 } 643 break; 644 case Opt_norecovery: |
645 nilfs_set_opt(sbi, NORECOVERY); | 645 nilfs_set_opt(nilfs, NORECOVERY); |
646 break; 647 case Opt_discard: | 646 break; 647 case Opt_discard: |
648 nilfs_set_opt(sbi, DISCARD); | 648 nilfs_set_opt(nilfs, DISCARD); |
649 break; 650 case Opt_nodiscard: | 649 break; 650 case Opt_nodiscard: |
651 nilfs_clear_opt(sbi, DISCARD); | 651 nilfs_clear_opt(nilfs, DISCARD); |
652 break; 653 default: 654 printk(KERN_ERR 655 "NILFS: Unrecognized mount option \"%s\"\n", p); 656 return 0; 657 } 658 } 659 return 1; 660} 661 662static inline void | 652 break; 653 default: 654 printk(KERN_ERR 655 "NILFS: Unrecognized mount option \"%s\"\n", p); 656 return 0; 657 } 658 } 659 return 1; 660} 661 662static inline void |
663nilfs_set_default_options(struct nilfs_sb_info *sbi, | 663nilfs_set_default_options(struct super_block *sb, |
664 struct nilfs_super_block *sbp) 665{ | 664 struct nilfs_super_block *sbp) 665{ |
666 sbi->s_mount_opt = | 666 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 667 668 nilfs->ns_mount_opt = |
667 NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER; 668} 669 670static int nilfs_setup_super(struct nilfs_sb_info *sbi, int is_mount) 671{ 672 struct the_nilfs *nilfs = sbi->s_nilfs; 673 struct nilfs_super_block **sbp; 674 int max_mnt_count; --- 56 unchanged lines hidden (view full) --- 731 732 sb->s_magic = le16_to_cpu(sbp->s_magic); 733 734 /* FS independent flags */ 735#ifdef NILFS_ATIME_DISABLE 736 sb->s_flags |= MS_NOATIME; 737#endif 738 | 669 NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER; 670} 671 672static int nilfs_setup_super(struct nilfs_sb_info *sbi, int is_mount) 673{ 674 struct the_nilfs *nilfs = sbi->s_nilfs; 675 struct nilfs_super_block **sbp; 676 int max_mnt_count; --- 56 unchanged lines hidden (view full) --- 733 734 sb->s_magic = le16_to_cpu(sbp->s_magic); 735 736 /* FS independent flags */ 737#ifdef NILFS_ATIME_DISABLE 738 sb->s_flags |= MS_NOATIME; 739#endif 740 |
739 nilfs_set_default_options(sbi, sbp); | 741 nilfs_set_default_options(sb, sbp); |
740 741 sbi->s_resuid = le16_to_cpu(sbp->s_def_resuid); 742 sbi->s_resgid = le16_to_cpu(sbp->s_def_resgid); 743 sbi->s_interval = le32_to_cpu(sbp->s_c_interval); 744 sbi->s_watermark = le32_to_cpu(sbp->s_c_block_max); 745 746 return !parse_options(data, sb, 0) ? -EINVAL : 0 ; 747} --- 270 unchanged lines hidden (view full) --- 1018{ 1019 struct nilfs_sb_info *sbi = NILFS_SB(sb); 1020 struct the_nilfs *nilfs = sbi->s_nilfs; 1021 unsigned long old_sb_flags; 1022 unsigned long old_mount_opt; 1023 int err; 1024 1025 old_sb_flags = sb->s_flags; | 742 743 sbi->s_resuid = le16_to_cpu(sbp->s_def_resuid); 744 sbi->s_resgid = le16_to_cpu(sbp->s_def_resgid); 745 sbi->s_interval = le32_to_cpu(sbp->s_c_interval); 746 sbi->s_watermark = le32_to_cpu(sbp->s_c_block_max); 747 748 return !parse_options(data, sb, 0) ? -EINVAL : 0 ; 749} --- 270 unchanged lines hidden (view full) --- 1020{ 1021 struct nilfs_sb_info *sbi = NILFS_SB(sb); 1022 struct the_nilfs *nilfs = sbi->s_nilfs; 1023 unsigned long old_sb_flags; 1024 unsigned long old_mount_opt; 1025 int err; 1026 1027 old_sb_flags = sb->s_flags; |
1026 old_mount_opt = sbi->s_mount_opt; | 1028 old_mount_opt = nilfs->ns_mount_opt; |
1027 1028 if (!parse_options(data, sb, 1)) { 1029 err = -EINVAL; 1030 goto restore_opts; 1031 } 1032 sb->s_flags = (sb->s_flags & ~MS_POSIXACL); 1033 1034 err = -EINVAL; --- 52 unchanged lines hidden (view full) --- 1087 nilfs_setup_super(sbi, true); 1088 up_write(&nilfs->ns_sem); 1089 } 1090 out: 1091 return 0; 1092 1093 restore_opts: 1094 sb->s_flags = old_sb_flags; | 1029 1030 if (!parse_options(data, sb, 1)) { 1031 err = -EINVAL; 1032 goto restore_opts; 1033 } 1034 sb->s_flags = (sb->s_flags & ~MS_POSIXACL); 1035 1036 err = -EINVAL; --- 52 unchanged lines hidden (view full) --- 1089 nilfs_setup_super(sbi, true); 1090 up_write(&nilfs->ns_sem); 1091 } 1092 out: 1093 return 0; 1094 1095 restore_opts: 1096 sb->s_flags = old_sb_flags; |
1095 sbi->s_mount_opt = old_mount_opt; | 1097 nilfs->ns_mount_opt = old_mount_opt; |
1096 return err; 1097} 1098 1099struct nilfs_super_data { 1100 struct block_device *bdev; 1101 struct nilfs_sb_info *sbi; 1102 __u64 cno; 1103 int flags; --- 262 unchanged lines hidden --- | 1098 return err; 1099} 1100 1101struct nilfs_super_data { 1102 struct block_device *bdev; 1103 struct nilfs_sb_info *sbi; 1104 __u64 cno; 1105 int flags; --- 262 unchanged lines hidden --- |