super.c (c6b4d57ddf12f3fd4d41d7b3b9181de46748418d) | super.c (7c01745781177795e39f78b2c2c42c470a13833a) |
---|---|
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 --- 607 unchanged lines hidden (view full) --- 616 {Opt_snapshot, "cp=%u"}, 617 {Opt_order, "order=%s"}, 618 {Opt_norecovery, "norecovery"}, 619 {Opt_discard, "discard"}, 620 {Opt_nodiscard, "nodiscard"}, 621 {Opt_err, NULL} 622}; 623 | 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 --- 607 unchanged lines hidden (view full) --- 616 {Opt_snapshot, "cp=%u"}, 617 {Opt_order, "order=%s"}, 618 {Opt_norecovery, "norecovery"}, 619 {Opt_discard, "discard"}, 620 {Opt_nodiscard, "nodiscard"}, 621 {Opt_err, NULL} 622}; 623 |
624static int parse_options(char *options, struct super_block *sb) | 624static int parse_options(char *options, struct super_block *sb, int is_remount) |
625{ 626 struct nilfs_sb_info *sbi = NILFS_SB(sb); 627 char *p; 628 substring_t args[MAX_OPT_ARGS]; 629 int option; 630 631 if (!options) 632 return 1; --- 28 unchanged lines hidden (view full) --- 661 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_RO); 662 break; 663 case Opt_err_cont: 664 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_CONT); 665 break; 666 case Opt_snapshot: 667 if (match_int(&args[0], &option) || option <= 0) 668 return 0; | 625{ 626 struct nilfs_sb_info *sbi = NILFS_SB(sb); 627 char *p; 628 substring_t args[MAX_OPT_ARGS]; 629 int option; 630 631 if (!options) 632 return 1; --- 28 unchanged lines hidden (view full) --- 661 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_RO); 662 break; 663 case Opt_err_cont: 664 nilfs_write_opt(sbi, ERROR_MODE, ERRORS_CONT); 665 break; 666 case Opt_snapshot: 667 if (match_int(&args[0], &option) || option <= 0) 668 return 0; |
669 if (!(sb->s_flags & MS_RDONLY)) | 669 if (is_remount) { 670 if (!nilfs_test_opt(sbi, SNAPSHOT)) { 671 printk(KERN_ERR 672 "NILFS: cannot change regular " 673 "mount to snapshot.\n"); 674 return 0; 675 } else if (option != sbi->s_snapshot_cno) { 676 printk(KERN_ERR 677 "NILFS: cannot remount to a " 678 "different snapshot.\n"); 679 return 0; 680 } 681 break; 682 } 683 if (!(sb->s_flags & MS_RDONLY)) { 684 printk(KERN_ERR "NILFS: cannot mount snapshot " 685 "read/write. A read-only option is " 686 "required.\n"); |
670 return 0; | 687 return 0; |
688 } |
|
671 sbi->s_snapshot_cno = option; 672 nilfs_set_opt(sbi, SNAPSHOT); 673 break; 674 case Opt_norecovery: 675 nilfs_set_opt(sbi, NORECOVERY); 676 break; 677 case Opt_discard: 678 nilfs_set_opt(sbi, DISCARD); --- 83 unchanged lines hidden (view full) --- 762 763 nilfs_set_default_options(sbi, sbp); 764 765 sbi->s_resuid = le16_to_cpu(sbp->s_def_resuid); 766 sbi->s_resgid = le16_to_cpu(sbp->s_def_resgid); 767 sbi->s_interval = le32_to_cpu(sbp->s_c_interval); 768 sbi->s_watermark = le32_to_cpu(sbp->s_c_block_max); 769 | 689 sbi->s_snapshot_cno = option; 690 nilfs_set_opt(sbi, SNAPSHOT); 691 break; 692 case Opt_norecovery: 693 nilfs_set_opt(sbi, NORECOVERY); 694 break; 695 case Opt_discard: 696 nilfs_set_opt(sbi, DISCARD); --- 83 unchanged lines hidden (view full) --- 780 781 nilfs_set_default_options(sbi, sbp); 782 783 sbi->s_resuid = le16_to_cpu(sbp->s_def_resuid); 784 sbi->s_resgid = le16_to_cpu(sbp->s_def_resgid); 785 sbi->s_interval = le32_to_cpu(sbp->s_c_interval); 786 sbi->s_watermark = le32_to_cpu(sbp->s_c_block_max); 787 |
770 return !parse_options(data, sb) ? -EINVAL : 0 ; | 788 return !parse_options(data, sb, 0) ? -EINVAL : 0 ; |
771} 772 773/** 774 * nilfs_fill_super() - initialize a super block instance 775 * @sb: super_block 776 * @data: mount options 777 * @silent: silent mode flag 778 * @nilfs: the_nilfs struct --- 145 unchanged lines hidden (view full) --- 924 lock_kernel(); 925 926 down_write(&nilfs->ns_super_sem); 927 old_sb_flags = sb->s_flags; 928 old_opts.mount_opt = sbi->s_mount_opt; 929 old_opts.snapshot_cno = sbi->s_snapshot_cno; 930 was_snapshot = nilfs_test_opt(sbi, SNAPSHOT); 931 | 789} 790 791/** 792 * nilfs_fill_super() - initialize a super block instance 793 * @sb: super_block 794 * @data: mount options 795 * @silent: silent mode flag 796 * @nilfs: the_nilfs struct --- 145 unchanged lines hidden (view full) --- 942 lock_kernel(); 943 944 down_write(&nilfs->ns_super_sem); 945 old_sb_flags = sb->s_flags; 946 old_opts.mount_opt = sbi->s_mount_opt; 947 old_opts.snapshot_cno = sbi->s_snapshot_cno; 948 was_snapshot = nilfs_test_opt(sbi, SNAPSHOT); 949 |
932 if (!parse_options(data, sb)) { | 950 if (!parse_options(data, sb, 1)) { |
933 err = -EINVAL; 934 goto restore_opts; 935 } 936 sb->s_flags = (sb->s_flags & ~MS_POSIXACL); 937 938 err = -EINVAL; | 951 err = -EINVAL; 952 goto restore_opts; 953 } 954 sb->s_flags = (sb->s_flags & ~MS_POSIXACL); 955 956 err = -EINVAL; |
939 if (was_snapshot) { 940 if (!(*flags & MS_RDONLY)) { 941 printk(KERN_ERR "NILFS (device %s): cannot remount " 942 "snapshot read/write.\n", 943 sb->s_id); 944 goto restore_opts; 945 } else if (sbi->s_snapshot_cno != old_opts.snapshot_cno) { 946 printk(KERN_ERR "NILFS (device %s): cannot " 947 "remount to a different snapshot.\n", 948 sb->s_id); 949 goto restore_opts; 950 } 951 } else { 952 if (nilfs_test_opt(sbi, SNAPSHOT)) { 953 printk(KERN_ERR "NILFS (device %s): cannot change " 954 "a regular mount to a snapshot.\n", 955 sb->s_id); 956 goto restore_opts; 957 } | 957 if (was_snapshot && !(*flags & MS_RDONLY)) { 958 printk(KERN_ERR "NILFS (device %s): cannot remount snapshot " 959 "read/write.\n", sb->s_id); 960 goto restore_opts; |
958 } 959 960 if (!nilfs_valid_fs(nilfs)) { 961 printk(KERN_WARNING "NILFS (device %s): couldn't " 962 "remount because the filesystem is in an " 963 "incomplete recovery state.\n", sb->s_id); 964 goto restore_opts; 965 } --- 330 unchanged lines hidden --- | 961 } 962 963 if (!nilfs_valid_fs(nilfs)) { 964 printk(KERN_WARNING "NILFS (device %s): couldn't " 965 "remount because the filesystem is in an " 966 "incomplete recovery state.\n", sb->s_id); 967 goto restore_opts; 968 } --- 330 unchanged lines hidden --- |