Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README |
| 3 | * |
| 4 | * Trivial changes by Alan Cox to add the LFS fixes |
| 5 | * |
| 6 | * Trivial Changes: |
| 7 | * Rights granted to Hans Reiser to redistribute under other terms providing |
| 8 | * he accepts all liability including but not limited to patent, fitness |
| 9 | * for purpose, and direct or indirect claims arising from failure to perform. |
| 10 | * |
| 11 | * NO WARRANTY |
| 12 | */ |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
| 15 | #include <linux/vmalloc.h> |
| 16 | #include <linux/time.h> |
| 17 | #include <asm/uaccess.h> |
| 18 | #include <linux/reiserfs_fs.h> |
| 19 | #include <linux/reiserfs_acl.h> |
| 20 | #include <linux/reiserfs_xattr.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/init.h> |
| 22 | #include <linux/blkdev.h> |
| 23 | #include <linux/buffer_head.h> |
Christoph Hellwig | a569425 | 2007-07-17 04:04:28 -0700 | [diff] [blame] | 24 | #include <linux/exportfs.h> |
Jan Kara | 74abb98 | 2008-07-25 01:46:51 -0700 | [diff] [blame] | 25 | #include <linux/quotaops.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/vfs.h> |
Kirill Korotaev | 6b3286e | 2006-12-08 02:37:56 -0800 | [diff] [blame] | 27 | #include <linux/mnt_namespace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include <linux/mount.h> |
| 29 | #include <linux/namei.h> |
| 30 | #include <linux/quotaops.h> |
| 31 | |
| 32 | struct file_system_type reiserfs_fs_type; |
| 33 | |
| 34 | static const char reiserfs_3_5_magic_string[] = REISERFS_SUPER_MAGIC_STRING; |
| 35 | static const char reiserfs_3_6_magic_string[] = REISER2FS_SUPER_MAGIC_STRING; |
| 36 | static const char reiserfs_jr_magic_string[] = REISER2FS_JR_SUPER_MAGIC_STRING; |
| 37 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 38 | int is_reiserfs_3_5(struct reiserfs_super_block *rs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 40 | return !strncmp(rs->s_v1.s_magic, reiserfs_3_5_magic_string, |
| 41 | strlen(reiserfs_3_5_magic_string)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 44 | int is_reiserfs_3_6(struct reiserfs_super_block *rs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 46 | return !strncmp(rs->s_v1.s_magic, reiserfs_3_6_magic_string, |
| 47 | strlen(reiserfs_3_6_magic_string)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 50 | int is_reiserfs_jr(struct reiserfs_super_block *rs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 52 | return !strncmp(rs->s_v1.s_magic, reiserfs_jr_magic_string, |
| 53 | strlen(reiserfs_jr_magic_string)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 56 | static int is_any_reiserfs_magic_string(struct reiserfs_super_block *rs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 58 | return (is_reiserfs_3_5(rs) || is_reiserfs_3_6(rs) || |
| 59 | is_reiserfs_jr(rs)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 62 | static int reiserfs_remount(struct super_block *s, int *flags, char *data); |
David Howells | 726c334 | 2006-06-23 02:02:58 -0700 | [diff] [blame] | 63 | static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 65 | static int reiserfs_sync_fs(struct super_block *s, int wait) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 67 | if (!(s->s_flags & MS_RDONLY)) { |
| 68 | struct reiserfs_transaction_handle th; |
| 69 | reiserfs_write_lock(s); |
| 70 | if (!journal_begin(&th, s, 1)) |
| 71 | if (!journal_end_sync(&th, s, 1)) |
| 72 | reiserfs_flush_old_commits(s); |
| 73 | s->s_dirt = 0; /* Even if it's not true. |
| 74 | * We'll loop forever in sync_supers otherwise */ |
| 75 | reiserfs_write_unlock(s); |
| 76 | } else { |
| 77 | s->s_dirt = 0; |
| 78 | } |
| 79 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | static void reiserfs_write_super(struct super_block *s) |
| 83 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 84 | reiserfs_sync_fs(s, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } |
| 86 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 87 | static void reiserfs_write_super_lockfs(struct super_block *s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 89 | struct reiserfs_transaction_handle th; |
| 90 | reiserfs_write_lock(s); |
| 91 | if (!(s->s_flags & MS_RDONLY)) { |
| 92 | int err = journal_begin(&th, s, 1); |
| 93 | if (err) { |
| 94 | reiserfs_block_writes(&th); |
| 95 | } else { |
| 96 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), |
| 97 | 1); |
| 98 | journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s)); |
| 99 | reiserfs_block_writes(&th); |
| 100 | journal_end_sync(&th, s, 1); |
| 101 | } |
| 102 | } |
| 103 | s->s_dirt = 0; |
| 104 | reiserfs_write_unlock(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 107 | static void reiserfs_unlockfs(struct super_block *s) |
| 108 | { |
| 109 | reiserfs_allow_writes(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 112 | extern const struct in_core_key MAX_IN_CORE_KEY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | /* this is used to delete "save link" when there are no items of a |
| 115 | file it points to. It can either happen if unlink is completed but |
| 116 | "save unlink" removal, or if file has both unlink and truncate |
| 117 | pending and as unlink completes first (because key of "save link" |
| 118 | protecting unlink is bigger that a key lf "save link" which |
| 119 | protects truncate), so there left no items to make truncate |
| 120 | completion on */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 121 | static int remove_save_link_only(struct super_block *s, |
| 122 | struct reiserfs_key *key, int oid_free) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 124 | struct reiserfs_transaction_handle th; |
| 125 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 127 | /* we are going to do one balancing */ |
| 128 | err = journal_begin(&th, s, JOURNAL_PER_BALANCE_CNT); |
| 129 | if (err) |
| 130 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 132 | reiserfs_delete_solid_item(&th, NULL, key); |
| 133 | if (oid_free) |
| 134 | /* removals are protected by direct items */ |
| 135 | reiserfs_release_objectid(&th, le32_to_cpu(key->k_objectid)); |
| 136 | |
| 137 | return journal_end(&th, s, JOURNAL_PER_BALANCE_CNT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | #ifdef CONFIG_QUOTA |
| 141 | static int reiserfs_quota_on_mount(struct super_block *, int); |
| 142 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | /* look for uncompleted unlinks and truncates and complete them */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 145 | static int finish_unfinished(struct super_block *s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 147 | INITIALIZE_PATH(path); |
| 148 | struct cpu_key max_cpu_key, obj_key; |
Lepton Wu | fb46f34 | 2007-10-16 23:30:04 -0700 | [diff] [blame] | 149 | struct reiserfs_key save_link_key, last_inode_key; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 150 | int retval = 0; |
| 151 | struct item_head *ih; |
| 152 | struct buffer_head *bh; |
| 153 | int item_pos; |
| 154 | char *item; |
| 155 | int done; |
| 156 | struct inode *inode; |
| 157 | int truncate; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | #ifdef CONFIG_QUOTA |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 159 | int i; |
| 160 | int ms_active_set; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 162 | |
| 163 | /* compose key to look for "save" links */ |
| 164 | max_cpu_key.version = KEY_FORMAT_3_5; |
| 165 | max_cpu_key.on_disk_key.k_dir_id = ~0U; |
| 166 | max_cpu_key.on_disk_key.k_objectid = ~0U; |
| 167 | set_cpu_key_k_offset(&max_cpu_key, ~0U); |
| 168 | max_cpu_key.key_length = 3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
Lepton Wu | fb46f34 | 2007-10-16 23:30:04 -0700 | [diff] [blame] | 170 | memset(&last_inode_key, 0, sizeof(last_inode_key)); |
| 171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | #ifdef CONFIG_QUOTA |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 173 | /* Needed for iput() to work correctly and not trash data */ |
| 174 | if (s->s_flags & MS_ACTIVE) { |
| 175 | ms_active_set = 0; |
| 176 | } else { |
| 177 | ms_active_set = 1; |
| 178 | s->s_flags |= MS_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 180 | /* Turn on quotas so that they are updated correctly */ |
| 181 | for (i = 0; i < MAXQUOTAS; i++) { |
| 182 | if (REISERFS_SB(s)->s_qf_names[i]) { |
| 183 | int ret = reiserfs_quota_on_mount(s, i); |
| 184 | if (ret < 0) |
| 185 | reiserfs_warning(s, |
Jan Kara | 4506567 | 2008-07-25 01:46:37 -0700 | [diff] [blame] | 186 | "reiserfs: cannot turn on journaled quota: error %d", |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 187 | ret); |
| 188 | } |
| 189 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 192 | done = 0; |
| 193 | REISERFS_SB(s)->s_is_unlinked_ok = 1; |
| 194 | while (!retval) { |
| 195 | retval = search_item(s, &max_cpu_key, &path); |
| 196 | if (retval != ITEM_NOT_FOUND) { |
| 197 | reiserfs_warning(s, |
| 198 | "vs-2140: finish_unfinished: search_by_key returned %d", |
| 199 | retval); |
| 200 | break; |
| 201 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 203 | bh = get_last_bh(&path); |
| 204 | item_pos = get_item_pos(&path); |
| 205 | if (item_pos != B_NR_ITEMS(bh)) { |
| 206 | reiserfs_warning(s, |
| 207 | "vs-2060: finish_unfinished: wrong position found"); |
| 208 | break; |
| 209 | } |
| 210 | item_pos--; |
| 211 | ih = B_N_PITEM_HEAD(bh, item_pos); |
| 212 | |
| 213 | if (le32_to_cpu(ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID) |
| 214 | /* there are no "save" links anymore */ |
| 215 | break; |
| 216 | |
| 217 | save_link_key = ih->ih_key; |
| 218 | if (is_indirect_le_ih(ih)) |
| 219 | truncate = 1; |
| 220 | else |
| 221 | truncate = 0; |
| 222 | |
| 223 | /* reiserfs_iget needs k_dirid and k_objectid only */ |
| 224 | item = B_I_PITEM(bh, ih); |
| 225 | obj_key.on_disk_key.k_dir_id = le32_to_cpu(*(__le32 *) item); |
| 226 | obj_key.on_disk_key.k_objectid = |
| 227 | le32_to_cpu(ih->ih_key.k_objectid); |
| 228 | obj_key.on_disk_key.k_offset = 0; |
| 229 | obj_key.on_disk_key.k_type = 0; |
| 230 | |
| 231 | pathrelse(&path); |
| 232 | |
| 233 | inode = reiserfs_iget(s, &obj_key); |
| 234 | if (!inode) { |
| 235 | /* the unlink almost completed, it just did not manage to remove |
| 236 | "save" link and release objectid */ |
| 237 | reiserfs_warning(s, |
| 238 | "vs-2180: finish_unfinished: iget failed for %K", |
| 239 | &obj_key); |
| 240 | retval = remove_save_link_only(s, &save_link_key, 1); |
| 241 | continue; |
| 242 | } |
| 243 | |
| 244 | if (!truncate && inode->i_nlink) { |
| 245 | /* file is not unlinked */ |
| 246 | reiserfs_warning(s, |
| 247 | "vs-2185: finish_unfinished: file %K is not unlinked", |
| 248 | &obj_key); |
| 249 | retval = remove_save_link_only(s, &save_link_key, 0); |
| 250 | continue; |
| 251 | } |
| 252 | DQUOT_INIT(inode); |
| 253 | |
| 254 | if (truncate && S_ISDIR(inode->i_mode)) { |
| 255 | /* We got a truncate request for a dir which is impossible. |
| 256 | The only imaginable way is to execute unfinished truncate request |
| 257 | then boot into old kernel, remove the file and create dir with |
| 258 | the same key. */ |
| 259 | reiserfs_warning(s, |
| 260 | "green-2101: impossible truncate on a directory %k. Please report", |
| 261 | INODE_PKEY(inode)); |
| 262 | retval = remove_save_link_only(s, &save_link_key, 0); |
| 263 | truncate = 0; |
| 264 | iput(inode); |
| 265 | continue; |
| 266 | } |
| 267 | |
| 268 | if (truncate) { |
| 269 | REISERFS_I(inode)->i_flags |= |
| 270 | i_link_saved_truncate_mask; |
| 271 | /* not completed truncate found. New size was committed together |
| 272 | with "save" link */ |
| 273 | reiserfs_info(s, "Truncating %k to %Ld ..", |
| 274 | INODE_PKEY(inode), inode->i_size); |
| 275 | reiserfs_truncate_file(inode, |
| 276 | 0 |
| 277 | /*don't update modification time */ |
| 278 | ); |
| 279 | retval = remove_save_link(inode, truncate); |
| 280 | } else { |
| 281 | REISERFS_I(inode)->i_flags |= i_link_saved_unlink_mask; |
| 282 | /* not completed unlink (rmdir) found */ |
| 283 | reiserfs_info(s, "Removing %k..", INODE_PKEY(inode)); |
Lepton Wu | fb46f34 | 2007-10-16 23:30:04 -0700 | [diff] [blame] | 284 | if (memcmp(&last_inode_key, INODE_PKEY(inode), |
| 285 | sizeof(last_inode_key))){ |
| 286 | last_inode_key = *INODE_PKEY(inode); |
| 287 | /* removal gets completed in iput */ |
| 288 | retval = 0; |
| 289 | } else { |
| 290 | reiserfs_warning(s, "Dead loop in " |
| 291 | "finish_unfinished detected, " |
| 292 | "just remove save link\n"); |
| 293 | retval = remove_save_link_only(s, |
| 294 | &save_link_key, 0); |
| 295 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | iput(inode); |
| 299 | printk("done\n"); |
| 300 | done++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 302 | REISERFS_SB(s)->s_is_unlinked_ok = 0; |
| 303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | #ifdef CONFIG_QUOTA |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 305 | /* Turn quotas off */ |
| 306 | for (i = 0; i < MAXQUOTAS; i++) { |
| 307 | if (sb_dqopt(s)->files[i]) |
Jan Kara | 1b445a9 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 308 | vfs_quota_off(s, i, 0); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 309 | } |
| 310 | if (ms_active_set) |
| 311 | /* Restore the flag back */ |
| 312 | s->s_flags &= ~MS_ACTIVE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 314 | pathrelse(&path); |
| 315 | if (done) |
| 316 | reiserfs_info(s, "There were %d uncompleted unlinks/truncates. " |
| 317 | "Completed\n", done); |
| 318 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 320 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | /* to protect file being unlinked from getting lost we "safe" link files |
| 322 | being unlinked. This link will be deleted in the same transaction with last |
Robert P. J. Day | 3a4fa0a | 2007-10-19 23:10:43 +0200 | [diff] [blame] | 323 | item of file. mounting the filesystem we scan all these links and remove |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | files which almost got lost */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 325 | void add_save_link(struct reiserfs_transaction_handle *th, |
| 326 | struct inode *inode, int truncate) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 328 | INITIALIZE_PATH(path); |
| 329 | int retval; |
| 330 | struct cpu_key key; |
| 331 | struct item_head ih; |
| 332 | __le32 link; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 334 | BUG_ON(!th->t_trans_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 336 | /* file can only get one "save link" of each kind */ |
| 337 | RFALSE(truncate && |
| 338 | (REISERFS_I(inode)->i_flags & i_link_saved_truncate_mask), |
| 339 | "saved link already exists for truncated inode %lx", |
| 340 | (long)inode->i_ino); |
| 341 | RFALSE(!truncate && |
| 342 | (REISERFS_I(inode)->i_flags & i_link_saved_unlink_mask), |
| 343 | "saved link already exists for unlinked inode %lx", |
| 344 | (long)inode->i_ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 346 | /* setup key of "save" link */ |
| 347 | key.version = KEY_FORMAT_3_5; |
| 348 | key.on_disk_key.k_dir_id = MAX_KEY_OBJECTID; |
| 349 | key.on_disk_key.k_objectid = inode->i_ino; |
| 350 | if (!truncate) { |
| 351 | /* unlink, rmdir, rename */ |
| 352 | set_cpu_key_k_offset(&key, 1 + inode->i_sb->s_blocksize); |
| 353 | set_cpu_key_k_type(&key, TYPE_DIRECT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 355 | /* item head of "safe" link */ |
| 356 | make_le_item_head(&ih, &key, key.version, |
| 357 | 1 + inode->i_sb->s_blocksize, TYPE_DIRECT, |
| 358 | 4 /*length */ , 0xffff /*free space */ ); |
| 359 | } else { |
| 360 | /* truncate */ |
| 361 | if (S_ISDIR(inode->i_mode)) |
| 362 | reiserfs_warning(inode->i_sb, |
| 363 | "green-2102: Adding a truncate savelink for a directory %k! Please report", |
| 364 | INODE_PKEY(inode)); |
| 365 | set_cpu_key_k_offset(&key, 1); |
| 366 | set_cpu_key_k_type(&key, TYPE_INDIRECT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 368 | /* item head of "safe" link */ |
| 369 | make_le_item_head(&ih, &key, key.version, 1, TYPE_INDIRECT, |
| 370 | 4 /*length */ , 0 /*free space */ ); |
| 371 | } |
| 372 | key.key_length = 3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 374 | /* look for its place in the tree */ |
| 375 | retval = search_item(inode->i_sb, &key, &path); |
| 376 | if (retval != ITEM_NOT_FOUND) { |
| 377 | if (retval != -ENOSPC) |
| 378 | reiserfs_warning(inode->i_sb, "vs-2100: add_save_link:" |
| 379 | "search_by_key (%K) returned %d", &key, |
| 380 | retval); |
| 381 | pathrelse(&path); |
| 382 | return; |
| 383 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 385 | /* body of "save" link */ |
| 386 | link = INODE_PKEY(inode)->k_dir_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 388 | /* put "save" link inot tree, don't charge quota to anyone */ |
| 389 | retval = |
| 390 | reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link); |
| 391 | if (retval) { |
| 392 | if (retval != -ENOSPC) |
| 393 | reiserfs_warning(inode->i_sb, |
| 394 | "vs-2120: add_save_link: insert_item returned %d", |
| 395 | retval); |
| 396 | } else { |
| 397 | if (truncate) |
| 398 | REISERFS_I(inode)->i_flags |= |
| 399 | i_link_saved_truncate_mask; |
| 400 | else |
| 401 | REISERFS_I(inode)->i_flags |= i_link_saved_unlink_mask; |
| 402 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | } |
| 404 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | /* this opens transaction unlike add_save_link */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 406 | int remove_save_link(struct inode *inode, int truncate) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 408 | struct reiserfs_transaction_handle th; |
| 409 | struct reiserfs_key key; |
| 410 | int err; |
| 411 | |
| 412 | /* we are going to do one balancing only */ |
| 413 | err = journal_begin(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT); |
| 414 | if (err) |
| 415 | return err; |
| 416 | |
| 417 | /* setup key of "save" link */ |
| 418 | key.k_dir_id = cpu_to_le32(MAX_KEY_OBJECTID); |
| 419 | key.k_objectid = INODE_PKEY(inode)->k_objectid; |
| 420 | if (!truncate) { |
| 421 | /* unlink, rmdir, rename */ |
| 422 | set_le_key_k_offset(KEY_FORMAT_3_5, &key, |
| 423 | 1 + inode->i_sb->s_blocksize); |
| 424 | set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_DIRECT); |
| 425 | } else { |
| 426 | /* truncate */ |
| 427 | set_le_key_k_offset(KEY_FORMAT_3_5, &key, 1); |
| 428 | set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_INDIRECT); |
| 429 | } |
| 430 | |
| 431 | if ((truncate && |
| 432 | (REISERFS_I(inode)->i_flags & i_link_saved_truncate_mask)) || |
| 433 | (!truncate && |
| 434 | (REISERFS_I(inode)->i_flags & i_link_saved_unlink_mask))) |
| 435 | /* don't take quota bytes from anywhere */ |
| 436 | reiserfs_delete_solid_item(&th, NULL, &key); |
| 437 | if (!truncate) { |
| 438 | reiserfs_release_objectid(&th, inode->i_ino); |
| 439 | REISERFS_I(inode)->i_flags &= ~i_link_saved_unlink_mask; |
| 440 | } else |
| 441 | REISERFS_I(inode)->i_flags &= ~i_link_saved_truncate_mask; |
| 442 | |
| 443 | return journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | } |
| 445 | |
David Howells | edc666e | 2006-10-11 01:22:14 -0700 | [diff] [blame] | 446 | static void reiserfs_kill_sb(struct super_block *s) |
| 447 | { |
| 448 | if (REISERFS_SB(s)) { |
Alexey Dobriyan | fe08a9d | 2007-05-08 00:24:55 -0700 | [diff] [blame] | 449 | #ifdef CONFIG_REISERFS_FS_XATTR |
David Howells | edc666e | 2006-10-11 01:22:14 -0700 | [diff] [blame] | 450 | if (REISERFS_SB(s)->xattr_root) { |
| 451 | d_invalidate(REISERFS_SB(s)->xattr_root); |
| 452 | dput(REISERFS_SB(s)->xattr_root); |
| 453 | REISERFS_SB(s)->xattr_root = NULL; |
| 454 | } |
Alexey Dobriyan | fe08a9d | 2007-05-08 00:24:55 -0700 | [diff] [blame] | 455 | #endif |
David Howells | edc666e | 2006-10-11 01:22:14 -0700 | [diff] [blame] | 456 | if (REISERFS_SB(s)->priv_root) { |
| 457 | d_invalidate(REISERFS_SB(s)->priv_root); |
| 458 | dput(REISERFS_SB(s)->priv_root); |
| 459 | REISERFS_SB(s)->priv_root = NULL; |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | kill_block_super(s); |
| 464 | } |
| 465 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 466 | static void reiserfs_put_super(struct super_block *s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 468 | struct reiserfs_transaction_handle th; |
| 469 | th.t_trans_id = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 471 | /* change file system state to current state if it was mounted with read-write permissions */ |
| 472 | if (!(s->s_flags & MS_RDONLY)) { |
| 473 | if (!journal_begin(&th, s, 10)) { |
| 474 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), |
| 475 | 1); |
| 476 | set_sb_umount_state(SB_DISK_SUPER_BLOCK(s), |
| 477 | REISERFS_SB(s)->s_mount_state); |
| 478 | journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s)); |
| 479 | } |
| 480 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 482 | /* note, journal_release checks for readonly mount, and can decide not |
| 483 | ** to do a journal_end |
| 484 | */ |
| 485 | journal_release(&th, s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | |
Jeff Mahoney | 5065227 | 2006-09-30 23:28:44 -0700 | [diff] [blame] | 487 | reiserfs_free_bitmap_cache(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 489 | brelse(SB_BUFFER_WITH_SB(s)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 491 | print_statistics(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 493 | if (REISERFS_SB(s)->reserved_blocks != 0) { |
| 494 | reiserfs_warning(s, |
| 495 | "green-2005: reiserfs_put_super: reserved blocks left %d", |
| 496 | REISERFS_SB(s)->reserved_blocks); |
| 497 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 499 | reiserfs_proc_info_done(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 501 | kfree(s->s_fs_info); |
| 502 | s->s_fs_info = NULL; |
| 503 | |
| 504 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | } |
| 506 | |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 507 | static struct kmem_cache *reiserfs_inode_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | |
| 509 | static struct inode *reiserfs_alloc_inode(struct super_block *sb) |
| 510 | { |
| 511 | struct reiserfs_inode_info *ei; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 512 | ei = (struct reiserfs_inode_info *) |
Christoph Lameter | e94b176 | 2006-12-06 20:33:17 -0800 | [diff] [blame] | 513 | kmem_cache_alloc(reiserfs_inode_cachep, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | if (!ei) |
| 515 | return NULL; |
| 516 | return &ei->vfs_inode; |
| 517 | } |
| 518 | |
| 519 | static void reiserfs_destroy_inode(struct inode *inode) |
| 520 | { |
| 521 | kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); |
| 522 | } |
| 523 | |
Alexey Dobriyan | 51cc506 | 2008-07-25 19:45:34 -0700 | [diff] [blame] | 524 | static void init_once(void *foo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 526 | struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | |
Christoph Lameter | a35afb8 | 2007-05-16 22:10:57 -0700 | [diff] [blame] | 528 | INIT_LIST_HEAD(&ei->i_prealloc_list); |
| 529 | inode_init_once(&ei->vfs_inode); |
Alexey Dobriyan | cfe1467 | 2006-09-29 02:00:00 -0700 | [diff] [blame] | 530 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL |
Christoph Lameter | a35afb8 | 2007-05-16 22:10:57 -0700 | [diff] [blame] | 531 | ei->i_acl_access = NULL; |
| 532 | ei->i_acl_default = NULL; |
Alexey Dobriyan | cfe1467 | 2006-09-29 02:00:00 -0700 | [diff] [blame] | 533 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | static int init_inodecache(void) |
| 537 | { |
| 538 | reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache", |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 539 | sizeof(struct |
| 540 | reiserfs_inode_info), |
Paul Jackson | fffb60f | 2006-03-24 03:16:06 -0800 | [diff] [blame] | 541 | 0, (SLAB_RECLAIM_ACCOUNT| |
| 542 | SLAB_MEM_SPREAD), |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 543 | init_once); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | if (reiserfs_inode_cachep == NULL) |
| 545 | return -ENOMEM; |
| 546 | return 0; |
| 547 | } |
| 548 | |
| 549 | static void destroy_inodecache(void) |
| 550 | { |
Alexey Dobriyan | 1a1d92c | 2006-09-27 01:49:40 -0700 | [diff] [blame] | 551 | kmem_cache_destroy(reiserfs_inode_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | /* we don't mark inodes dirty, we just log them */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 555 | static void reiserfs_dirty_inode(struct inode *inode) |
| 556 | { |
| 557 | struct reiserfs_transaction_handle th; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 559 | int err = 0; |
| 560 | if (inode->i_sb->s_flags & MS_RDONLY) { |
| 561 | reiserfs_warning(inode->i_sb, |
| 562 | "clm-6006: writing inode %lu on readonly FS", |
| 563 | inode->i_ino); |
| 564 | return; |
| 565 | } |
| 566 | reiserfs_write_lock(inode->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 568 | /* this is really only used for atime updates, so they don't have |
| 569 | ** to be included in O_SYNC or fsync |
| 570 | */ |
| 571 | err = journal_begin(&th, inode->i_sb, 1); |
| 572 | if (err) { |
| 573 | reiserfs_write_unlock(inode->i_sb); |
| 574 | return; |
| 575 | } |
| 576 | reiserfs_update_sd(&th, inode); |
| 577 | journal_end(&th, inode->i_sb, 1); |
| 578 | reiserfs_write_unlock(inode->i_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | } |
| 580 | |
Alexey Dobriyan | cfe1467 | 2006-09-29 02:00:00 -0700 | [diff] [blame] | 581 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 582 | static void reiserfs_clear_inode(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 584 | struct posix_acl *acl; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 586 | acl = REISERFS_I(inode)->i_acl_access; |
| 587 | if (acl && !IS_ERR(acl)) |
| 588 | posix_acl_release(acl); |
| 589 | REISERFS_I(inode)->i_acl_access = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 591 | acl = REISERFS_I(inode)->i_acl_default; |
| 592 | if (acl && !IS_ERR(acl)) |
| 593 | posix_acl_release(acl); |
| 594 | REISERFS_I(inode)->i_acl_default = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | } |
Alexey Dobriyan | cfe1467 | 2006-09-29 02:00:00 -0700 | [diff] [blame] | 596 | #else |
| 597 | #define reiserfs_clear_inode NULL |
| 598 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | |
| 600 | #ifdef CONFIG_QUOTA |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 601 | static ssize_t reiserfs_quota_write(struct super_block *, int, const char *, |
| 602 | size_t, loff_t); |
| 603 | static ssize_t reiserfs_quota_read(struct super_block *, int, char *, size_t, |
| 604 | loff_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | #endif |
| 606 | |
Josef 'Jeff' Sipek | ee9b6d6 | 2007-02-12 00:55:41 -0800 | [diff] [blame] | 607 | static const struct super_operations reiserfs_sops = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 608 | .alloc_inode = reiserfs_alloc_inode, |
| 609 | .destroy_inode = reiserfs_destroy_inode, |
| 610 | .write_inode = reiserfs_write_inode, |
| 611 | .dirty_inode = reiserfs_dirty_inode, |
| 612 | .delete_inode = reiserfs_delete_inode, |
| 613 | .clear_inode = reiserfs_clear_inode, |
| 614 | .put_super = reiserfs_put_super, |
| 615 | .write_super = reiserfs_write_super, |
| 616 | .sync_fs = reiserfs_sync_fs, |
| 617 | .write_super_lockfs = reiserfs_write_super_lockfs, |
| 618 | .unlockfs = reiserfs_unlockfs, |
| 619 | .statfs = reiserfs_statfs, |
| 620 | .remount_fs = reiserfs_remount, |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 621 | .show_options = generic_show_options, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | #ifdef CONFIG_QUOTA |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 623 | .quota_read = reiserfs_quota_read, |
| 624 | .quota_write = reiserfs_quota_write, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | #endif |
| 626 | }; |
| 627 | |
| 628 | #ifdef CONFIG_QUOTA |
| 629 | #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group") |
| 630 | |
| 631 | static int reiserfs_dquot_initialize(struct inode *, int); |
| 632 | static int reiserfs_dquot_drop(struct inode *); |
| 633 | static int reiserfs_write_dquot(struct dquot *); |
| 634 | static int reiserfs_acquire_dquot(struct dquot *); |
| 635 | static int reiserfs_release_dquot(struct dquot *); |
| 636 | static int reiserfs_mark_dquot_dirty(struct dquot *); |
| 637 | static int reiserfs_write_info(struct super_block *, int); |
Jan Kara | 1b445a9 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 638 | static int reiserfs_quota_on(struct super_block *, int, int, char *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 640 | static struct dquot_operations reiserfs_quota_operations = { |
| 641 | .initialize = reiserfs_dquot_initialize, |
| 642 | .drop = reiserfs_dquot_drop, |
| 643 | .alloc_space = dquot_alloc_space, |
| 644 | .alloc_inode = dquot_alloc_inode, |
| 645 | .free_space = dquot_free_space, |
| 646 | .free_inode = dquot_free_inode, |
| 647 | .transfer = dquot_transfer, |
| 648 | .write_dquot = reiserfs_write_dquot, |
| 649 | .acquire_dquot = reiserfs_acquire_dquot, |
| 650 | .release_dquot = reiserfs_release_dquot, |
| 651 | .mark_dirty = reiserfs_mark_dquot_dirty, |
| 652 | .write_info = reiserfs_write_info, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | }; |
| 654 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 655 | static struct quotactl_ops reiserfs_qctl_operations = { |
| 656 | .quota_on = reiserfs_quota_on, |
| 657 | .quota_off = vfs_quota_off, |
| 658 | .quota_sync = vfs_quota_sync, |
| 659 | .get_info = vfs_get_dqinfo, |
| 660 | .set_info = vfs_set_dqinfo, |
| 661 | .get_dqblk = vfs_get_dqblk, |
| 662 | .set_dqblk = vfs_set_dqblk, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | }; |
| 664 | #endif |
| 665 | |
Christoph Hellwig | 3965516 | 2007-10-21 16:42:17 -0700 | [diff] [blame] | 666 | static const struct export_operations reiserfs_export_ops = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 667 | .encode_fh = reiserfs_encode_fh, |
Christoph Hellwig | be55caf | 2007-10-21 16:42:13 -0700 | [diff] [blame] | 668 | .fh_to_dentry = reiserfs_fh_to_dentry, |
| 669 | .fh_to_parent = reiserfs_fh_to_parent, |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 670 | .get_parent = reiserfs_get_parent, |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 671 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
| 673 | /* this struct is used in reiserfs_getopt () for containing the value for those |
| 674 | mount options that have values rather than being toggles. */ |
| 675 | typedef struct { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 676 | char *value; |
| 677 | int setmask; /* bitmask which is to set on mount_options bitmask when this |
| 678 | value is found, 0 is no bits are to be changed. */ |
| 679 | int clrmask; /* bitmask which is to clear on mount_options bitmask when this |
| 680 | value is found, 0 is no bits are to be changed. This is |
| 681 | applied BEFORE setmask */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | } arg_desc_t; |
| 683 | |
| 684 | /* Set this bit in arg_required to allow empty arguments */ |
| 685 | #define REISERFS_OPT_ALLOWEMPTY 31 |
| 686 | |
| 687 | /* this struct is used in reiserfs_getopt() for describing the set of reiserfs |
| 688 | mount options */ |
| 689 | typedef struct { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 690 | char *option_name; |
| 691 | int arg_required; /* 0 if argument is not required, not 0 otherwise */ |
| 692 | const arg_desc_t *values; /* list of values accepted by an option */ |
| 693 | int setmask; /* bitmask which is to set on mount_options bitmask when this |
| 694 | value is found, 0 is no bits are to be changed. */ |
| 695 | int clrmask; /* bitmask which is to clear on mount_options bitmask when this |
| 696 | value is found, 0 is no bits are to be changed. This is |
| 697 | applied BEFORE setmask */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | } opt_desc_t; |
| 699 | |
| 700 | /* possible values for -o data= */ |
| 701 | static const arg_desc_t logging_mode[] = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 702 | {"ordered", 1 << REISERFS_DATA_ORDERED, |
| 703 | (1 << REISERFS_DATA_LOG | 1 << REISERFS_DATA_WRITEBACK)}, |
| 704 | {"journal", 1 << REISERFS_DATA_LOG, |
| 705 | (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)}, |
| 706 | {"writeback", 1 << REISERFS_DATA_WRITEBACK, |
| 707 | (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)}, |
Vladimir V. Saveliev | cd02b96 | 2006-03-25 03:07:15 -0800 | [diff] [blame] | 708 | {.value = NULL} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | }; |
| 710 | |
| 711 | /* possible values for -o barrier= */ |
| 712 | static const arg_desc_t barrier_mode[] = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 713 | {"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH}, |
| 714 | {"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE}, |
Vladimir V. Saveliev | cd02b96 | 2006-03-25 03:07:15 -0800 | [diff] [blame] | 715 | {.value = NULL} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | }; |
| 717 | |
| 718 | /* possible values for "-o block-allocator=" and bits which are to be set in |
| 719 | s_mount_opt of reiserfs specific part of in-core super block */ |
| 720 | static const arg_desc_t balloc[] = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 721 | {"noborder", 1 << REISERFS_NO_BORDER, 0}, |
| 722 | {"border", 0, 1 << REISERFS_NO_BORDER}, |
| 723 | {"no_unhashed_relocation", 1 << REISERFS_NO_UNHASHED_RELOCATION, 0}, |
| 724 | {"hashed_relocation", 1 << REISERFS_HASHED_RELOCATION, 0}, |
| 725 | {"test4", 1 << REISERFS_TEST4, 0}, |
| 726 | {"notest4", 0, 1 << REISERFS_TEST4}, |
| 727 | {NULL, 0, 0} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | }; |
| 729 | |
| 730 | static const arg_desc_t tails[] = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 731 | {"on", 1 << REISERFS_LARGETAIL, 1 << REISERFS_SMALLTAIL}, |
| 732 | {"off", 0, (1 << REISERFS_LARGETAIL) | (1 << REISERFS_SMALLTAIL)}, |
| 733 | {"small", 1 << REISERFS_SMALLTAIL, 1 << REISERFS_LARGETAIL}, |
| 734 | {NULL, 0, 0} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | }; |
| 736 | |
| 737 | static const arg_desc_t error_actions[] = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 738 | {"panic", 1 << REISERFS_ERROR_PANIC, |
| 739 | (1 << REISERFS_ERROR_RO | 1 << REISERFS_ERROR_CONTINUE)}, |
| 740 | {"ro-remount", 1 << REISERFS_ERROR_RO, |
| 741 | (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_CONTINUE)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | #ifdef REISERFS_JOURNAL_ERROR_ALLOWS_NO_LOG |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 743 | {"continue", 1 << REISERFS_ERROR_CONTINUE, |
| 744 | (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_RO)}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 746 | {NULL, 0, 0}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | }; |
| 748 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | /* proceed only one option from a list *cur - string containing of mount options |
| 750 | opts - array of options which are accepted |
| 751 | opt_arg - if option is found and requires an argument and if it is specifed |
| 752 | in the input - pointer to the argument is stored here |
| 753 | bit_flags - if option requires to set a certain bit - it is set here |
| 754 | return -1 if unknown option is found, opt->arg_required otherwise */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 755 | static int reiserfs_getopt(struct super_block *s, char **cur, opt_desc_t * opts, |
| 756 | char **opt_arg, unsigned long *bit_flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 758 | char *p; |
| 759 | /* foo=bar, |
| 760 | ^ ^ ^ |
| 761 | | | +-- option_end |
| 762 | | +-- arg_start |
| 763 | +-- option_start |
| 764 | */ |
| 765 | const opt_desc_t *opt; |
| 766 | const arg_desc_t *arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 768 | p = *cur; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 770 | /* assume argument cannot contain commas */ |
| 771 | *cur = strchr(p, ','); |
| 772 | if (*cur) { |
| 773 | *(*cur) = '\0'; |
| 774 | (*cur)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 777 | if (!strncmp(p, "alloc=", 6)) { |
| 778 | /* Ugly special case, probably we should redo options parser so that |
| 779 | it can understand several arguments for some options, also so that |
| 780 | it can fill several bitfields with option values. */ |
| 781 | if (reiserfs_parse_alloc_options(s, p + 6)) { |
| 782 | return -1; |
| 783 | } else { |
| 784 | return 0; |
| 785 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 787 | |
| 788 | /* for every option in the list */ |
| 789 | for (opt = opts; opt->option_name; opt++) { |
| 790 | if (!strncmp(p, opt->option_name, strlen(opt->option_name))) { |
| 791 | if (bit_flags) { |
| 792 | if (opt->clrmask == |
| 793 | (1 << REISERFS_UNSUPPORTED_OPT)) |
| 794 | reiserfs_warning(s, "%s not supported.", |
| 795 | p); |
| 796 | else |
| 797 | *bit_flags &= ~opt->clrmask; |
| 798 | if (opt->setmask == |
| 799 | (1 << REISERFS_UNSUPPORTED_OPT)) |
| 800 | reiserfs_warning(s, "%s not supported.", |
| 801 | p); |
| 802 | else |
| 803 | *bit_flags |= opt->setmask; |
| 804 | } |
| 805 | break; |
| 806 | } |
| 807 | } |
| 808 | if (!opt->option_name) { |
| 809 | reiserfs_warning(s, "unknown mount option \"%s\"", p); |
| 810 | return -1; |
| 811 | } |
| 812 | |
| 813 | p += strlen(opt->option_name); |
| 814 | switch (*p) { |
| 815 | case '=': |
| 816 | if (!opt->arg_required) { |
| 817 | reiserfs_warning(s, |
| 818 | "the option \"%s\" does not require an argument", |
| 819 | opt->option_name); |
| 820 | return -1; |
| 821 | } |
| 822 | break; |
| 823 | |
| 824 | case 0: |
| 825 | if (opt->arg_required) { |
| 826 | reiserfs_warning(s, |
| 827 | "the option \"%s\" requires an argument", |
| 828 | opt->option_name); |
| 829 | return -1; |
| 830 | } |
| 831 | break; |
| 832 | default: |
| 833 | reiserfs_warning(s, "head of option \"%s\" is only correct", |
| 834 | opt->option_name); |
| 835 | return -1; |
| 836 | } |
| 837 | |
| 838 | /* move to the argument, or to next option if argument is not required */ |
| 839 | p++; |
| 840 | |
| 841 | if (opt->arg_required |
| 842 | && !(opt->arg_required & (1 << REISERFS_OPT_ALLOWEMPTY)) |
| 843 | && !strlen(p)) { |
| 844 | /* this catches "option=," if not allowed */ |
| 845 | reiserfs_warning(s, "empty argument for \"%s\"", |
| 846 | opt->option_name); |
| 847 | return -1; |
| 848 | } |
| 849 | |
| 850 | if (!opt->values) { |
| 851 | /* *=NULLopt_arg contains pointer to argument */ |
| 852 | *opt_arg = p; |
| 853 | return opt->arg_required & ~(1 << REISERFS_OPT_ALLOWEMPTY); |
| 854 | } |
| 855 | |
| 856 | /* values possible for this option are listed in opt->values */ |
| 857 | for (arg = opt->values; arg->value; arg++) { |
| 858 | if (!strcmp(p, arg->value)) { |
| 859 | if (bit_flags) { |
| 860 | *bit_flags &= ~arg->clrmask; |
| 861 | *bit_flags |= arg->setmask; |
| 862 | } |
| 863 | return opt->arg_required; |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | reiserfs_warning(s, "bad value \"%s\" for option \"%s\"", p, |
| 868 | opt->option_name); |
| 869 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | /* returns 0 if something is wrong in option string, 1 - otherwise */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 873 | static int reiserfs_parse_options(struct super_block *s, char *options, /* string given via mount's -o */ |
| 874 | unsigned long *mount_options, |
| 875 | /* after the parsing phase, contains the |
| 876 | collection of bitflags defining what |
| 877 | mount options were selected. */ |
| 878 | unsigned long *blocks, /* strtol-ed from NNN of resize=NNN */ |
| 879 | char **jdev_name, |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 880 | unsigned int *commit_max_age, |
| 881 | char **qf_names, |
| 882 | unsigned int *qfmt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 884 | int c; |
| 885 | char *arg = NULL; |
| 886 | char *pos; |
| 887 | opt_desc_t opts[] = { |
| 888 | /* Compatibility stuff, so that -o notail for old setups still work */ |
| 889 | {"tails",.arg_required = 't',.values = tails}, |
| 890 | {"notail",.clrmask = |
| 891 | (1 << REISERFS_LARGETAIL) | (1 << REISERFS_SMALLTAIL)}, |
| 892 | {"conv",.setmask = 1 << REISERFS_CONVERT}, |
| 893 | {"attrs",.setmask = 1 << REISERFS_ATTRS}, |
| 894 | {"noattrs",.clrmask = 1 << REISERFS_ATTRS}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | #ifdef CONFIG_REISERFS_FS_XATTR |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 896 | {"user_xattr",.setmask = 1 << REISERFS_XATTRS_USER}, |
| 897 | {"nouser_xattr",.clrmask = 1 << REISERFS_XATTRS_USER}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | #else |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 899 | {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT}, |
| 900 | {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | #endif |
| 902 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 903 | {"acl",.setmask = 1 << REISERFS_POSIXACL}, |
| 904 | {"noacl",.clrmask = 1 << REISERFS_POSIXACL}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | #else |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 906 | {"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT}, |
| 907 | {"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 908 | #endif |
Vladimir V. Saveliev | cd02b96 | 2006-03-25 03:07:15 -0800 | [diff] [blame] | 909 | {.option_name = "nolog"}, |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 910 | {"replayonly",.setmask = 1 << REPLAYONLY}, |
| 911 | {"block-allocator",.arg_required = 'a',.values = balloc}, |
| 912 | {"data",.arg_required = 'd',.values = logging_mode}, |
| 913 | {"barrier",.arg_required = 'b',.values = barrier_mode}, |
| 914 | {"resize",.arg_required = 'r',.values = NULL}, |
| 915 | {"jdev",.arg_required = 'j',.values = NULL}, |
| 916 | {"nolargeio",.arg_required = 'w',.values = NULL}, |
| 917 | {"commit",.arg_required = 'c',.values = NULL}, |
| 918 | {"usrquota",.setmask = 1 << REISERFS_QUOTA}, |
| 919 | {"grpquota",.setmask = 1 << REISERFS_QUOTA}, |
| 920 | {"noquota",.clrmask = 1 << REISERFS_QUOTA}, |
| 921 | {"errors",.arg_required = 'e',.values = error_actions}, |
| 922 | {"usrjquota",.arg_required = |
| 923 | 'u' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL}, |
| 924 | {"grpjquota",.arg_required = |
| 925 | 'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL}, |
| 926 | {"jqfmt",.arg_required = 'f',.values = NULL}, |
Vladimir V. Saveliev | cd02b96 | 2006-03-25 03:07:15 -0800 | [diff] [blame] | 927 | {.option_name = NULL} |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 928 | }; |
| 929 | |
| 930 | *blocks = 0; |
| 931 | if (!options || !*options) |
| 932 | /* use default configuration: create tails, journaling on, no |
| 933 | conversion to newest format */ |
| 934 | return 1; |
| 935 | |
| 936 | for (pos = options; pos;) { |
| 937 | c = reiserfs_getopt(s, &pos, opts, &arg, mount_options); |
| 938 | if (c == -1) |
| 939 | /* wrong option is given */ |
| 940 | return 0; |
| 941 | |
| 942 | if (c == 'r') { |
| 943 | char *p; |
| 944 | |
| 945 | p = NULL; |
| 946 | /* "resize=NNN" or "resize=auto" */ |
| 947 | |
| 948 | if (!strcmp(arg, "auto")) { |
| 949 | /* From JFS code, to auto-get the size. */ |
| 950 | *blocks = |
| 951 | s->s_bdev->bd_inode->i_size >> s-> |
| 952 | s_blocksize_bits; |
| 953 | } else { |
| 954 | *blocks = simple_strtoul(arg, &p, 0); |
| 955 | if (*p != '\0') { |
| 956 | /* NNN does not look like a number */ |
| 957 | reiserfs_warning(s, |
| 958 | "reiserfs_parse_options: bad value %s", |
| 959 | arg); |
| 960 | return 0; |
| 961 | } |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | if (c == 'c') { |
| 966 | char *p = NULL; |
| 967 | unsigned long val = simple_strtoul(arg, &p, 0); |
| 968 | /* commit=NNN (time in seconds) */ |
| 969 | if (*p != '\0' || val >= (unsigned int)-1) { |
| 970 | reiserfs_warning(s, |
| 971 | "reiserfs_parse_options: bad value %s", |
| 972 | arg); |
| 973 | return 0; |
| 974 | } |
| 975 | *commit_max_age = (unsigned int)val; |
| 976 | } |
| 977 | |
| 978 | if (c == 'w') { |
Adrian Bunk | 36b756f | 2006-09-27 01:50:50 -0700 | [diff] [blame] | 979 | reiserfs_warning(s, "reiserfs: nolargeio option is no longer supported"); |
| 980 | return 0; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | if (c == 'j') { |
| 984 | if (arg && *arg && jdev_name) { |
| 985 | if (*jdev_name) { //Hm, already assigned? |
| 986 | reiserfs_warning(s, |
| 987 | "reiserfs_parse_options: journal device was already specified to be %s", |
| 988 | *jdev_name); |
| 989 | return 0; |
| 990 | } |
| 991 | *jdev_name = arg; |
| 992 | } |
| 993 | } |
| 994 | #ifdef CONFIG_QUOTA |
| 995 | if (c == 'u' || c == 'g') { |
| 996 | int qtype = c == 'u' ? USRQUOTA : GRPQUOTA; |
| 997 | |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 998 | if ((sb_any_quota_enabled(s) || |
| 999 | sb_any_quota_suspended(s)) && |
| 1000 | (!*arg != !REISERFS_SB(s)->s_qf_names[qtype])) { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1001 | reiserfs_warning(s, |
Jan Kara | 4506567 | 2008-07-25 01:46:37 -0700 | [diff] [blame] | 1002 | "reiserfs_parse_options: cannot change journaled quota options when quota turned on."); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1003 | return 0; |
| 1004 | } |
| 1005 | if (*arg) { /* Some filename specified? */ |
| 1006 | if (REISERFS_SB(s)->s_qf_names[qtype] |
| 1007 | && strcmp(REISERFS_SB(s)->s_qf_names[qtype], |
| 1008 | arg)) { |
| 1009 | reiserfs_warning(s, |
| 1010 | "reiserfs_parse_options: %s quota file already specified.", |
| 1011 | QTYPE2NAME(qtype)); |
| 1012 | return 0; |
| 1013 | } |
| 1014 | if (strchr(arg, '/')) { |
| 1015 | reiserfs_warning(s, |
| 1016 | "reiserfs_parse_options: quotafile must be on filesystem root."); |
| 1017 | return 0; |
| 1018 | } |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1019 | qf_names[qtype] = |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1020 | kmalloc(strlen(arg) + 1, GFP_KERNEL); |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1021 | if (!qf_names[qtype]) { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1022 | reiserfs_warning(s, |
| 1023 | "reiserfs_parse_options: not enough memory for storing quotafile name."); |
| 1024 | return 0; |
| 1025 | } |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1026 | strcpy(qf_names[qtype], arg); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1027 | *mount_options |= 1 << REISERFS_QUOTA; |
| 1028 | } else { |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1029 | if (qf_names[qtype] != |
| 1030 | REISERFS_SB(s)->s_qf_names[qtype]) |
| 1031 | kfree(qf_names[qtype]); |
| 1032 | qf_names[qtype] = NULL; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1033 | } |
| 1034 | } |
| 1035 | if (c == 'f') { |
| 1036 | if (!strcmp(arg, "vfsold")) |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1037 | *qfmt = QFMT_VFS_OLD; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1038 | else if (!strcmp(arg, "vfsv0")) |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1039 | *qfmt = QFMT_VFS_V0; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1040 | else { |
| 1041 | reiserfs_warning(s, |
| 1042 | "reiserfs_parse_options: unknown quota format specified."); |
| 1043 | return 0; |
| 1044 | } |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 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 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1052 | } |
| 1053 | #else |
| 1054 | if (c == 'u' || c == 'g' || c == 'f') { |
| 1055 | reiserfs_warning(s, |
Jan Kara | 4506567 | 2008-07-25 01:46:37 -0700 | [diff] [blame] | 1056 | "reiserfs_parse_options: journaled quota options not supported."); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1057 | return 0; |
| 1058 | } |
| 1059 | #endif |
| 1060 | } |
| 1061 | |
| 1062 | #ifdef CONFIG_QUOTA |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1063 | if (!REISERFS_SB(s)->s_jquota_fmt && !*qfmt |
| 1064 | && (qf_names[USRQUOTA] || qf_names[GRPQUOTA])) { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1065 | reiserfs_warning(s, |
Jan Kara | 4506567 | 2008-07-25 01:46:37 -0700 | [diff] [blame] | 1066 | "reiserfs_parse_options: journaled quota format not specified."); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1067 | return 0; |
| 1068 | } |
| 1069 | /* This checking is not precise wrt the quota type but for our purposes it is sufficient */ |
| 1070 | if (!(*mount_options & (1 << REISERFS_QUOTA)) |
| 1071 | && sb_any_quota_enabled(s)) { |
| 1072 | reiserfs_warning(s, |
| 1073 | "reiserfs_parse_options: quota options must be present when quota is turned on."); |
| 1074 | return 0; |
| 1075 | } |
| 1076 | #endif |
| 1077 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | } |
| 1080 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1081 | static void switch_data_mode(struct super_block *s, unsigned long mode) |
| 1082 | { |
| 1083 | REISERFS_SB(s)->s_mount_opt &= ~((1 << REISERFS_DATA_LOG) | |
| 1084 | (1 << REISERFS_DATA_ORDERED) | |
| 1085 | (1 << REISERFS_DATA_WRITEBACK)); |
| 1086 | REISERFS_SB(s)->s_mount_opt |= (1 << mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | static void handle_data_mode(struct super_block *s, unsigned long mount_options) |
| 1090 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1091 | if (mount_options & (1 << REISERFS_DATA_LOG)) { |
| 1092 | if (!reiserfs_data_log(s)) { |
| 1093 | switch_data_mode(s, REISERFS_DATA_LOG); |
| 1094 | reiserfs_info(s, "switching to journaled data mode\n"); |
| 1095 | } |
| 1096 | } else if (mount_options & (1 << REISERFS_DATA_ORDERED)) { |
| 1097 | if (!reiserfs_data_ordered(s)) { |
| 1098 | switch_data_mode(s, REISERFS_DATA_ORDERED); |
| 1099 | reiserfs_info(s, "switching to ordered data mode\n"); |
| 1100 | } |
| 1101 | } else if (mount_options & (1 << REISERFS_DATA_WRITEBACK)) { |
| 1102 | if (!reiserfs_data_writeback(s)) { |
| 1103 | switch_data_mode(s, REISERFS_DATA_WRITEBACK); |
| 1104 | reiserfs_info(s, "switching to writeback data mode\n"); |
| 1105 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1106 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | } |
| 1108 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1109 | static void handle_barrier_mode(struct super_block *s, unsigned long bits) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1111 | int flush = (1 << REISERFS_BARRIER_FLUSH); |
| 1112 | int none = (1 << REISERFS_BARRIER_NONE); |
| 1113 | int all_barrier = flush | none; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1115 | if (bits & all_barrier) { |
| 1116 | REISERFS_SB(s)->s_mount_opt &= ~all_barrier; |
| 1117 | if (bits & flush) { |
| 1118 | REISERFS_SB(s)->s_mount_opt |= flush; |
| 1119 | printk("reiserfs: enabling write barrier flush mode\n"); |
| 1120 | } else if (bits & none) { |
| 1121 | REISERFS_SB(s)->s_mount_opt |= none; |
| 1122 | printk("reiserfs: write barriers turned off\n"); |
| 1123 | } |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | static void handle_attrs(struct super_block *s) |
| 1128 | { |
| 1129 | struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s); |
| 1130 | |
| 1131 | if (reiserfs_attrs(s)) { |
| 1132 | if (old_format_only(s)) { |
| 1133 | reiserfs_warning(s, |
| 1134 | "reiserfs: cannot support attributes on 3.5.x disk format"); |
| 1135 | REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1136 | return; |
| 1137 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1138 | if (!(le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared)) { |
| 1139 | reiserfs_warning(s, |
| 1140 | "reiserfs: cannot support attributes until flag is set in super-block"); |
| 1141 | REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1161 | static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1162 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1163 | struct reiserfs_super_block *rs; |
| 1164 | struct reiserfs_transaction_handle th; |
| 1165 | unsigned long blocks; |
| 1166 | unsigned long mount_options = REISERFS_SB(s)->s_mount_opt; |
| 1167 | unsigned long safe_mask = 0; |
| 1168 | unsigned int commit_max_age = (unsigned int)-1; |
| 1169 | struct reiserfs_journal *journal = SB_JOURNAL(s); |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1170 | char *new_opts = kstrdup(arg, GFP_KERNEL); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1171 | int err; |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1172 | char *qf_names[MAXQUOTAS]; |
| 1173 | unsigned int qfmt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1174 | #ifdef CONFIG_QUOTA |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1175 | int i; |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1176 | |
| 1177 | memcpy(qf_names, REISERFS_SB(s)->s_qf_names, sizeof(qf_names)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | #endif |
| 1179 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1180 | rs = SB_DISK_SUPER_BLOCK(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1182 | if (!reiserfs_parse_options |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1183 | (s, arg, &mount_options, &blocks, NULL, &commit_max_age, |
| 1184 | qf_names, &qfmt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | #ifdef CONFIG_QUOTA |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1186 | for (i = 0; i < MAXQUOTAS; i++) |
| 1187 | if (qf_names[i] != REISERFS_SB(s)->s_qf_names[i]) |
| 1188 | kfree(qf_names[i]); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1189 | #endif |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1190 | err = -EINVAL; |
| 1191 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1192 | } |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1193 | #ifdef CONFIG_QUOTA |
| 1194 | handle_quota_files(s, qf_names, &qfmt); |
| 1195 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1197 | handle_attrs(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1199 | /* Add options that are safe here */ |
| 1200 | safe_mask |= 1 << REISERFS_SMALLTAIL; |
| 1201 | safe_mask |= 1 << REISERFS_LARGETAIL; |
| 1202 | safe_mask |= 1 << REISERFS_NO_BORDER; |
| 1203 | safe_mask |= 1 << REISERFS_NO_UNHASHED_RELOCATION; |
| 1204 | safe_mask |= 1 << REISERFS_HASHED_RELOCATION; |
| 1205 | safe_mask |= 1 << REISERFS_TEST4; |
| 1206 | safe_mask |= 1 << REISERFS_ATTRS; |
| 1207 | safe_mask |= 1 << REISERFS_XATTRS_USER; |
| 1208 | safe_mask |= 1 << REISERFS_POSIXACL; |
| 1209 | safe_mask |= 1 << REISERFS_BARRIER_FLUSH; |
| 1210 | safe_mask |= 1 << REISERFS_BARRIER_NONE; |
| 1211 | safe_mask |= 1 << REISERFS_ERROR_RO; |
| 1212 | safe_mask |= 1 << REISERFS_ERROR_CONTINUE; |
| 1213 | safe_mask |= 1 << REISERFS_ERROR_PANIC; |
| 1214 | safe_mask |= 1 << REISERFS_QUOTA; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1216 | /* Update the bitmask, taking care to keep |
| 1217 | * the bits we're not allowed to change here */ |
| 1218 | REISERFS_SB(s)->s_mount_opt = |
| 1219 | (REISERFS_SB(s)-> |
| 1220 | s_mount_opt & ~safe_mask) | (mount_options & safe_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1222 | if (commit_max_age != 0 && commit_max_age != (unsigned int)-1) { |
| 1223 | journal->j_max_commit_age = commit_max_age; |
| 1224 | journal->j_max_trans_age = commit_max_age; |
| 1225 | } else if (commit_max_age == 0) { |
| 1226 | /* 0 means restore defaults. */ |
| 1227 | journal->j_max_commit_age = journal->j_default_max_commit_age; |
| 1228 | journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE; |
| 1229 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1230 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1231 | if (blocks) { |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1232 | err = reiserfs_resize(s, blocks); |
| 1233 | if (err != 0) |
| 1234 | goto out_err; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1235 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1236 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1237 | if (*mount_flags & MS_RDONLY) { |
| 1238 | reiserfs_xattr_init(s, *mount_flags); |
| 1239 | /* remount read-only */ |
| 1240 | if (s->s_flags & MS_RDONLY) |
| 1241 | /* it is read-only already */ |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1242 | goto out_ok; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1243 | /* try to remount file system with read-only permissions */ |
| 1244 | if (sb_umount_state(rs) == REISERFS_VALID_FS |
| 1245 | || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) { |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1246 | goto out_ok; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1249 | err = journal_begin(&th, s, 10); |
| 1250 | if (err) |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1251 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1253 | /* Mounting a rw partition read-only. */ |
| 1254 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); |
| 1255 | set_sb_umount_state(rs, REISERFS_SB(s)->s_mount_state); |
| 1256 | journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s)); |
| 1257 | } else { |
| 1258 | /* remount read-write */ |
| 1259 | if (!(s->s_flags & MS_RDONLY)) { |
| 1260 | reiserfs_xattr_init(s, *mount_flags); |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1261 | goto out_ok; /* We are read-write already */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1262 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1264 | if (reiserfs_is_journal_aborted(journal)) { |
| 1265 | err = journal->j_errno; |
| 1266 | goto out_err; |
| 1267 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1268 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1269 | handle_data_mode(s, mount_options); |
| 1270 | handle_barrier_mode(s, mount_options); |
| 1271 | REISERFS_SB(s)->s_mount_state = sb_umount_state(rs); |
| 1272 | s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */ |
| 1273 | err = journal_begin(&th, s, 10); |
| 1274 | if (err) |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1275 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1277 | /* Mount a partition which is read-only, read-write */ |
| 1278 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); |
| 1279 | REISERFS_SB(s)->s_mount_state = sb_umount_state(rs); |
| 1280 | s->s_flags &= ~MS_RDONLY; |
| 1281 | set_sb_umount_state(rs, REISERFS_ERROR_FS); |
| 1282 | /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */ |
| 1283 | journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s)); |
| 1284 | REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS; |
| 1285 | } |
| 1286 | /* this will force a full flush of all journal lists */ |
| 1287 | SB_JOURNAL(s)->j_must_wait = 1; |
| 1288 | err = journal_end(&th, s, 10); |
| 1289 | if (err) |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1290 | goto out_err; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1291 | s->s_dirt = 0; |
| 1292 | |
| 1293 | if (!(*mount_flags & MS_RDONLY)) { |
| 1294 | finish_unfinished(s); |
| 1295 | reiserfs_xattr_init(s, *mount_flags); |
| 1296 | } |
| 1297 | |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1298 | out_ok: |
| 1299 | kfree(s->s_options); |
| 1300 | s->s_options = new_opts; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1301 | return 0; |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1302 | |
| 1303 | out_err: |
| 1304 | kfree(new_opts); |
| 1305 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | } |
| 1307 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1308 | static int read_super_block(struct super_block *s, int offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1309 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1310 | struct buffer_head *bh; |
| 1311 | struct reiserfs_super_block *rs; |
| 1312 | int fs_blocksize; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1314 | bh = sb_bread(s, offset / s->s_blocksize); |
| 1315 | if (!bh) { |
| 1316 | reiserfs_warning(s, "sh-2006: read_super_block: " |
| 1317 | "bread failed (dev %s, block %lu, size %lu)", |
| 1318 | reiserfs_bdevname(s), offset / s->s_blocksize, |
| 1319 | s->s_blocksize); |
| 1320 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1321 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1323 | rs = (struct reiserfs_super_block *)bh->b_data; |
| 1324 | if (!is_any_reiserfs_magic_string(rs)) { |
| 1325 | brelse(bh); |
| 1326 | return 1; |
| 1327 | } |
| 1328 | // |
| 1329 | // ok, reiserfs signature (old or new) found in at the given offset |
| 1330 | // |
| 1331 | fs_blocksize = sb_blocksize(rs); |
| 1332 | brelse(bh); |
| 1333 | sb_set_blocksize(s, fs_blocksize); |
| 1334 | |
| 1335 | bh = sb_bread(s, offset / s->s_blocksize); |
| 1336 | if (!bh) { |
| 1337 | reiserfs_warning(s, "sh-2007: read_super_block: " |
| 1338 | "bread failed (dev %s, block %lu, size %lu)\n", |
| 1339 | reiserfs_bdevname(s), offset / s->s_blocksize, |
| 1340 | s->s_blocksize); |
| 1341 | return 1; |
| 1342 | } |
| 1343 | |
| 1344 | rs = (struct reiserfs_super_block *)bh->b_data; |
| 1345 | if (sb_blocksize(rs) != s->s_blocksize) { |
| 1346 | reiserfs_warning(s, "sh-2011: read_super_block: " |
| 1347 | "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n", |
| 1348 | reiserfs_bdevname(s), |
| 1349 | (unsigned long long)bh->b_blocknr, |
| 1350 | s->s_blocksize); |
| 1351 | brelse(bh); |
| 1352 | return 1; |
| 1353 | } |
| 1354 | |
| 1355 | if (rs->s_v1.s_root_block == cpu_to_le32(-1)) { |
| 1356 | brelse(bh); |
| 1357 | reiserfs_warning(s, |
| 1358 | "Unfinished reiserfsck --rebuild-tree run detected. Please run\n" |
| 1359 | "reiserfsck --rebuild-tree and wait for a completion. If that fails\n" |
| 1360 | "get newer reiserfsprogs package"); |
| 1361 | return 1; |
| 1362 | } |
| 1363 | |
| 1364 | SB_BUFFER_WITH_SB(s) = bh; |
| 1365 | SB_DISK_SUPER_BLOCK(s) = rs; |
| 1366 | |
| 1367 | if (is_reiserfs_jr(rs)) { |
| 1368 | /* magic is of non-standard journal filesystem, look at s_version to |
| 1369 | find which format is in use */ |
| 1370 | if (sb_version(rs) == REISERFS_VERSION_2) |
| 1371 | reiserfs_warning(s, |
| 1372 | "read_super_block: found reiserfs format \"3.6\"" |
| 1373 | " with non-standard journal"); |
| 1374 | else if (sb_version(rs) == REISERFS_VERSION_1) |
| 1375 | reiserfs_warning(s, |
| 1376 | "read_super_block: found reiserfs format \"3.5\"" |
| 1377 | " with non-standard journal"); |
| 1378 | else { |
| 1379 | reiserfs_warning(s, |
| 1380 | "sh-2012: read_super_block: found unknown " |
| 1381 | "format \"%u\" of reiserfs with non-standard magic", |
| 1382 | sb_version(rs)); |
| 1383 | return 1; |
| 1384 | } |
| 1385 | } else |
| 1386 | /* s_version of standard format may contain incorrect information, |
| 1387 | so we just look at the magic string */ |
| 1388 | reiserfs_info(s, |
| 1389 | "found reiserfs format \"%s\" with standard journal\n", |
| 1390 | is_reiserfs_3_5(rs) ? "3.5" : "3.6"); |
| 1391 | |
| 1392 | s->s_op = &reiserfs_sops; |
| 1393 | s->s_export_op = &reiserfs_export_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | #ifdef CONFIG_QUOTA |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1395 | s->s_qcop = &reiserfs_qctl_operations; |
| 1396 | s->dq_op = &reiserfs_quota_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | #endif |
| 1398 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1399 | /* new format is limited by the 32 bit wide i_blocks field, want to |
| 1400 | ** be one full block below that. |
| 1401 | */ |
| 1402 | s->s_maxbytes = (512LL << 32) - s->s_blocksize; |
| 1403 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | } |
| 1405 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | /* after journal replay, reread all bitmap and super blocks */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1407 | static int reread_meta_blocks(struct super_block *s) |
| 1408 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1409 | ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))); |
| 1410 | wait_on_buffer(SB_BUFFER_WITH_SB(s)); |
| 1411 | if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) { |
| 1412 | reiserfs_warning(s, |
| 1413 | "reread_meta_blocks, error reading the super"); |
| 1414 | return 1; |
| 1415 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1417 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1418 | } |
| 1419 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | ///////////////////////////////////////////////////// |
| 1421 | // hash detection stuff |
| 1422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | // if root directory is empty - we set default - Yura's - hash and |
| 1424 | // warn about it |
| 1425 | // FIXME: we look for only one name in a directory. If tea and yura |
| 1426 | // bith have the same value - we ask user to send report to the |
| 1427 | // mailing list |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1428 | static __u32 find_hash_out(struct super_block *s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1430 | int retval; |
| 1431 | struct inode *inode; |
| 1432 | struct cpu_key key; |
| 1433 | INITIALIZE_PATH(path); |
| 1434 | struct reiserfs_dir_entry de; |
| 1435 | __u32 hash = DEFAULT_HASH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1437 | inode = s->s_root->d_inode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1439 | do { // Some serious "goto"-hater was there ;) |
| 1440 | u32 teahash, r5hash, yurahash; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1441 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1442 | make_cpu_key(&key, inode, ~0, TYPE_DIRENTRY, 3); |
| 1443 | retval = search_by_entry_key(s, &key, &path, &de); |
| 1444 | if (retval == IO_ERROR) { |
| 1445 | pathrelse(&path); |
| 1446 | return UNSET_HASH; |
| 1447 | } |
| 1448 | if (retval == NAME_NOT_FOUND) |
| 1449 | de.de_entry_num--; |
| 1450 | set_de_name_and_namelen(&de); |
| 1451 | if (deh_offset(&(de.de_deh[de.de_entry_num])) == DOT_DOT_OFFSET) { |
| 1452 | /* allow override in this case */ |
| 1453 | if (reiserfs_rupasov_hash(s)) { |
| 1454 | hash = YURA_HASH; |
| 1455 | } |
| 1456 | reiserfs_warning(s, "FS seems to be empty, autodetect " |
| 1457 | "is using the default hash"); |
| 1458 | break; |
| 1459 | } |
| 1460 | r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen)); |
| 1461 | teahash = GET_HASH_VALUE(keyed_hash(de.de_name, de.de_namelen)); |
| 1462 | yurahash = GET_HASH_VALUE(yura_hash(de.de_name, de.de_namelen)); |
| 1463 | if (((teahash == r5hash) |
| 1464 | && |
| 1465 | (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num]))) |
| 1466 | == r5hash)) || ((teahash == yurahash) |
| 1467 | && (yurahash == |
| 1468 | GET_HASH_VALUE(deh_offset |
| 1469 | (& |
| 1470 | (de. |
| 1471 | de_deh[de. |
| 1472 | de_entry_num]))))) |
| 1473 | || ((r5hash == yurahash) |
| 1474 | && (yurahash == |
| 1475 | GET_HASH_VALUE(deh_offset |
| 1476 | (&(de.de_deh[de.de_entry_num])))))) { |
| 1477 | reiserfs_warning(s, |
| 1478 | "Unable to automatically detect hash function. " |
| 1479 | "Please mount with -o hash={tea,rupasov,r5}", |
| 1480 | reiserfs_bdevname(s)); |
| 1481 | hash = UNSET_HASH; |
| 1482 | break; |
| 1483 | } |
| 1484 | if (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num]))) == |
| 1485 | yurahash) |
| 1486 | hash = YURA_HASH; |
| 1487 | else if (GET_HASH_VALUE |
| 1488 | (deh_offset(&(de.de_deh[de.de_entry_num]))) == teahash) |
| 1489 | hash = TEA_HASH; |
| 1490 | else if (GET_HASH_VALUE |
| 1491 | (deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash) |
| 1492 | hash = R5_HASH; |
| 1493 | else { |
| 1494 | reiserfs_warning(s, "Unrecognised hash function"); |
| 1495 | hash = UNSET_HASH; |
| 1496 | } |
| 1497 | } while (0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1498 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1499 | pathrelse(&path); |
| 1500 | return hash; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1501 | } |
| 1502 | |
| 1503 | // finds out which hash names are sorted with |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1504 | static int what_hash(struct super_block *s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1505 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1506 | __u32 code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1507 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1508 | code = sb_hash_function_code(SB_DISK_SUPER_BLOCK(s)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1509 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1510 | /* reiserfs_hash_detect() == true if any of the hash mount options |
| 1511 | ** were used. We must check them to make sure the user isn't |
| 1512 | ** using a bad hash value |
| 1513 | */ |
| 1514 | if (code == UNSET_HASH || reiserfs_hash_detect(s)) |
| 1515 | code = find_hash_out(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1517 | if (code != UNSET_HASH && reiserfs_hash_detect(s)) { |
| 1518 | /* detection has found the hash, and we must check against the |
| 1519 | ** mount options |
| 1520 | */ |
| 1521 | if (reiserfs_rupasov_hash(s) && code != YURA_HASH) { |
| 1522 | reiserfs_warning(s, "Error, %s hash detected, " |
| 1523 | "unable to force rupasov hash", |
| 1524 | reiserfs_hashname(code)); |
| 1525 | code = UNSET_HASH; |
| 1526 | } else if (reiserfs_tea_hash(s) && code != TEA_HASH) { |
| 1527 | reiserfs_warning(s, "Error, %s hash detected, " |
| 1528 | "unable to force tea hash", |
| 1529 | reiserfs_hashname(code)); |
| 1530 | code = UNSET_HASH; |
| 1531 | } else if (reiserfs_r5_hash(s) && code != R5_HASH) { |
| 1532 | reiserfs_warning(s, "Error, %s hash detected, " |
| 1533 | "unable to force r5 hash", |
| 1534 | reiserfs_hashname(code)); |
| 1535 | code = UNSET_HASH; |
| 1536 | } |
| 1537 | } else { |
| 1538 | /* find_hash_out was not called or could not determine the hash */ |
| 1539 | if (reiserfs_rupasov_hash(s)) { |
| 1540 | code = YURA_HASH; |
| 1541 | } else if (reiserfs_tea_hash(s)) { |
| 1542 | code = TEA_HASH; |
| 1543 | } else if (reiserfs_r5_hash(s)) { |
| 1544 | code = R5_HASH; |
| 1545 | } |
| 1546 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1548 | /* if we are mounted RW, and we have a new valid hash code, update |
| 1549 | ** the super |
| 1550 | */ |
| 1551 | if (code != UNSET_HASH && |
| 1552 | !(s->s_flags & MS_RDONLY) && |
| 1553 | code != sb_hash_function_code(SB_DISK_SUPER_BLOCK(s))) { |
| 1554 | set_sb_hash_function_code(SB_DISK_SUPER_BLOCK(s), code); |
| 1555 | } |
| 1556 | return code; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1557 | } |
| 1558 | |
| 1559 | // return pointer to appropriate function |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1560 | static hashf_t hash_function(struct super_block *s) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1562 | switch (what_hash(s)) { |
| 1563 | case TEA_HASH: |
| 1564 | reiserfs_info(s, "Using tea hash to sort names\n"); |
| 1565 | return keyed_hash; |
| 1566 | case YURA_HASH: |
| 1567 | reiserfs_info(s, "Using rupasov hash to sort names\n"); |
| 1568 | return yura_hash; |
| 1569 | case R5_HASH: |
| 1570 | reiserfs_info(s, "Using r5 hash to sort names\n"); |
| 1571 | return r5_hash; |
| 1572 | } |
| 1573 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1574 | } |
| 1575 | |
| 1576 | // this is used to set up correct value for old partitions |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1577 | static int function2code(hashf_t func) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1579 | if (func == keyed_hash) |
| 1580 | return TEA_HASH; |
| 1581 | if (func == yura_hash) |
| 1582 | return YURA_HASH; |
| 1583 | if (func == r5_hash) |
| 1584 | return R5_HASH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1585 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1586 | BUG(); // should never happen |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1588 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1589 | } |
| 1590 | |
| 1591 | #define SWARN(silent, s, ...) \ |
| 1592 | if (!(silent)) \ |
| 1593 | reiserfs_warning (s, __VA_ARGS__) |
| 1594 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1595 | static int reiserfs_fill_super(struct super_block *s, void *data, int silent) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1596 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1597 | struct inode *root_inode; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1598 | struct reiserfs_transaction_handle th; |
| 1599 | int old_format = 0; |
| 1600 | unsigned long blocks; |
| 1601 | unsigned int commit_max_age = 0; |
| 1602 | int jinit_done = 0; |
| 1603 | struct reiserfs_iget_args args; |
| 1604 | struct reiserfs_super_block *rs; |
| 1605 | char *jdev_name; |
| 1606 | struct reiserfs_sb_info *sbi; |
| 1607 | int errval = -EINVAL; |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1608 | char *qf_names[MAXQUOTAS] = {}; |
| 1609 | unsigned int qfmt = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1610 | |
Miklos Szeredi | cdf6ccc | 2008-02-08 04:21:47 -0800 | [diff] [blame] | 1611 | save_mount_options(s, data); |
| 1612 | |
Yan Burman | 01afb21 | 2006-12-06 20:39:01 -0800 | [diff] [blame] | 1613 | sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1614 | if (!sbi) { |
| 1615 | errval = -ENOMEM; |
| 1616 | goto error; |
| 1617 | } |
| 1618 | s->s_fs_info = sbi; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1619 | /* Set default values for options: non-aggressive tails, RO on errors */ |
| 1620 | REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL); |
| 1621 | REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO); |
| 1622 | /* no preallocation minimum, be smart in |
| 1623 | reiserfs_file_write instead */ |
| 1624 | REISERFS_SB(s)->s_alloc_options.preallocmin = 0; |
| 1625 | /* Preallocate by 16 blocks (17-1) at once */ |
| 1626 | REISERFS_SB(s)->s_alloc_options.preallocsize = 17; |
Alexey Dobriyan | fe08a9d | 2007-05-08 00:24:55 -0700 | [diff] [blame] | 1627 | #ifdef CONFIG_REISERFS_FS_XATTR |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1628 | /* Initialize the rwsem for xattr dir */ |
| 1629 | init_rwsem(&REISERFS_SB(s)->xattr_dir_sem); |
Alexey Dobriyan | fe08a9d | 2007-05-08 00:24:55 -0700 | [diff] [blame] | 1630 | #endif |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1631 | /* setup default block allocator options */ |
| 1632 | reiserfs_init_alloc_options(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1634 | jdev_name = NULL; |
| 1635 | if (reiserfs_parse_options |
| 1636 | (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name, |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1637 | &commit_max_age, qf_names, &qfmt) == 0) { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1638 | goto error; |
| 1639 | } |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1640 | #ifdef CONFIG_QUOTA |
| 1641 | handle_quota_files(s, qf_names, &qfmt); |
| 1642 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1643 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1644 | if (blocks) { |
| 1645 | SWARN(silent, s, "jmacd-7: reiserfs_fill_super: resize option " |
| 1646 | "for remount only"); |
| 1647 | goto error; |
| 1648 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1649 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1650 | /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */ |
| 1651 | if (!read_super_block(s, REISERFS_OLD_DISK_OFFSET_IN_BYTES)) |
| 1652 | old_format = 1; |
| 1653 | /* try new format (64-th 1k block), which can contain reiserfs super block */ |
| 1654 | else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) { |
| 1655 | SWARN(silent, s, |
| 1656 | "sh-2021: reiserfs_fill_super: can not find reiserfs on %s", |
| 1657 | reiserfs_bdevname(s)); |
| 1658 | goto error; |
| 1659 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1661 | rs = SB_DISK_SUPER_BLOCK(s); |
| 1662 | /* Let's do basic sanity check to verify that underlying device is not |
| 1663 | smaller than the filesystem. If the check fails then abort and scream, |
| 1664 | because bad stuff will happen otherwise. */ |
| 1665 | if (s->s_bdev && s->s_bdev->bd_inode |
| 1666 | && i_size_read(s->s_bdev->bd_inode) < |
| 1667 | sb_block_count(rs) * sb_blocksize(rs)) { |
| 1668 | SWARN(silent, s, |
| 1669 | "Filesystem on %s cannot be mounted because it is bigger than the device", |
| 1670 | reiserfs_bdevname(s)); |
| 1671 | SWARN(silent, s, |
| 1672 | "You may need to run fsck or increase size of your LVM partition"); |
| 1673 | SWARN(silent, s, |
| 1674 | "Or may be you forgot to reboot after fdisk when it told you to"); |
| 1675 | goto error; |
| 1676 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1677 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1678 | sbi->s_mount_state = SB_REISERFS_STATE(s); |
| 1679 | sbi->s_mount_state = REISERFS_VALID_FS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1680 | |
Jeff Mahoney | 6f01046 | 2006-09-30 23:28:43 -0700 | [diff] [blame] | 1681 | if ((errval = reiserfs_init_bitmap_cache(s))) { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1682 | SWARN(silent, s, |
| 1683 | "jmacd-8: reiserfs_fill_super: unable to read bitmap"); |
| 1684 | goto error; |
| 1685 | } |
Jeff Mahoney | d2c89a4 | 2006-11-02 22:07:20 -0800 | [diff] [blame] | 1686 | errval = -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | #ifdef CONFIG_REISERFS_CHECK |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1688 | SWARN(silent, s, "CONFIG_REISERFS_CHECK is set ON"); |
| 1689 | SWARN(silent, s, "- it is slow mode for debugging."); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1690 | #endif |
| 1691 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1692 | /* make data=ordered the default */ |
| 1693 | if (!reiserfs_data_log(s) && !reiserfs_data_ordered(s) && |
| 1694 | !reiserfs_data_writeback(s)) { |
| 1695 | REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_DATA_ORDERED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | } |
| 1697 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1698 | if (reiserfs_data_log(s)) { |
| 1699 | reiserfs_info(s, "using journaled data mode\n"); |
| 1700 | } else if (reiserfs_data_ordered(s)) { |
| 1701 | reiserfs_info(s, "using ordered data mode\n"); |
| 1702 | } else { |
| 1703 | reiserfs_info(s, "using writeback data mode\n"); |
| 1704 | } |
| 1705 | if (reiserfs_barrier_flush(s)) { |
| 1706 | printk("reiserfs: using flush barriers\n"); |
| 1707 | } |
| 1708 | // set_device_ro(s->s_dev, 1) ; |
| 1709 | if (journal_init(s, jdev_name, old_format, commit_max_age)) { |
| 1710 | SWARN(silent, s, |
| 1711 | "sh-2022: reiserfs_fill_super: unable to initialize journal space"); |
| 1712 | goto error; |
| 1713 | } else { |
| 1714 | jinit_done = 1; /* once this is set, journal_release must be called |
| 1715 | ** if we error out of the mount |
| 1716 | */ |
| 1717 | } |
| 1718 | if (reread_meta_blocks(s)) { |
| 1719 | SWARN(silent, s, |
| 1720 | "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init"); |
| 1721 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1722 | } |
| 1723 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1724 | if (replay_only(s)) |
| 1725 | goto error; |
| 1726 | |
| 1727 | if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) { |
| 1728 | SWARN(silent, s, |
| 1729 | "clm-7000: Detected readonly device, marking FS readonly"); |
| 1730 | s->s_flags |= MS_RDONLY; |
| 1731 | } |
| 1732 | args.objectid = REISERFS_ROOT_OBJECTID; |
| 1733 | args.dirid = REISERFS_ROOT_PARENT_OBJECTID; |
| 1734 | root_inode = |
| 1735 | iget5_locked(s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, |
| 1736 | reiserfs_init_locked_inode, (void *)(&args)); |
| 1737 | if (!root_inode) { |
| 1738 | SWARN(silent, s, |
| 1739 | "jmacd-10: reiserfs_fill_super: get root inode failed"); |
| 1740 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1741 | } |
| 1742 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1743 | if (root_inode->i_state & I_NEW) { |
| 1744 | reiserfs_read_locked_inode(root_inode, &args); |
| 1745 | unlock_new_inode(root_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1746 | } |
| 1747 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1748 | s->s_root = d_alloc_root(root_inode); |
| 1749 | if (!s->s_root) { |
| 1750 | iput(root_inode); |
| 1751 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1752 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1753 | // define and initialize hash function |
| 1754 | sbi->s_hash_function = hash_function(s); |
| 1755 | if (sbi->s_hash_function == NULL) { |
| 1756 | dput(s->s_root); |
| 1757 | s->s_root = NULL; |
| 1758 | goto error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1759 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1760 | |
| 1761 | if (is_reiserfs_3_5(rs) |
| 1762 | || (is_reiserfs_jr(rs) && SB_VERSION(s) == REISERFS_VERSION_1)) |
| 1763 | set_bit(REISERFS_3_5, &(sbi->s_properties)); |
Jeff Mahoney | e1fabd3 | 2006-09-30 23:28:40 -0700 | [diff] [blame] | 1764 | else if (old_format) |
| 1765 | set_bit(REISERFS_OLD_FORMAT, &(sbi->s_properties)); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1766 | else |
| 1767 | set_bit(REISERFS_3_6, &(sbi->s_properties)); |
| 1768 | |
| 1769 | if (!(s->s_flags & MS_RDONLY)) { |
| 1770 | |
| 1771 | errval = journal_begin(&th, s, 1); |
| 1772 | if (errval) { |
| 1773 | dput(s->s_root); |
| 1774 | s->s_root = NULL; |
| 1775 | goto error; |
| 1776 | } |
| 1777 | reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); |
| 1778 | |
| 1779 | set_sb_umount_state(rs, REISERFS_ERROR_FS); |
| 1780 | set_sb_fs_state(rs, 0); |
| 1781 | |
Jeff Mahoney | cb680c1 | 2007-10-18 23:39:27 -0700 | [diff] [blame] | 1782 | /* Clear out s_bmap_nr if it would wrap. We can handle this |
| 1783 | * case, but older revisions can't. This will cause the |
| 1784 | * file system to fail mount on those older implementations, |
| 1785 | * avoiding corruption. -jeffm */ |
| 1786 | if (bmap_would_wrap(reiserfs_bmap_count(s)) && |
| 1787 | sb_bmap_nr(rs) != 0) { |
| 1788 | reiserfs_warning(s, "super-2030: This file system " |
| 1789 | "claims to use %u bitmap blocks in " |
| 1790 | "its super block, but requires %u. " |
| 1791 | "Clearing to zero.", sb_bmap_nr(rs), |
| 1792 | reiserfs_bmap_count(s)); |
| 1793 | |
| 1794 | set_sb_bmap_nr(rs, 0); |
| 1795 | } |
| 1796 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1797 | if (old_format_only(s)) { |
| 1798 | /* filesystem of format 3.5 either with standard or non-standard |
| 1799 | journal */ |
| 1800 | if (convert_reiserfs(s)) { |
| 1801 | /* and -o conv is given */ |
| 1802 | if (!silent) |
| 1803 | reiserfs_info(s, |
| 1804 | "converting 3.5 filesystem to the 3.6 format"); |
| 1805 | |
| 1806 | if (is_reiserfs_3_5(rs)) |
| 1807 | /* put magic string of 3.6 format. 2.2 will not be able to |
| 1808 | mount this filesystem anymore */ |
| 1809 | memcpy(rs->s_v1.s_magic, |
| 1810 | reiserfs_3_6_magic_string, |
| 1811 | sizeof |
| 1812 | (reiserfs_3_6_magic_string)); |
| 1813 | |
| 1814 | set_sb_version(rs, REISERFS_VERSION_2); |
| 1815 | reiserfs_convert_objectid_map_v1(s); |
| 1816 | set_bit(REISERFS_3_6, &(sbi->s_properties)); |
| 1817 | clear_bit(REISERFS_3_5, &(sbi->s_properties)); |
| 1818 | } else if (!silent) { |
| 1819 | reiserfs_info(s, "using 3.5.x disk format\n"); |
| 1820 | } |
| 1821 | } |
| 1822 | |
| 1823 | journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s)); |
| 1824 | errval = journal_end(&th, s, 1); |
| 1825 | if (errval) { |
| 1826 | dput(s->s_root); |
| 1827 | s->s_root = NULL; |
| 1828 | goto error; |
| 1829 | } |
| 1830 | |
| 1831 | if ((errval = reiserfs_xattr_init(s, s->s_flags))) { |
| 1832 | dput(s->s_root); |
| 1833 | s->s_root = NULL; |
| 1834 | goto error; |
| 1835 | } |
| 1836 | |
| 1837 | /* look for files which were to be removed in previous session */ |
| 1838 | finish_unfinished(s); |
| 1839 | } else { |
| 1840 | if (old_format_only(s) && !silent) { |
| 1841 | reiserfs_info(s, "using 3.5.x disk format\n"); |
| 1842 | } |
| 1843 | |
| 1844 | if ((errval = reiserfs_xattr_init(s, s->s_flags))) { |
| 1845 | dput(s->s_root); |
| 1846 | s->s_root = NULL; |
| 1847 | goto error; |
| 1848 | } |
| 1849 | } |
| 1850 | // mark hash in super block: it could be unset. overwrite should be ok |
| 1851 | set_sb_hash_function_code(rs, function2code(sbi->s_hash_function)); |
| 1852 | |
| 1853 | handle_attrs(s); |
| 1854 | |
| 1855 | reiserfs_proc_info_init(s); |
| 1856 | |
| 1857 | init_waitqueue_head(&(sbi->s_wait)); |
| 1858 | spin_lock_init(&sbi->bitmap_lock); |
| 1859 | |
| 1860 | return (0); |
| 1861 | |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1862 | error: |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1863 | if (jinit_done) { /* kill the commit thread, free journal ram */ |
| 1864 | journal_release_error(NULL, s); |
| 1865 | } |
Jeff Mahoney | 5065227 | 2006-09-30 23:28:44 -0700 | [diff] [blame] | 1866 | |
| 1867 | reiserfs_free_bitmap_cache(s); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1868 | if (SB_BUFFER_WITH_SB(s)) |
| 1869 | brelse(SB_BUFFER_WITH_SB(s)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1870 | #ifdef CONFIG_QUOTA |
Jeff Mahoney | 5065227 | 2006-09-30 23:28:44 -0700 | [diff] [blame] | 1871 | { |
| 1872 | int j; |
Jan Kara | 00b4419 | 2008-07-25 01:46:38 -0700 | [diff] [blame] | 1873 | for (j = 0; j < MAXQUOTAS; j++) |
| 1874 | kfree(qf_names[j]); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1875 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1876 | #endif |
James Lamanna | 833d304 | 2005-10-30 15:00:16 -0800 | [diff] [blame] | 1877 | kfree(sbi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1878 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1879 | s->s_fs_info = NULL; |
| 1880 | return errval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1881 | } |
| 1882 | |
David Howells | 726c334 | 2006-06-23 02:02:58 -0700 | [diff] [blame] | 1883 | static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1884 | { |
David Howells | 726c334 | 2006-06-23 02:02:58 -0700 | [diff] [blame] | 1885 | struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(dentry->d_sb); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1886 | |
| 1887 | buf->f_namelen = (REISERFS_MAX_NAME(s->s_blocksize)); |
| 1888 | buf->f_bfree = sb_free_blocks(rs); |
| 1889 | buf->f_bavail = buf->f_bfree; |
| 1890 | buf->f_blocks = sb_block_count(rs) - sb_bmap_nr(rs) - 1; |
David Howells | 726c334 | 2006-06-23 02:02:58 -0700 | [diff] [blame] | 1891 | buf->f_bsize = dentry->d_sb->s_blocksize; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1892 | /* changed to accommodate gcc folks. */ |
| 1893 | buf->f_type = REISERFS_SUPER_MAGIC; |
| 1894 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1895 | } |
| 1896 | |
| 1897 | #ifdef CONFIG_QUOTA |
| 1898 | static int reiserfs_dquot_initialize(struct inode *inode, int type) |
| 1899 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1900 | struct reiserfs_transaction_handle th; |
| 1901 | int ret, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1902 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1903 | /* We may create quota structure so we need to reserve enough blocks */ |
| 1904 | reiserfs_write_lock(inode->i_sb); |
| 1905 | ret = |
| 1906 | journal_begin(&th, inode->i_sb, |
| 1907 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb)); |
| 1908 | if (ret) |
| 1909 | goto out; |
| 1910 | ret = dquot_initialize(inode, type); |
| 1911 | err = |
| 1912 | journal_end(&th, inode->i_sb, |
| 1913 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb)); |
| 1914 | if (!ret && err) |
| 1915 | ret = err; |
| 1916 | out: |
| 1917 | reiserfs_write_unlock(inode->i_sb); |
| 1918 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1919 | } |
| 1920 | |
| 1921 | static int reiserfs_dquot_drop(struct inode *inode) |
| 1922 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1923 | struct reiserfs_transaction_handle th; |
| 1924 | int ret, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1925 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1926 | /* We may delete quota structure so we need to reserve enough blocks */ |
| 1927 | reiserfs_write_lock(inode->i_sb); |
| 1928 | ret = |
| 1929 | journal_begin(&th, inode->i_sb, |
| 1930 | 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb)); |
Jan Kara | a2fe594 | 2008-04-28 02:16:23 -0700 | [diff] [blame] | 1931 | if (ret) { |
| 1932 | /* |
| 1933 | * We call dquot_drop() anyway to at least release references |
| 1934 | * to quota structures so that umount does not hang. |
| 1935 | */ |
| 1936 | dquot_drop(inode); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1937 | goto out; |
Jan Kara | a2fe594 | 2008-04-28 02:16:23 -0700 | [diff] [blame] | 1938 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1939 | ret = dquot_drop(inode); |
| 1940 | err = |
| 1941 | journal_end(&th, inode->i_sb, |
| 1942 | 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb)); |
| 1943 | if (!ret && err) |
| 1944 | ret = err; |
| 1945 | out: |
| 1946 | reiserfs_write_unlock(inode->i_sb); |
| 1947 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1948 | } |
| 1949 | |
| 1950 | static int reiserfs_write_dquot(struct dquot *dquot) |
| 1951 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1952 | struct reiserfs_transaction_handle th; |
| 1953 | int ret, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1954 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1955 | reiserfs_write_lock(dquot->dq_sb); |
| 1956 | ret = |
| 1957 | journal_begin(&th, dquot->dq_sb, |
| 1958 | REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); |
| 1959 | if (ret) |
| 1960 | goto out; |
| 1961 | ret = dquot_commit(dquot); |
| 1962 | err = |
| 1963 | journal_end(&th, dquot->dq_sb, |
| 1964 | REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); |
| 1965 | if (!ret && err) |
| 1966 | ret = err; |
| 1967 | out: |
| 1968 | reiserfs_write_unlock(dquot->dq_sb); |
| 1969 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1970 | } |
| 1971 | |
| 1972 | static int reiserfs_acquire_dquot(struct dquot *dquot) |
| 1973 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1974 | struct reiserfs_transaction_handle th; |
| 1975 | int ret, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1977 | reiserfs_write_lock(dquot->dq_sb); |
| 1978 | ret = |
| 1979 | journal_begin(&th, dquot->dq_sb, |
| 1980 | REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb)); |
| 1981 | if (ret) |
| 1982 | goto out; |
| 1983 | ret = dquot_acquire(dquot); |
| 1984 | err = |
| 1985 | journal_end(&th, dquot->dq_sb, |
| 1986 | REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb)); |
| 1987 | if (!ret && err) |
| 1988 | ret = err; |
| 1989 | out: |
| 1990 | reiserfs_write_unlock(dquot->dq_sb); |
| 1991 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1992 | } |
| 1993 | |
| 1994 | static int reiserfs_release_dquot(struct dquot *dquot) |
| 1995 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1996 | struct reiserfs_transaction_handle th; |
| 1997 | int ret, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 1999 | reiserfs_write_lock(dquot->dq_sb); |
| 2000 | ret = |
| 2001 | journal_begin(&th, dquot->dq_sb, |
| 2002 | REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb)); |
Jan Kara | 9c3013e | 2007-09-11 15:23:29 -0700 | [diff] [blame] | 2003 | if (ret) { |
| 2004 | /* Release dquot anyway to avoid endless cycle in dqput() */ |
| 2005 | dquot_release(dquot); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2006 | goto out; |
Jan Kara | 9c3013e | 2007-09-11 15:23:29 -0700 | [diff] [blame] | 2007 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2008 | ret = dquot_release(dquot); |
| 2009 | err = |
| 2010 | journal_end(&th, dquot->dq_sb, |
| 2011 | REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb)); |
| 2012 | if (!ret && err) |
| 2013 | ret = err; |
| 2014 | out: |
| 2015 | reiserfs_write_unlock(dquot->dq_sb); |
| 2016 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | static int reiserfs_mark_dquot_dirty(struct dquot *dquot) |
| 2020 | { |
Jan Kara | 4506567 | 2008-07-25 01:46:37 -0700 | [diff] [blame] | 2021 | /* Are we journaling quotas? */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2022 | if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] || |
| 2023 | REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) { |
| 2024 | dquot_mark_dquot_dirty(dquot); |
| 2025 | return reiserfs_write_dquot(dquot); |
| 2026 | } else |
| 2027 | return dquot_mark_dquot_dirty(dquot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | } |
| 2029 | |
| 2030 | static int reiserfs_write_info(struct super_block *sb, int type) |
| 2031 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2032 | struct reiserfs_transaction_handle th; |
| 2033 | int ret, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2034 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2035 | /* Data block + inode block */ |
| 2036 | reiserfs_write_lock(sb); |
| 2037 | ret = journal_begin(&th, sb, 2); |
| 2038 | if (ret) |
| 2039 | goto out; |
| 2040 | ret = dquot_commit_info(sb, type); |
| 2041 | err = journal_end(&th, sb, 2); |
| 2042 | if (!ret && err) |
| 2043 | ret = err; |
| 2044 | out: |
| 2045 | reiserfs_write_unlock(sb); |
| 2046 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | /* |
Christoph Hellwig | 84de856 | 2005-06-23 00:09:16 -0700 | [diff] [blame] | 2050 | * Turn on quotas during mount time - we need to find the quota file and such... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2051 | */ |
| 2052 | static int reiserfs_quota_on_mount(struct super_block *sb, int type) |
| 2053 | { |
Christoph Hellwig | 84de856 | 2005-06-23 00:09:16 -0700 | [diff] [blame] | 2054 | return vfs_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type], |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2055 | REISERFS_SB(sb)->s_jquota_fmt, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2056 | } |
| 2057 | |
| 2058 | /* |
| 2059 | * Standard function to be called on quota_on |
| 2060 | */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2061 | static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, |
Jan Kara | 1b445a9 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 2062 | char *path, int remount) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2063 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2064 | int err; |
| 2065 | struct nameidata nd; |
Jan Kara | d5dee5c | 2008-04-28 02:16:23 -0700 | [diff] [blame] | 2066 | struct inode *inode; |
Jan Kara | 5d4f7fd | 2008-07-25 01:46:36 -0700 | [diff] [blame] | 2067 | struct reiserfs_transaction_handle th; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2069 | if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA))) |
| 2070 | return -EINVAL; |
Jan Kara | 1b445a9 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 2071 | /* No more checks needed? Path and format_id are bogus anyway... */ |
| 2072 | if (remount) |
| 2073 | return vfs_quota_on(sb, type, format_id, path, 1); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2074 | err = path_lookup(path, LOOKUP_FOLLOW, &nd); |
| 2075 | if (err) |
| 2076 | return err; |
| 2077 | /* Quotafile not on the same filesystem? */ |
Jan Blunck | 4ac9137 | 2008-02-14 19:34:32 -0800 | [diff] [blame] | 2078 | if (nd.path.mnt->mnt_sb != sb) { |
Jan Blunck | 1d957f9 | 2008-02-14 19:34:35 -0800 | [diff] [blame] | 2079 | path_put(&nd.path); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2080 | return -EXDEV; |
| 2081 | } |
Jan Kara | d5dee5c | 2008-04-28 02:16:23 -0700 | [diff] [blame] | 2082 | inode = nd.path.dentry->d_inode; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2083 | /* We must not pack tails for quota files on reiserfs for quota IO to work */ |
Jan Kara | d5dee5c | 2008-04-28 02:16:23 -0700 | [diff] [blame] | 2084 | if (!(REISERFS_I(inode)->i_flags & i_nopack_mask)) { |
| 2085 | err = reiserfs_unpack(inode, NULL); |
| 2086 | if (err) { |
| 2087 | reiserfs_warning(sb, |
| 2088 | "reiserfs: Unpacking tail of quota file failed" |
| 2089 | " (%d). Cannot turn on quotas.", err); |
| 2090 | path_put(&nd.path); |
| 2091 | return -EINVAL; |
| 2092 | } |
| 2093 | mark_inode_dirty(inode); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2094 | } |
Jan Kara | 5d4f7fd | 2008-07-25 01:46:36 -0700 | [diff] [blame] | 2095 | /* Journaling quota? */ |
| 2096 | if (REISERFS_SB(sb)->s_qf_names[type]) { |
| 2097 | /* Quotafile not of fs root? */ |
| 2098 | if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode) |
| 2099 | reiserfs_warning(sb, |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2100 | "reiserfs: Quota file not on filesystem root. " |
| 2101 | "Journalled quota will not work."); |
Jan Kara | 5d4f7fd | 2008-07-25 01:46:36 -0700 | [diff] [blame] | 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 | } |
Jan Blunck | 1d957f9 | 2008-02-14 19:34:35 -0800 | [diff] [blame] | 2117 | path_put(&nd.path); |
Jan Kara | 1b445a9 | 2008-04-28 02:14:35 -0700 | [diff] [blame] | 2118 | return vfs_quota_on(sb, type, format_id, path, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2119 | } |
| 2120 | |
| 2121 | /* Read data from quotafile - avoid pagecache and such because we cannot afford |
| 2122 | * acquiring the locks... As quota files are never truncated and quota code |
| 2123 | * itself serializes the operations (and noone else should touch the files) |
| 2124 | * we don't have to be afraid of races */ |
| 2125 | static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data, |
| 2126 | size_t len, loff_t off) |
| 2127 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2128 | struct inode *inode = sb_dqopt(sb)->files[type]; |
| 2129 | unsigned long blk = off >> sb->s_blocksize_bits; |
| 2130 | int err = 0, offset = off & (sb->s_blocksize - 1), tocopy; |
| 2131 | size_t toread; |
| 2132 | struct buffer_head tmp_bh, *bh; |
| 2133 | loff_t i_size = i_size_read(inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2135 | if (off > i_size) |
| 2136 | return 0; |
| 2137 | if (off + len > i_size) |
| 2138 | len = i_size - off; |
| 2139 | toread = len; |
| 2140 | while (toread > 0) { |
| 2141 | tocopy = |
| 2142 | sb->s_blocksize - offset < |
| 2143 | toread ? sb->s_blocksize - offset : toread; |
| 2144 | tmp_bh.b_state = 0; |
| 2145 | /* Quota files are without tails so we can safely use this function */ |
| 2146 | reiserfs_write_lock(sb); |
| 2147 | err = reiserfs_get_block(inode, blk, &tmp_bh, 0); |
| 2148 | reiserfs_write_unlock(sb); |
| 2149 | if (err) |
| 2150 | return err; |
| 2151 | if (!buffer_mapped(&tmp_bh)) /* A hole? */ |
| 2152 | memset(data, 0, tocopy); |
| 2153 | else { |
| 2154 | bh = sb_bread(sb, tmp_bh.b_blocknr); |
| 2155 | if (!bh) |
| 2156 | return -EIO; |
| 2157 | memcpy(data, bh->b_data + offset, tocopy); |
| 2158 | brelse(bh); |
| 2159 | } |
| 2160 | offset = 0; |
| 2161 | toread -= tocopy; |
| 2162 | data += tocopy; |
| 2163 | blk++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2164 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2165 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2166 | } |
| 2167 | |
| 2168 | /* Write to quotafile (we know the transaction is already started and has |
| 2169 | * enough credits) */ |
| 2170 | static ssize_t reiserfs_quota_write(struct super_block *sb, int type, |
| 2171 | const char *data, size_t len, loff_t off) |
| 2172 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2173 | struct inode *inode = sb_dqopt(sb)->files[type]; |
| 2174 | unsigned long blk = off >> sb->s_blocksize_bits; |
| 2175 | int err = 0, offset = off & (sb->s_blocksize - 1), tocopy; |
| 2176 | int journal_quota = REISERFS_SB(sb)->s_qf_names[type] != NULL; |
| 2177 | size_t towrite = len; |
| 2178 | struct buffer_head tmp_bh, *bh; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | |
Jan Kara | 9c3013e | 2007-09-11 15:23:29 -0700 | [diff] [blame] | 2180 | if (!current->journal_info) { |
| 2181 | printk(KERN_WARNING "reiserfs: Quota write (off=%Lu, len=%Lu)" |
| 2182 | " cancelled because transaction is not started.\n", |
| 2183 | (unsigned long long)off, (unsigned long long)len); |
| 2184 | return -EIO; |
| 2185 | } |
Arjan van de Ven | 5c81a41 | 2006-07-03 00:25:20 -0700 | [diff] [blame] | 2186 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2187 | while (towrite > 0) { |
| 2188 | tocopy = sb->s_blocksize - offset < towrite ? |
| 2189 | sb->s_blocksize - offset : towrite; |
| 2190 | tmp_bh.b_state = 0; |
| 2191 | err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE); |
| 2192 | if (err) |
| 2193 | goto out; |
| 2194 | if (offset || tocopy != sb->s_blocksize) |
| 2195 | bh = sb_bread(sb, tmp_bh.b_blocknr); |
| 2196 | else |
| 2197 | bh = sb_getblk(sb, tmp_bh.b_blocknr); |
| 2198 | if (!bh) { |
| 2199 | err = -EIO; |
| 2200 | goto out; |
| 2201 | } |
| 2202 | lock_buffer(bh); |
| 2203 | memcpy(bh->b_data + offset, data, tocopy); |
| 2204 | flush_dcache_page(bh->b_page); |
| 2205 | set_buffer_uptodate(bh); |
| 2206 | unlock_buffer(bh); |
| 2207 | reiserfs_prepare_for_journal(sb, bh, 1); |
| 2208 | journal_mark_dirty(current->journal_info, sb, bh); |
| 2209 | if (!journal_quota) |
| 2210 | reiserfs_add_ordered_list(inode, bh); |
| 2211 | brelse(bh); |
| 2212 | offset = 0; |
| 2213 | towrite -= tocopy; |
| 2214 | data += tocopy; |
| 2215 | blk++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | } |
Jan Kara | 9c3013e | 2007-09-11 15:23:29 -0700 | [diff] [blame] | 2217 | out: |
Jan Kara | 10dd08d | 2008-07-04 09:59:34 -0700 | [diff] [blame] | 2218 | if (len == towrite) { |
| 2219 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2220 | return err; |
Jan Kara | 10dd08d | 2008-07-04 09:59:34 -0700 | [diff] [blame] | 2221 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2222 | if (inode->i_size < off + len - towrite) |
| 2223 | i_size_write(inode, off + len - towrite); |
| 2224 | inode->i_version++; |
| 2225 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
| 2226 | mark_inode_dirty(inode); |
Jes Sorensen | 1b1dcc1 | 2006-01-09 15:59:24 -0800 | [diff] [blame] | 2227 | mutex_unlock(&inode->i_mutex); |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2228 | return len - towrite; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2229 | } |
| 2230 | |
| 2231 | #endif |
| 2232 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 2233 | static int get_super_block(struct file_system_type *fs_type, |
| 2234 | int flags, const char *dev_name, |
| 2235 | void *data, struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2236 | { |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 2237 | return get_sb_bdev(fs_type, flags, dev_name, data, reiserfs_fill_super, |
| 2238 | mnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2239 | } |
| 2240 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2241 | static int __init init_reiserfs_fs(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2242 | { |
| 2243 | int ret; |
| 2244 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2245 | if ((ret = init_inodecache())) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | return ret; |
| 2247 | } |
| 2248 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2249 | if ((ret = reiserfs_xattr_register_handlers())) |
| 2250 | goto failed_reiserfs_xattr_register_handlers; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2252 | reiserfs_proc_info_global_init(); |
| 2253 | reiserfs_proc_register_global("version", |
| 2254 | reiserfs_global_version_in_proc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2255 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2256 | ret = register_filesystem(&reiserfs_fs_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2257 | |
| 2258 | if (ret == 0) { |
| 2259 | return 0; |
| 2260 | } |
| 2261 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2262 | reiserfs_xattr_unregister_handlers(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2263 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2264 | failed_reiserfs_xattr_register_handlers: |
| 2265 | reiserfs_proc_unregister_global("version"); |
| 2266 | reiserfs_proc_info_global_done(); |
| 2267 | destroy_inodecache(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | |
| 2269 | return ret; |
| 2270 | } |
| 2271 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2272 | static void __exit exit_reiserfs_fs(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2274 | reiserfs_xattr_unregister_handlers(); |
| 2275 | reiserfs_proc_unregister_global("version"); |
| 2276 | reiserfs_proc_info_global_done(); |
| 2277 | unregister_filesystem(&reiserfs_fs_type); |
| 2278 | destroy_inodecache(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | } |
| 2280 | |
| 2281 | struct file_system_type reiserfs_fs_type = { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2282 | .owner = THIS_MODULE, |
| 2283 | .name = "reiserfs", |
| 2284 | .get_sb = get_super_block, |
David Howells | edc666e | 2006-10-11 01:22:14 -0700 | [diff] [blame] | 2285 | .kill_sb = reiserfs_kill_sb, |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2286 | .fs_flags = FS_REQUIRES_DEV, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2287 | }; |
| 2288 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2289 | MODULE_DESCRIPTION("ReiserFS journaled filesystem"); |
| 2290 | MODULE_AUTHOR("Hans Reiser <reiser@namesys.com>"); |
| 2291 | MODULE_LICENSE("GPL"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2292 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 2293 | module_init(init_reiserfs_fs); |
| 2294 | module_exit(exit_reiserfs_fs); |