diff options
Diffstat (limited to 'fs/reiserfs/super.c')
-rw-r--r-- | fs/reiserfs/super.c | 124 |
1 files changed, 87 insertions, 37 deletions
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 1d40f2bd1970..2ec748ba0bd3 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/buffer_head.h> | 23 | #include <linux/buffer_head.h> |
24 | #include <linux/exportfs.h> | 24 | #include <linux/exportfs.h> |
25 | #include <linux/quotaops.h> | ||
25 | #include <linux/vfs.h> | 26 | #include <linux/vfs.h> |
26 | #include <linux/mnt_namespace.h> | 27 | #include <linux/mnt_namespace.h> |
27 | #include <linux/mount.h> | 28 | #include <linux/mount.h> |
@@ -182,7 +183,7 @@ static int finish_unfinished(struct super_block *s) | |||
182 | int ret = reiserfs_quota_on_mount(s, i); | 183 | int ret = reiserfs_quota_on_mount(s, i); |
183 | if (ret < 0) | 184 | if (ret < 0) |
184 | reiserfs_warning(s, | 185 | reiserfs_warning(s, |
185 | "reiserfs: cannot turn on journalled quota: error %d", | 186 | "reiserfs: cannot turn on journaled quota: error %d", |
186 | ret); | 187 | ret); |
187 | } | 188 | } |
188 | } | 189 | } |
@@ -876,7 +877,9 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin | |||
876 | mount options were selected. */ | 877 | mount options were selected. */ |
877 | unsigned long *blocks, /* strtol-ed from NNN of resize=NNN */ | 878 | unsigned long *blocks, /* strtol-ed from NNN of resize=NNN */ |
878 | char **jdev_name, | 879 | char **jdev_name, |
879 | unsigned int *commit_max_age) | 880 | unsigned int *commit_max_age, |
881 | char **qf_names, | ||
882 | unsigned int *qfmt) | ||
880 | { | 883 | { |
881 | int c; | 884 | int c; |
882 | char *arg = NULL; | 885 | char *arg = NULL; |
@@ -992,9 +995,11 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin | |||
992 | if (c == 'u' || c == 'g') { | 995 | if (c == 'u' || c == 'g') { |
993 | int qtype = c == 'u' ? USRQUOTA : GRPQUOTA; | 996 | int qtype = c == 'u' ? USRQUOTA : GRPQUOTA; |
994 | 997 | ||
995 | if (sb_any_quota_enabled(s)) { | 998 | if ((sb_any_quota_enabled(s) || |
999 | sb_any_quota_suspended(s)) && | ||
1000 | (!*arg != !REISERFS_SB(s)->s_qf_names[qtype])) { | ||
996 | reiserfs_warning(s, | 1001 | reiserfs_warning(s, |
997 | "reiserfs_parse_options: cannot change journalled quota options when quota turned on."); | 1002 | "reiserfs_parse_options: cannot change journaled quota options when quota turned on."); |
998 | return 0; | 1003 | return 0; |
999 | } | 1004 | } |
1000 | if (*arg) { /* Some filename specified? */ | 1005 | if (*arg) { /* Some filename specified? */ |
@@ -1011,46 +1016,54 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin | |||
1011 | "reiserfs_parse_options: quotafile must be on filesystem root."); | 1016 | "reiserfs_parse_options: quotafile must be on filesystem root."); |
1012 | return 0; | 1017 | return 0; |
1013 | } | 1018 | } |
1014 | REISERFS_SB(s)->s_qf_names[qtype] = | 1019 | qf_names[qtype] = |
1015 | kmalloc(strlen(arg) + 1, GFP_KERNEL); | 1020 | kmalloc(strlen(arg) + 1, GFP_KERNEL); |
1016 | if (!REISERFS_SB(s)->s_qf_names[qtype]) { | 1021 | if (!qf_names[qtype]) { |
1017 | reiserfs_warning(s, | 1022 | reiserfs_warning(s, |
1018 | "reiserfs_parse_options: not enough memory for storing quotafile name."); | 1023 | "reiserfs_parse_options: not enough memory for storing quotafile name."); |
1019 | return 0; | 1024 | return 0; |
1020 | } | 1025 | } |
1021 | strcpy(REISERFS_SB(s)->s_qf_names[qtype], arg); | 1026 | strcpy(qf_names[qtype], arg); |
1022 | *mount_options |= 1 << REISERFS_QUOTA; | 1027 | *mount_options |= 1 << REISERFS_QUOTA; |
1023 | } else { | 1028 | } else { |
1024 | kfree(REISERFS_SB(s)->s_qf_names[qtype]); | 1029 | if (qf_names[qtype] != |
1025 | REISERFS_SB(s)->s_qf_names[qtype] = NULL; | 1030 | REISERFS_SB(s)->s_qf_names[qtype]) |
1031 | kfree(qf_names[qtype]); | ||
1032 | qf_names[qtype] = NULL; | ||
1026 | } | 1033 | } |
1027 | } | 1034 | } |
1028 | if (c == 'f') { | 1035 | if (c == 'f') { |
1029 | if (!strcmp(arg, "vfsold")) | 1036 | if (!strcmp(arg, "vfsold")) |
1030 | REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_OLD; | 1037 | *qfmt = QFMT_VFS_OLD; |
1031 | else if (!strcmp(arg, "vfsv0")) | 1038 | else if (!strcmp(arg, "vfsv0")) |
1032 | REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_V0; | 1039 | *qfmt = QFMT_VFS_V0; |
1033 | else { | 1040 | else { |
1034 | reiserfs_warning(s, | 1041 | reiserfs_warning(s, |
1035 | "reiserfs_parse_options: unknown quota format specified."); | 1042 | "reiserfs_parse_options: unknown quota format specified."); |
1036 | return 0; | 1043 | return 0; |
1037 | } | 1044 | } |
1045 | if ((sb_any_quota_enabled(s) || | ||
1046 | sb_any_quota_suspended(s)) && | ||
1047 | *qfmt != REISERFS_SB(s)->s_jquota_fmt) { | ||
1048 | reiserfs_warning(s, | ||
1049 | "reiserfs_parse_options: cannot change journaled quota options when quota turned on."); | ||
1050 | return 0; | ||
1051 | } | ||
1038 | } | 1052 | } |
1039 | #else | 1053 | #else |
1040 | if (c == 'u' || c == 'g' || c == 'f') { | 1054 | if (c == 'u' || c == 'g' || c == 'f') { |
1041 | reiserfs_warning(s, | 1055 | reiserfs_warning(s, |
1042 | "reiserfs_parse_options: journalled quota options not supported."); | 1056 | "reiserfs_parse_options: journaled quota options not supported."); |
1043 | return 0; | 1057 | return 0; |
1044 | } | 1058 | } |
1045 | #endif | 1059 | #endif |
1046 | } | 1060 | } |
1047 | 1061 | ||
1048 | #ifdef CONFIG_QUOTA | 1062 | #ifdef CONFIG_QUOTA |
1049 | if (!REISERFS_SB(s)->s_jquota_fmt | 1063 | if (!REISERFS_SB(s)->s_jquota_fmt && !*qfmt |
1050 | && (REISERFS_SB(s)->s_qf_names[USRQUOTA] | 1064 | && (qf_names[USRQUOTA] || qf_names[GRPQUOTA])) { |
1051 | || REISERFS_SB(s)->s_qf_names[GRPQUOTA])) { | ||
1052 | reiserfs_warning(s, | 1065 | reiserfs_warning(s, |
1053 | "reiserfs_parse_options: journalled quota format not specified."); | 1066 | "reiserfs_parse_options: journaled quota format not specified."); |
1054 | return 0; | 1067 | return 0; |
1055 | } | 1068 | } |
1056 | /* This checking is not precise wrt the quota type but for our purposes it is sufficient */ | 1069 | /* This checking is not precise wrt the quota type but for our purposes it is sufficient */ |
@@ -1130,6 +1143,21 @@ static void handle_attrs(struct super_block *s) | |||
1130 | } | 1143 | } |
1131 | } | 1144 | } |
1132 | 1145 | ||
1146 | #ifdef CONFIG_QUOTA | ||
1147 | static void handle_quota_files(struct super_block *s, char **qf_names, | ||
1148 | unsigned int *qfmt) | ||
1149 | { | ||
1150 | int i; | ||
1151 | |||
1152 | for (i = 0; i < MAXQUOTAS; i++) { | ||
1153 | if (qf_names[i] != REISERFS_SB(s)->s_qf_names[i]) | ||
1154 | kfree(REISERFS_SB(s)->s_qf_names[i]); | ||
1155 | REISERFS_SB(s)->s_qf_names[i] = qf_names[i]; | ||
1156 | } | ||
1157 | REISERFS_SB(s)->s_jquota_fmt = *qfmt; | ||
1158 | } | ||
1159 | #endif | ||
1160 | |||
1133 | static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | 1161 | static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) |
1134 | { | 1162 | { |
1135 | struct reiserfs_super_block *rs; | 1163 | struct reiserfs_super_block *rs; |
@@ -1141,23 +1169,30 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) | |||
1141 | struct reiserfs_journal *journal = SB_JOURNAL(s); | 1169 | struct reiserfs_journal *journal = SB_JOURNAL(s); |
1142 | char *new_opts = kstrdup(arg, GFP_KERNEL); | 1170 | char *new_opts = kstrdup(arg, GFP_KERNEL); |
1143 | int err; | 1171 | int err; |
1172 | char *qf_names[MAXQUOTAS]; | ||
1173 | unsigned int qfmt = 0; | ||
1144 | #ifdef CONFIG_QUOTA | 1174 | #ifdef CONFIG_QUOTA |
1145 | int i; | 1175 | int i; |
1176 | |||
1177 | memcpy(qf_names, REISERFS_SB(s)->s_qf_names, sizeof(qf_names)); | ||
1146 | #endif | 1178 | #endif |
1147 | 1179 | ||
1148 | rs = SB_DISK_SUPER_BLOCK(s); | 1180 | rs = SB_DISK_SUPER_BLOCK(s); |
1149 | 1181 | ||
1150 | if (!reiserfs_parse_options | 1182 | if (!reiserfs_parse_options |
1151 | (s, arg, &mount_options, &blocks, NULL, &commit_max_age)) { | 1183 | (s, arg, &mount_options, &blocks, NULL, &commit_max_age, |
1184 | qf_names, &qfmt)) { | ||
1152 | #ifdef CONFIG_QUOTA | 1185 | #ifdef CONFIG_QUOTA |
1153 | for (i = 0; i < MAXQUOTAS; i++) { | 1186 | for (i = 0; i < MAXQUOTAS; i++) |
1154 | kfree(REISERFS_SB(s)->s_qf_names[i]); | 1187 | if (qf_names[i] != REISERFS_SB(s)->s_qf_names[i]) |
1155 | REISERFS_SB(s)->s_qf_names[i] = NULL; | 1188 | kfree(qf_names[i]); |
1156 | } | ||
1157 | #endif | 1189 | #endif |
1158 | err = -EINVAL; | 1190 | err = -EINVAL; |
1159 | goto out_err; | 1191 | goto out_err; |
1160 | } | 1192 | } |
1193 | #ifdef CONFIG_QUOTA | ||
1194 | handle_quota_files(s, qf_names, &qfmt); | ||
1195 | #endif | ||
1161 | 1196 | ||
1162 | handle_attrs(s); | 1197 | handle_attrs(s); |
1163 | 1198 | ||
@@ -1570,6 +1605,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1570 | char *jdev_name; | 1605 | char *jdev_name; |
1571 | struct reiserfs_sb_info *sbi; | 1606 | struct reiserfs_sb_info *sbi; |
1572 | int errval = -EINVAL; | 1607 | int errval = -EINVAL; |
1608 | char *qf_names[MAXQUOTAS] = {}; | ||
1609 | unsigned int qfmt = 0; | ||
1573 | 1610 | ||
1574 | save_mount_options(s, data); | 1611 | save_mount_options(s, data); |
1575 | 1612 | ||
@@ -1597,9 +1634,12 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1597 | jdev_name = NULL; | 1634 | jdev_name = NULL; |
1598 | if (reiserfs_parse_options | 1635 | if (reiserfs_parse_options |
1599 | (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name, | 1636 | (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name, |
1600 | &commit_max_age) == 0) { | 1637 | &commit_max_age, qf_names, &qfmt) == 0) { |
1601 | goto error; | 1638 | goto error; |
1602 | } | 1639 | } |
1640 | #ifdef CONFIG_QUOTA | ||
1641 | handle_quota_files(s, qf_names, &qfmt); | ||
1642 | #endif | ||
1603 | 1643 | ||
1604 | if (blocks) { | 1644 | if (blocks) { |
1605 | SWARN(silent, s, "jmacd-7: reiserfs_fill_super: resize option " | 1645 | SWARN(silent, s, "jmacd-7: reiserfs_fill_super: resize option " |
@@ -1819,7 +1859,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1819 | 1859 | ||
1820 | return (0); | 1860 | return (0); |
1821 | 1861 | ||
1822 | error: | 1862 | error: |
1823 | if (jinit_done) { /* kill the commit thread, free journal ram */ | 1863 | if (jinit_done) { /* kill the commit thread, free journal ram */ |
1824 | journal_release_error(NULL, s); | 1864 | journal_release_error(NULL, s); |
1825 | } | 1865 | } |
@@ -1830,10 +1870,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) | |||
1830 | #ifdef CONFIG_QUOTA | 1870 | #ifdef CONFIG_QUOTA |
1831 | { | 1871 | { |
1832 | int j; | 1872 | int j; |
1833 | for (j = 0; j < MAXQUOTAS; j++) { | 1873 | for (j = 0; j < MAXQUOTAS; j++) |
1834 | kfree(sbi->s_qf_names[j]); | 1874 | kfree(qf_names[j]); |
1835 | sbi->s_qf_names[j] = NULL; | ||
1836 | } | ||
1837 | } | 1875 | } |
1838 | #endif | 1876 | #endif |
1839 | kfree(sbi); | 1877 | kfree(sbi); |
@@ -1980,7 +2018,7 @@ static int reiserfs_release_dquot(struct dquot *dquot) | |||
1980 | 2018 | ||
1981 | static int reiserfs_mark_dquot_dirty(struct dquot *dquot) | 2019 | static int reiserfs_mark_dquot_dirty(struct dquot *dquot) |
1982 | { | 2020 | { |
1983 | /* Are we journalling quotas? */ | 2021 | /* Are we journaling quotas? */ |
1984 | if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] || | 2022 | if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] || |
1985 | REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) { | 2023 | REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) { |
1986 | dquot_mark_dquot_dirty(dquot); | 2024 | dquot_mark_dquot_dirty(dquot); |
@@ -2026,6 +2064,7 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, | |||
2026 | int err; | 2064 | int err; |
2027 | struct nameidata nd; | 2065 | struct nameidata nd; |
2028 | struct inode *inode; | 2066 | struct inode *inode; |
2067 | struct reiserfs_transaction_handle th; | ||
2029 | 2068 | ||
2030 | if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA))) | 2069 | if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA))) |
2031 | return -EINVAL; | 2070 | return -EINVAL; |
@@ -2053,17 +2092,28 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, | |||
2053 | } | 2092 | } |
2054 | mark_inode_dirty(inode); | 2093 | mark_inode_dirty(inode); |
2055 | } | 2094 | } |
2056 | /* Not journalling quota? No more tests needed... */ | 2095 | /* Journaling quota? */ |
2057 | if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] && | 2096 | if (REISERFS_SB(sb)->s_qf_names[type]) { |
2058 | !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) { | 2097 | /* Quotafile not of fs root? */ |
2059 | path_put(&nd.path); | 2098 | if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode) |
2060 | return vfs_quota_on(sb, type, format_id, path, 0); | 2099 | reiserfs_warning(sb, |
2061 | } | ||
2062 | /* Quotafile not of fs root? */ | ||
2063 | if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode) | ||
2064 | reiserfs_warning(sb, | ||
2065 | "reiserfs: Quota file not on filesystem root. " | 2100 | "reiserfs: Quota file not on filesystem root. " |
2066 | "Journalled quota will not work."); | 2101 | "Journalled quota will not work."); |
2102 | } | ||
2103 | |||
2104 | /* | ||
2105 | * When we journal data on quota file, we have to flush journal to see | ||
2106 | * all updates to the file when we bypass pagecache... | ||
2107 | */ | ||
2108 | if (reiserfs_file_data_log(inode)) { | ||
2109 | /* Just start temporary transaction and finish it */ | ||
2110 | err = journal_begin(&th, sb, 1); | ||
2111 | if (err) | ||
2112 | return err; | ||
2113 | err = journal_end_sync(&th, sb, 1); | ||
2114 | if (err) | ||
2115 | return err; | ||
2116 | } | ||
2067 | path_put(&nd.path); | 2117 | path_put(&nd.path); |
2068 | return vfs_quota_on(sb, type, format_id, path, 0); | 2118 | return vfs_quota_on(sb, type, format_id, path, 0); |
2069 | } | 2119 | } |