2 * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
4 * Trivial changes by Alan Cox to add the LFS fixes
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.
14 #include <linux/config.h>
15 #include <linux/module.h>
16 #include <linux/vmalloc.h>
17 #include <linux/time.h>
18 #include <asm/uaccess.h>
19 #include <linux/reiserfs_fs.h>
20 #include <linux/reiserfs_acl.h>
21 #include <linux/reiserfs_xattr.h>
22 #include <linux/smp_lock.h>
23 #include <linux/init.h>
24 #include <linux/blkdev.h>
25 #include <linux/buffer_head.h>
26 #include <linux/vfs.h>
27 #include <linux/namespace.h>
28 #include <linux/mount.h>
29 #include <linux/namei.h>
30 #include <linux/quotaops.h>
32 struct file_system_type reiserfs_fs_type;
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;
38 int is_reiserfs_3_5(struct reiserfs_super_block *rs)
40 return !strncmp(rs->s_v1.s_magic, reiserfs_3_5_magic_string,
41 strlen(reiserfs_3_5_magic_string));
44 int is_reiserfs_3_6(struct reiserfs_super_block *rs)
46 return !strncmp(rs->s_v1.s_magic, reiserfs_3_6_magic_string,
47 strlen(reiserfs_3_6_magic_string));
50 int is_reiserfs_jr(struct reiserfs_super_block *rs)
52 return !strncmp(rs->s_v1.s_magic, reiserfs_jr_magic_string,
53 strlen(reiserfs_jr_magic_string));
56 static int is_any_reiserfs_magic_string(struct reiserfs_super_block *rs)
58 return (is_reiserfs_3_5(rs) || is_reiserfs_3_6(rs) ||
62 static int reiserfs_remount(struct super_block *s, int *flags, char *data);
63 static int reiserfs_statfs(struct super_block *s, struct kstatfs *buf);
65 static int reiserfs_sync_fs(struct super_block *s, int wait)
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);
82 static void reiserfs_write_super(struct super_block *s)
84 reiserfs_sync_fs(s, 1);
87 static void reiserfs_write_super_lockfs(struct super_block *s)
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);
94 reiserfs_block_writes(&th);
96 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
98 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
99 reiserfs_block_writes(&th);
100 journal_end_sync(&th, s, 1);
104 reiserfs_write_unlock(s);
107 static void reiserfs_unlockfs(struct super_block *s)
109 reiserfs_allow_writes(s);
112 extern const struct in_core_key MAX_IN_CORE_KEY;
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
121 static int remove_save_link_only(struct super_block *s,
122 struct reiserfs_key *key, int oid_free)
124 struct reiserfs_transaction_handle th;
127 /* we are going to do one balancing */
128 err = journal_begin(&th, s, JOURNAL_PER_BALANCE_CNT);
132 reiserfs_delete_solid_item(&th, NULL, key);
134 /* removals are protected by direct items */
135 reiserfs_release_objectid(&th, le32_to_cpu(key->k_objectid));
137 return journal_end(&th, s, JOURNAL_PER_BALANCE_CNT);
141 static int reiserfs_quota_on_mount(struct super_block *, int);
144 /* look for uncompleted unlinks and truncates and complete them */
145 static int finish_unfinished(struct super_block *s)
147 INITIALIZE_PATH(path);
148 struct cpu_key max_cpu_key, obj_key;
149 struct reiserfs_key save_link_key;
151 struct item_head *ih;
152 struct buffer_head *bh;
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;
171 /* Needed for iput() to work correctly and not trash data */
172 if (s->s_flags & MS_ACTIVE) {
176 s->s_flags |= MS_ACTIVE;
178 /* Turn on quotas so that they are updated correctly */
179 for (i = 0; i < MAXQUOTAS; i++) {
180 if (REISERFS_SB(s)->s_qf_names[i]) {
181 int ret = reiserfs_quota_on_mount(s, i);
184 "reiserfs: cannot turn on journalled quota: error %d",
191 REISERFS_SB(s)->s_is_unlinked_ok = 1;
193 retval = search_item(s, &max_cpu_key, &path);
194 if (retval != ITEM_NOT_FOUND) {
196 "vs-2140: finish_unfinished: search_by_key returned %d",
201 bh = get_last_bh(&path);
202 item_pos = get_item_pos(&path);
203 if (item_pos != B_NR_ITEMS(bh)) {
205 "vs-2060: finish_unfinished: wrong position found");
209 ih = B_N_PITEM_HEAD(bh, item_pos);
211 if (le32_to_cpu(ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID)
212 /* there are no "save" links anymore */
215 save_link_key = ih->ih_key;
216 if (is_indirect_le_ih(ih))
221 /* reiserfs_iget needs k_dirid and k_objectid only */
222 item = B_I_PITEM(bh, ih);
223 obj_key.on_disk_key.k_dir_id = le32_to_cpu(*(__le32 *) item);
224 obj_key.on_disk_key.k_objectid =
225 le32_to_cpu(ih->ih_key.k_objectid);
226 obj_key.on_disk_key.k_offset = 0;
227 obj_key.on_disk_key.k_type = 0;
231 inode = reiserfs_iget(s, &obj_key);
233 /* the unlink almost completed, it just did not manage to remove
234 "save" link and release objectid */
236 "vs-2180: finish_unfinished: iget failed for %K",
238 retval = remove_save_link_only(s, &save_link_key, 1);
242 if (!truncate && inode->i_nlink) {
243 /* file is not unlinked */
245 "vs-2185: finish_unfinished: file %K is not unlinked",
247 retval = remove_save_link_only(s, &save_link_key, 0);
252 if (truncate && S_ISDIR(inode->i_mode)) {
253 /* We got a truncate request for a dir which is impossible.
254 The only imaginable way is to execute unfinished truncate request
255 then boot into old kernel, remove the file and create dir with
258 "green-2101: impossible truncate on a directory %k. Please report",
260 retval = remove_save_link_only(s, &save_link_key, 0);
267 REISERFS_I(inode)->i_flags |=
268 i_link_saved_truncate_mask;
269 /* not completed truncate found. New size was committed together
271 reiserfs_info(s, "Truncating %k to %Ld ..",
272 INODE_PKEY(inode), inode->i_size);
273 reiserfs_truncate_file(inode,
275 /*don't update modification time */
277 retval = remove_save_link(inode, truncate);
279 REISERFS_I(inode)->i_flags |= i_link_saved_unlink_mask;
280 /* not completed unlink (rmdir) found */
281 reiserfs_info(s, "Removing %k..", INODE_PKEY(inode));
282 /* removal gets completed in iput */
290 REISERFS_SB(s)->s_is_unlinked_ok = 0;
293 /* Turn quotas off */
294 for (i = 0; i < MAXQUOTAS; i++) {
295 if (sb_dqopt(s)->files[i])
296 vfs_quota_off_mount(s, i);
299 /* Restore the flag back */
300 s->s_flags &= ~MS_ACTIVE;
304 reiserfs_info(s, "There were %d uncompleted unlinks/truncates. "
305 "Completed\n", done);
309 /* to protect file being unlinked from getting lost we "safe" link files
310 being unlinked. This link will be deleted in the same transaction with last
311 item of file. mounting the filesytem we scan all these links and remove
312 files which almost got lost */
313 void add_save_link(struct reiserfs_transaction_handle *th,
314 struct inode *inode, int truncate)
316 INITIALIZE_PATH(path);
322 BUG_ON(!th->t_trans_id);
324 /* file can only get one "save link" of each kind */
326 (REISERFS_I(inode)->i_flags & i_link_saved_truncate_mask),
327 "saved link already exists for truncated inode %lx",
330 (REISERFS_I(inode)->i_flags & i_link_saved_unlink_mask),
331 "saved link already exists for unlinked inode %lx",
334 /* setup key of "save" link */
335 key.version = KEY_FORMAT_3_5;
336 key.on_disk_key.k_dir_id = MAX_KEY_OBJECTID;
337 key.on_disk_key.k_objectid = inode->i_ino;
339 /* unlink, rmdir, rename */
340 set_cpu_key_k_offset(&key, 1 + inode->i_sb->s_blocksize);
341 set_cpu_key_k_type(&key, TYPE_DIRECT);
343 /* item head of "safe" link */
344 make_le_item_head(&ih, &key, key.version,
345 1 + inode->i_sb->s_blocksize, TYPE_DIRECT,
346 4 /*length */ , 0xffff /*free space */ );
349 if (S_ISDIR(inode->i_mode))
350 reiserfs_warning(inode->i_sb,
351 "green-2102: Adding a truncate savelink for a directory %k! Please report",
353 set_cpu_key_k_offset(&key, 1);
354 set_cpu_key_k_type(&key, TYPE_INDIRECT);
356 /* item head of "safe" link */
357 make_le_item_head(&ih, &key, key.version, 1, TYPE_INDIRECT,
358 4 /*length */ , 0 /*free space */ );
362 /* look for its place in the tree */
363 retval = search_item(inode->i_sb, &key, &path);
364 if (retval != ITEM_NOT_FOUND) {
365 if (retval != -ENOSPC)
366 reiserfs_warning(inode->i_sb, "vs-2100: add_save_link:"
367 "search_by_key (%K) returned %d", &key,
373 /* body of "save" link */
374 link = INODE_PKEY(inode)->k_dir_id;
376 /* put "save" link inot tree, don't charge quota to anyone */
378 reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link);
380 if (retval != -ENOSPC)
381 reiserfs_warning(inode->i_sb,
382 "vs-2120: add_save_link: insert_item returned %d",
386 REISERFS_I(inode)->i_flags |=
387 i_link_saved_truncate_mask;
389 REISERFS_I(inode)->i_flags |= i_link_saved_unlink_mask;
393 /* this opens transaction unlike add_save_link */
394 int remove_save_link(struct inode *inode, int truncate)
396 struct reiserfs_transaction_handle th;
397 struct reiserfs_key key;
400 /* we are going to do one balancing only */
401 err = journal_begin(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
405 /* setup key of "save" link */
406 key.k_dir_id = cpu_to_le32(MAX_KEY_OBJECTID);
407 key.k_objectid = INODE_PKEY(inode)->k_objectid;
409 /* unlink, rmdir, rename */
410 set_le_key_k_offset(KEY_FORMAT_3_5, &key,
411 1 + inode->i_sb->s_blocksize);
412 set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_DIRECT);
415 set_le_key_k_offset(KEY_FORMAT_3_5, &key, 1);
416 set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_INDIRECT);
420 (REISERFS_I(inode)->i_flags & i_link_saved_truncate_mask)) ||
422 (REISERFS_I(inode)->i_flags & i_link_saved_unlink_mask)))
423 /* don't take quota bytes from anywhere */
424 reiserfs_delete_solid_item(&th, NULL, &key);
426 reiserfs_release_objectid(&th, inode->i_ino);
427 REISERFS_I(inode)->i_flags &= ~i_link_saved_unlink_mask;
429 REISERFS_I(inode)->i_flags &= ~i_link_saved_truncate_mask;
431 return journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
434 static void reiserfs_put_super(struct super_block *s)
437 struct reiserfs_transaction_handle th;
440 if (REISERFS_SB(s)->xattr_root) {
441 d_invalidate(REISERFS_SB(s)->xattr_root);
442 dput(REISERFS_SB(s)->xattr_root);
445 if (REISERFS_SB(s)->priv_root) {
446 d_invalidate(REISERFS_SB(s)->priv_root);
447 dput(REISERFS_SB(s)->priv_root);
450 /* change file system state to current state if it was mounted with read-write permissions */
451 if (!(s->s_flags & MS_RDONLY)) {
452 if (!journal_begin(&th, s, 10)) {
453 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
455 set_sb_umount_state(SB_DISK_SUPER_BLOCK(s),
456 REISERFS_SB(s)->s_mount_state);
457 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
461 /* note, journal_release checks for readonly mount, and can decide not
462 ** to do a journal_end
464 journal_release(&th, s);
466 for (i = 0; i < SB_BMAP_NR(s); i++)
467 brelse(SB_AP_BITMAP(s)[i].bh);
469 vfree(SB_AP_BITMAP(s));
471 brelse(SB_BUFFER_WITH_SB(s));
475 if (REISERFS_SB(s)->reserved_blocks != 0) {
477 "green-2005: reiserfs_put_super: reserved blocks left %d",
478 REISERFS_SB(s)->reserved_blocks);
481 reiserfs_proc_info_done(s);
489 static kmem_cache_t *reiserfs_inode_cachep;
491 static struct inode *reiserfs_alloc_inode(struct super_block *sb)
493 struct reiserfs_inode_info *ei;
494 ei = (struct reiserfs_inode_info *)
495 kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL);
498 return &ei->vfs_inode;
501 static void reiserfs_destroy_inode(struct inode *inode)
503 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
506 static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
508 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
510 if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
511 SLAB_CTOR_CONSTRUCTOR) {
512 INIT_LIST_HEAD(&ei->i_prealloc_list);
513 inode_init_once(&ei->vfs_inode);
514 ei->i_acl_access = NULL;
515 ei->i_acl_default = NULL;
519 static int init_inodecache(void)
521 reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache",
523 reiserfs_inode_info),
524 0, SLAB_RECLAIM_ACCOUNT,
526 if (reiserfs_inode_cachep == NULL)
531 static void destroy_inodecache(void)
533 if (kmem_cache_destroy(reiserfs_inode_cachep))
534 reiserfs_warning(NULL,
535 "reiserfs_inode_cache: not all structures were freed");
538 /* we don't mark inodes dirty, we just log them */
539 static void reiserfs_dirty_inode(struct inode *inode)
541 struct reiserfs_transaction_handle th;
544 if (inode->i_sb->s_flags & MS_RDONLY) {
545 reiserfs_warning(inode->i_sb,
546 "clm-6006: writing inode %lu on readonly FS",
550 reiserfs_write_lock(inode->i_sb);
552 /* this is really only used for atime updates, so they don't have
553 ** to be included in O_SYNC or fsync
555 err = journal_begin(&th, inode->i_sb, 1);
557 reiserfs_write_unlock(inode->i_sb);
560 reiserfs_update_sd(&th, inode);
561 journal_end(&th, inode->i_sb, 1);
562 reiserfs_write_unlock(inode->i_sb);
565 static void reiserfs_clear_inode(struct inode *inode)
567 struct posix_acl *acl;
569 acl = REISERFS_I(inode)->i_acl_access;
570 if (acl && !IS_ERR(acl))
571 posix_acl_release(acl);
572 REISERFS_I(inode)->i_acl_access = NULL;
574 acl = REISERFS_I(inode)->i_acl_default;
575 if (acl && !IS_ERR(acl))
576 posix_acl_release(acl);
577 REISERFS_I(inode)->i_acl_default = NULL;
581 static ssize_t reiserfs_quota_write(struct super_block *, int, const char *,
583 static ssize_t reiserfs_quota_read(struct super_block *, int, char *, size_t,
587 static struct super_operations reiserfs_sops = {
588 .alloc_inode = reiserfs_alloc_inode,
589 .destroy_inode = reiserfs_destroy_inode,
590 .write_inode = reiserfs_write_inode,
591 .dirty_inode = reiserfs_dirty_inode,
592 .delete_inode = reiserfs_delete_inode,
593 .clear_inode = reiserfs_clear_inode,
594 .put_super = reiserfs_put_super,
595 .write_super = reiserfs_write_super,
596 .sync_fs = reiserfs_sync_fs,
597 .write_super_lockfs = reiserfs_write_super_lockfs,
598 .unlockfs = reiserfs_unlockfs,
599 .statfs = reiserfs_statfs,
600 .remount_fs = reiserfs_remount,
602 .quota_read = reiserfs_quota_read,
603 .quota_write = reiserfs_quota_write,
608 #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")
610 static int reiserfs_dquot_initialize(struct inode *, int);
611 static int reiserfs_dquot_drop(struct inode *);
612 static int reiserfs_write_dquot(struct dquot *);
613 static int reiserfs_acquire_dquot(struct dquot *);
614 static int reiserfs_release_dquot(struct dquot *);
615 static int reiserfs_mark_dquot_dirty(struct dquot *);
616 static int reiserfs_write_info(struct super_block *, int);
617 static int reiserfs_quota_on(struct super_block *, int, int, char *);
619 static struct dquot_operations reiserfs_quota_operations = {
620 .initialize = reiserfs_dquot_initialize,
621 .drop = reiserfs_dquot_drop,
622 .alloc_space = dquot_alloc_space,
623 .alloc_inode = dquot_alloc_inode,
624 .free_space = dquot_free_space,
625 .free_inode = dquot_free_inode,
626 .transfer = dquot_transfer,
627 .write_dquot = reiserfs_write_dquot,
628 .acquire_dquot = reiserfs_acquire_dquot,
629 .release_dquot = reiserfs_release_dquot,
630 .mark_dirty = reiserfs_mark_dquot_dirty,
631 .write_info = reiserfs_write_info,
634 static struct quotactl_ops reiserfs_qctl_operations = {
635 .quota_on = reiserfs_quota_on,
636 .quota_off = vfs_quota_off,
637 .quota_sync = vfs_quota_sync,
638 .get_info = vfs_get_dqinfo,
639 .set_info = vfs_set_dqinfo,
640 .get_dqblk = vfs_get_dqblk,
641 .set_dqblk = vfs_set_dqblk,
645 static struct export_operations reiserfs_export_ops = {
646 .encode_fh = reiserfs_encode_fh,
647 .decode_fh = reiserfs_decode_fh,
648 .get_parent = reiserfs_get_parent,
649 .get_dentry = reiserfs_get_dentry,
652 /* this struct is used in reiserfs_getopt () for containing the value for those
653 mount options that have values rather than being toggles. */
656 int setmask; /* bitmask which is to set on mount_options bitmask when this
657 value is found, 0 is no bits are to be changed. */
658 int clrmask; /* bitmask which is to clear on mount_options bitmask when this
659 value is found, 0 is no bits are to be changed. This is
660 applied BEFORE setmask */
663 /* Set this bit in arg_required to allow empty arguments */
664 #define REISERFS_OPT_ALLOWEMPTY 31
666 /* this struct is used in reiserfs_getopt() for describing the set of reiserfs
670 int arg_required; /* 0 if argument is not required, not 0 otherwise */
671 const arg_desc_t *values; /* list of values accepted by an option */
672 int setmask; /* bitmask which is to set on mount_options bitmask when this
673 value is found, 0 is no bits are to be changed. */
674 int clrmask; /* bitmask which is to clear on mount_options bitmask when this
675 value is found, 0 is no bits are to be changed. This is
676 applied BEFORE setmask */
679 /* possible values for -o data= */
680 static const arg_desc_t logging_mode[] = {
681 {"ordered", 1 << REISERFS_DATA_ORDERED,
682 (1 << REISERFS_DATA_LOG | 1 << REISERFS_DATA_WRITEBACK)},
683 {"journal", 1 << REISERFS_DATA_LOG,
684 (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)},
685 {"writeback", 1 << REISERFS_DATA_WRITEBACK,
686 (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)},
690 /* possible values for -o barrier= */
691 static const arg_desc_t barrier_mode[] = {
692 {"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH},
693 {"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE},
697 /* possible values for "-o block-allocator=" and bits which are to be set in
698 s_mount_opt of reiserfs specific part of in-core super block */
699 static const arg_desc_t balloc[] = {
700 {"noborder", 1 << REISERFS_NO_BORDER, 0},
701 {"border", 0, 1 << REISERFS_NO_BORDER},
702 {"no_unhashed_relocation", 1 << REISERFS_NO_UNHASHED_RELOCATION, 0},
703 {"hashed_relocation", 1 << REISERFS_HASHED_RELOCATION, 0},
704 {"test4", 1 << REISERFS_TEST4, 0},
705 {"notest4", 0, 1 << REISERFS_TEST4},
709 static const arg_desc_t tails[] = {
710 {"on", 1 << REISERFS_LARGETAIL, 1 << REISERFS_SMALLTAIL},
711 {"off", 0, (1 << REISERFS_LARGETAIL) | (1 << REISERFS_SMALLTAIL)},
712 {"small", 1 << REISERFS_SMALLTAIL, 1 << REISERFS_LARGETAIL},
716 static const arg_desc_t error_actions[] = {
717 {"panic", 1 << REISERFS_ERROR_PANIC,
718 (1 << REISERFS_ERROR_RO | 1 << REISERFS_ERROR_CONTINUE)},
719 {"ro-remount", 1 << REISERFS_ERROR_RO,
720 (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_CONTINUE)},
721 #ifdef REISERFS_JOURNAL_ERROR_ALLOWS_NO_LOG
722 {"continue", 1 << REISERFS_ERROR_CONTINUE,
723 (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_RO)},
728 int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 128k.
729 There might be broken applications that are
730 confused by this. Use nolargeio mount option
731 to get usual i/o size = PAGE_SIZE.
734 /* proceed only one option from a list *cur - string containing of mount options
735 opts - array of options which are accepted
736 opt_arg - if option is found and requires an argument and if it is specifed
737 in the input - pointer to the argument is stored here
738 bit_flags - if option requires to set a certain bit - it is set here
739 return -1 if unknown option is found, opt->arg_required otherwise */
740 static int reiserfs_getopt(struct super_block *s, char **cur, opt_desc_t * opts,
741 char **opt_arg, unsigned long *bit_flags)
750 const opt_desc_t *opt;
751 const arg_desc_t *arg;
755 /* assume argument cannot contain commas */
756 *cur = strchr(p, ',');
762 if (!strncmp(p, "alloc=", 6)) {
763 /* Ugly special case, probably we should redo options parser so that
764 it can understand several arguments for some options, also so that
765 it can fill several bitfields with option values. */
766 if (reiserfs_parse_alloc_options(s, p + 6)) {
773 /* for every option in the list */
774 for (opt = opts; opt->option_name; opt++) {
775 if (!strncmp(p, opt->option_name, strlen(opt->option_name))) {
778 (1 << REISERFS_UNSUPPORTED_OPT))
779 reiserfs_warning(s, "%s not supported.",
782 *bit_flags &= ~opt->clrmask;
784 (1 << REISERFS_UNSUPPORTED_OPT))
785 reiserfs_warning(s, "%s not supported.",
788 *bit_flags |= opt->setmask;
793 if (!opt->option_name) {
794 reiserfs_warning(s, "unknown mount option \"%s\"", p);
798 p += strlen(opt->option_name);
801 if (!opt->arg_required) {
803 "the option \"%s\" does not require an argument",
810 if (opt->arg_required) {
812 "the option \"%s\" requires an argument",
818 reiserfs_warning(s, "head of option \"%s\" is only correct",
823 /* move to the argument, or to next option if argument is not required */
826 if (opt->arg_required
827 && !(opt->arg_required & (1 << REISERFS_OPT_ALLOWEMPTY))
829 /* this catches "option=," if not allowed */
830 reiserfs_warning(s, "empty argument for \"%s\"",
836 /* *=NULLopt_arg contains pointer to argument */
838 return opt->arg_required & ~(1 << REISERFS_OPT_ALLOWEMPTY);
841 /* values possible for this option are listed in opt->values */
842 for (arg = opt->values; arg->value; arg++) {
843 if (!strcmp(p, arg->value)) {
845 *bit_flags &= ~arg->clrmask;
846 *bit_flags |= arg->setmask;
848 return opt->arg_required;
852 reiserfs_warning(s, "bad value \"%s\" for option \"%s\"", p,
857 /* returns 0 if something is wrong in option string, 1 - otherwise */
858 static int reiserfs_parse_options(struct super_block *s, char *options, /* string given via mount's -o */
859 unsigned long *mount_options,
860 /* after the parsing phase, contains the
861 collection of bitflags defining what
862 mount options were selected. */
863 unsigned long *blocks, /* strtol-ed from NNN of resize=NNN */
865 unsigned int *commit_max_age)
870 opt_desc_t opts[] = {
871 /* Compatibility stuff, so that -o notail for old setups still work */
872 {"tails",.arg_required = 't',.values = tails},
874 (1 << REISERFS_LARGETAIL) | (1 << REISERFS_SMALLTAIL)},
875 {"conv",.setmask = 1 << REISERFS_CONVERT},
876 {"attrs",.setmask = 1 << REISERFS_ATTRS},
877 {"noattrs",.clrmask = 1 << REISERFS_ATTRS},
878 #ifdef CONFIG_REISERFS_FS_XATTR
879 {"user_xattr",.setmask = 1 << REISERFS_XATTRS_USER},
880 {"nouser_xattr",.clrmask = 1 << REISERFS_XATTRS_USER},
882 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
883 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
885 #ifndef CONFIG_INOXID_NONE
886 {"tagxid",.setmask = 1 << REISERFS_TAGXID},
888 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
889 {"acl",.setmask = 1 << REISERFS_POSIXACL},
890 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
892 {"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
893 {"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
895 {"nolog",}, /* This is unsupported */
896 {"replayonly",.setmask = 1 << REPLAYONLY},
897 {"block-allocator",.arg_required = 'a',.values = balloc},
898 {"data",.arg_required = 'd',.values = logging_mode},
899 {"barrier",.arg_required = 'b',.values = barrier_mode},
900 {"resize",.arg_required = 'r',.values = NULL},
901 {"jdev",.arg_required = 'j',.values = NULL},
902 {"nolargeio",.arg_required = 'w',.values = NULL},
903 {"commit",.arg_required = 'c',.values = NULL},
904 {"usrquota",.setmask = 1 << REISERFS_QUOTA},
905 {"grpquota",.setmask = 1 << REISERFS_QUOTA},
906 {"noquota",.clrmask = 1 << REISERFS_QUOTA},
907 {"errors",.arg_required = 'e',.values = error_actions},
908 {"usrjquota",.arg_required =
909 'u' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
910 {"grpjquota",.arg_required =
911 'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
912 {"jqfmt",.arg_required = 'f',.values = NULL},
917 if (!options || !*options)
918 /* use default configuration: create tails, journaling on, no
919 conversion to newest format */
922 for (pos = options; pos;) {
923 c = reiserfs_getopt(s, &pos, opts, &arg, mount_options);
925 /* wrong option is given */
932 /* "resize=NNN" or "resize=auto" */
934 if (!strcmp(arg, "auto")) {
935 /* From JFS code, to auto-get the size. */
937 s->s_bdev->bd_inode->i_size >> s->
940 *blocks = simple_strtoul(arg, &p, 0);
942 /* NNN does not look like a number */
944 "reiserfs_parse_options: bad value %s",
953 unsigned long val = simple_strtoul(arg, &p, 0);
954 /* commit=NNN (time in seconds) */
955 if (*p != '\0' || val >= (unsigned int)-1) {
957 "reiserfs_parse_options: bad value %s",
961 *commit_max_age = (unsigned int)val;
966 int val = simple_strtoul(arg, &p, 0);
970 "reiserfs_parse_options: non-numeric value %s for nolargeio option",
975 reiserfs_default_io_size = PAGE_SIZE;
977 reiserfs_default_io_size = 128 * 1024;
981 if (arg && *arg && jdev_name) {
982 if (*jdev_name) { //Hm, already assigned?
984 "reiserfs_parse_options: journal device was already specified to be %s",
992 if (c == 'u' || c == 'g') {
993 int qtype = c == 'u' ? USRQUOTA : GRPQUOTA;
995 if (sb_any_quota_enabled(s)) {
997 "reiserfs_parse_options: cannot change journalled quota options when quota turned on.");
1000 if (*arg) { /* Some filename specified? */
1001 if (REISERFS_SB(s)->s_qf_names[qtype]
1002 && strcmp(REISERFS_SB(s)->s_qf_names[qtype],
1005 "reiserfs_parse_options: %s quota file already specified.",
1009 if (strchr(arg, '/')) {
1011 "reiserfs_parse_options: quotafile must be on filesystem root.");
1014 REISERFS_SB(s)->s_qf_names[qtype] =
1015 kmalloc(strlen(arg) + 1, GFP_KERNEL);
1016 if (!REISERFS_SB(s)->s_qf_names[qtype]) {
1018 "reiserfs_parse_options: not enough memory for storing quotafile name.");
1021 strcpy(REISERFS_SB(s)->s_qf_names[qtype], arg);
1022 *mount_options |= 1 << REISERFS_QUOTA;
1024 kfree(REISERFS_SB(s)->s_qf_names[qtype]);
1025 REISERFS_SB(s)->s_qf_names[qtype] = NULL;
1029 if (!strcmp(arg, "vfsold"))
1030 REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_OLD;
1031 else if (!strcmp(arg, "vfsv0"))
1032 REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_V0;
1035 "reiserfs_parse_options: unknown quota format specified.");
1040 if (c == 'u' || c == 'g' || c == 'f') {
1042 "reiserfs_parse_options: journalled quota options not supported.");
1049 if (!REISERFS_SB(s)->s_jquota_fmt
1050 && (REISERFS_SB(s)->s_qf_names[USRQUOTA]
1051 || REISERFS_SB(s)->s_qf_names[GRPQUOTA])) {
1053 "reiserfs_parse_options: journalled quota format not specified.");
1056 /* This checking is not precise wrt the quota type but for our purposes it is sufficient */
1057 if (!(*mount_options & (1 << REISERFS_QUOTA))
1058 && sb_any_quota_enabled(s)) {
1060 "reiserfs_parse_options: quota options must be present when quota is turned on.");
1068 static void switch_data_mode(struct super_block *s, unsigned long mode)
1070 REISERFS_SB(s)->s_mount_opt &= ~((1 << REISERFS_DATA_LOG) |
1071 (1 << REISERFS_DATA_ORDERED) |
1072 (1 << REISERFS_DATA_WRITEBACK));
1073 REISERFS_SB(s)->s_mount_opt |= (1 << mode);
1076 static void handle_data_mode(struct super_block *s, unsigned long mount_options)
1078 if (mount_options & (1 << REISERFS_DATA_LOG)) {
1079 if (!reiserfs_data_log(s)) {
1080 switch_data_mode(s, REISERFS_DATA_LOG);
1081 reiserfs_info(s, "switching to journaled data mode\n");
1083 } else if (mount_options & (1 << REISERFS_DATA_ORDERED)) {
1084 if (!reiserfs_data_ordered(s)) {
1085 switch_data_mode(s, REISERFS_DATA_ORDERED);
1086 reiserfs_info(s, "switching to ordered data mode\n");
1088 } else if (mount_options & (1 << REISERFS_DATA_WRITEBACK)) {
1089 if (!reiserfs_data_writeback(s)) {
1090 switch_data_mode(s, REISERFS_DATA_WRITEBACK);
1091 reiserfs_info(s, "switching to writeback data mode\n");
1096 static void handle_barrier_mode(struct super_block *s, unsigned long bits)
1098 int flush = (1 << REISERFS_BARRIER_FLUSH);
1099 int none = (1 << REISERFS_BARRIER_NONE);
1100 int all_barrier = flush | none;
1102 if (bits & all_barrier) {
1103 REISERFS_SB(s)->s_mount_opt &= ~all_barrier;
1105 REISERFS_SB(s)->s_mount_opt |= flush;
1106 printk("reiserfs: enabling write barrier flush mode\n");
1107 } else if (bits & none) {
1108 REISERFS_SB(s)->s_mount_opt |= none;
1109 printk("reiserfs: write barriers turned off\n");
1114 static void handle_attrs(struct super_block *s)
1116 struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
1118 if (reiserfs_attrs(s)) {
1119 if (old_format_only(s)) {
1121 "reiserfs: cannot support attributes on 3.5.x disk format");
1122 REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
1125 if (!(le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared)) {
1127 "reiserfs: cannot support attributes until flag is set in super-block");
1128 REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
1133 static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1135 struct reiserfs_super_block *rs;
1136 struct reiserfs_transaction_handle th;
1137 unsigned long blocks;
1138 unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
1139 unsigned long safe_mask = 0;
1140 unsigned int commit_max_age = (unsigned int)-1;
1141 struct reiserfs_journal *journal = SB_JOURNAL(s);
1147 rs = SB_DISK_SUPER_BLOCK(s);
1149 if (!reiserfs_parse_options
1150 (s, arg, &mount_options, &blocks, NULL, &commit_max_age)) {
1152 for (i = 0; i < MAXQUOTAS; i++) {
1153 kfree(REISERFS_SB(s)->s_qf_names[i]);
1154 REISERFS_SB(s)->s_qf_names[i] = NULL;
1160 if ((mount_options & (1 << REISERFS_TAGXID)) &&
1161 !(s->s_flags & MS_TAGXID)) {
1162 reiserfs_warning(s, "reiserfs: tagxid not permitted on remount.");
1168 /* Add options that are safe here */
1169 safe_mask |= 1 << REISERFS_SMALLTAIL;
1170 safe_mask |= 1 << REISERFS_LARGETAIL;
1171 safe_mask |= 1 << REISERFS_NO_BORDER;
1172 safe_mask |= 1 << REISERFS_NO_UNHASHED_RELOCATION;
1173 safe_mask |= 1 << REISERFS_HASHED_RELOCATION;
1174 safe_mask |= 1 << REISERFS_TEST4;
1175 safe_mask |= 1 << REISERFS_ATTRS;
1176 safe_mask |= 1 << REISERFS_XATTRS_USER;
1177 safe_mask |= 1 << REISERFS_POSIXACL;
1178 safe_mask |= 1 << REISERFS_BARRIER_FLUSH;
1179 safe_mask |= 1 << REISERFS_BARRIER_NONE;
1180 safe_mask |= 1 << REISERFS_ERROR_RO;
1181 safe_mask |= 1 << REISERFS_ERROR_CONTINUE;
1182 safe_mask |= 1 << REISERFS_ERROR_PANIC;
1183 safe_mask |= 1 << REISERFS_QUOTA;
1185 /* Update the bitmask, taking care to keep
1186 * the bits we're not allowed to change here */
1187 REISERFS_SB(s)->s_mount_opt =
1189 s_mount_opt & ~safe_mask) | (mount_options & safe_mask);
1191 if (commit_max_age != 0 && commit_max_age != (unsigned int)-1) {
1192 journal->j_max_commit_age = commit_max_age;
1193 journal->j_max_trans_age = commit_max_age;
1194 } else if (commit_max_age == 0) {
1195 /* 0 means restore defaults. */
1196 journal->j_max_commit_age = journal->j_default_max_commit_age;
1197 journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
1201 int rc = reiserfs_resize(s, blocks);
1206 if (*mount_flags & MS_RDONLY) {
1207 reiserfs_xattr_init(s, *mount_flags);
1208 /* remount read-only */
1209 if (s->s_flags & MS_RDONLY)
1210 /* it is read-only already */
1212 /* try to remount file system with read-only permissions */
1213 if (sb_umount_state(rs) == REISERFS_VALID_FS
1214 || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) {
1218 err = journal_begin(&th, s, 10);
1222 /* Mounting a rw partition read-only. */
1223 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
1224 set_sb_umount_state(rs, REISERFS_SB(s)->s_mount_state);
1225 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
1227 /* remount read-write */
1228 if (!(s->s_flags & MS_RDONLY)) {
1229 reiserfs_xattr_init(s, *mount_flags);
1230 return 0; /* We are read-write already */
1233 if (reiserfs_is_journal_aborted(journal))
1234 return journal->j_errno;
1236 handle_data_mode(s, mount_options);
1237 handle_barrier_mode(s, mount_options);
1238 REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
1239 s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */
1240 err = journal_begin(&th, s, 10);
1244 /* Mount a partition which is read-only, read-write */
1245 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
1246 REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
1247 s->s_flags &= ~MS_RDONLY;
1248 set_sb_umount_state(rs, REISERFS_ERROR_FS);
1249 /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */
1250 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
1251 REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS;
1253 /* this will force a full flush of all journal lists */
1254 SB_JOURNAL(s)->j_must_wait = 1;
1255 err = journal_end(&th, s, 10);
1260 if (!(*mount_flags & MS_RDONLY)) {
1261 finish_unfinished(s);
1262 reiserfs_xattr_init(s, *mount_flags);
1268 /* load_bitmap_info_data - Sets up the reiserfs_bitmap_info structure from disk.
1269 * @sb - superblock for this filesystem
1270 * @bi - the bitmap info to be loaded. Requires that bi->bh is valid.
1272 * This routine counts how many free bits there are, finding the first zero
1273 * as a side effect. Could also be implemented as a loop of test_bit() calls, or
1274 * a loop of find_first_zero_bit() calls. This implementation is similar to
1275 * find_first_zero_bit(), but doesn't return after it finds the first bit.
1276 * Should only be called on fs mount, but should be fairly efficient anyways.
1278 * bi->first_zero_hint is considered unset if it == 0, since the bitmap itself
1279 * will * invariably occupt block 0 represented in the bitmap. The only
1280 * exception to this is when free_count also == 0, since there will be no
1281 * free blocks at all.
1284 static void load_bitmap_info_data(struct super_block *sb,
1285 struct reiserfs_bitmap_info *bi)
1287 unsigned long *cur = (unsigned long *)bi->bh->b_data;
1289 while ((char *)cur < (bi->bh->b_data + sb->s_blocksize)) {
1291 /* No need to scan if all 0's or all 1's.
1292 * Since we're only counting 0's, we can simply ignore all 1's */
1294 if (bi->first_zero_hint == 0) {
1295 bi->first_zero_hint =
1296 ((char *)cur - bi->bh->b_data) << 3;
1298 bi->free_count += sizeof(unsigned long) * 8;
1299 } else if (*cur != ~0L) {
1301 for (b = 0; b < sizeof(unsigned long) * 8; b++) {
1302 if (!reiserfs_test_le_bit(b, cur)) {
1304 if (bi->first_zero_hint == 0)
1305 bi->first_zero_hint =
1307 bi->bh->b_data) << 3) + b;
1314 #ifdef CONFIG_REISERFS_CHECK
1315 // This outputs a lot of unneded info on big FSes
1316 // reiserfs_warning ("bitmap loaded from block %d: %d free blocks",
1317 // bi->bh->b_blocknr, bi->free_count);
1321 static int read_bitmaps(struct super_block *s)
1326 vmalloc(sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
1327 if (SB_AP_BITMAP(s) == 0)
1329 memset(SB_AP_BITMAP(s), 0,
1330 sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
1331 for (i = 0, bmap_nr =
1332 REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1;
1333 i < SB_BMAP_NR(s); i++, bmap_nr = s->s_blocksize * 8 * i) {
1334 SB_AP_BITMAP(s)[i].bh = sb_getblk(s, bmap_nr);
1335 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh))
1336 ll_rw_block(READ, 1, &SB_AP_BITMAP(s)[i].bh);
1338 for (i = 0; i < SB_BMAP_NR(s); i++) {
1339 wait_on_buffer(SB_AP_BITMAP(s)[i].bh);
1340 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
1341 reiserfs_warning(s, "sh-2029: reiserfs read_bitmaps: "
1342 "bitmap block (#%lu) reading failed",
1343 SB_AP_BITMAP(s)[i].bh->b_blocknr);
1344 for (i = 0; i < SB_BMAP_NR(s); i++)
1345 brelse(SB_AP_BITMAP(s)[i].bh);
1346 vfree(SB_AP_BITMAP(s));
1347 SB_AP_BITMAP(s) = NULL;
1350 load_bitmap_info_data(s, SB_AP_BITMAP(s) + i);
1355 static int read_old_bitmaps(struct super_block *s)
1358 struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
1359 int bmp1 = (REISERFS_OLD_DISK_OFFSET_IN_BYTES / s->s_blocksize) + 1; /* first of bitmap blocks */
1361 /* read true bitmap */
1363 vmalloc(sizeof(struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
1364 if (SB_AP_BITMAP(s) == 0)
1367 memset(SB_AP_BITMAP(s), 0,
1368 sizeof(struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
1370 for (i = 0; i < sb_bmap_nr(rs); i++) {
1371 SB_AP_BITMAP(s)[i].bh = sb_bread(s, bmp1 + i);
1372 if (!SB_AP_BITMAP(s)[i].bh)
1374 load_bitmap_info_data(s, SB_AP_BITMAP(s) + i);
1380 static int read_super_block(struct super_block *s, int offset)
1382 struct buffer_head *bh;
1383 struct reiserfs_super_block *rs;
1386 bh = sb_bread(s, offset / s->s_blocksize);
1388 reiserfs_warning(s, "sh-2006: read_super_block: "
1389 "bread failed (dev %s, block %lu, size %lu)",
1390 reiserfs_bdevname(s), offset / s->s_blocksize,
1395 rs = (struct reiserfs_super_block *)bh->b_data;
1396 if (!is_any_reiserfs_magic_string(rs)) {
1401 // ok, reiserfs signature (old or new) found in at the given offset
1403 fs_blocksize = sb_blocksize(rs);
1405 sb_set_blocksize(s, fs_blocksize);
1407 bh = sb_bread(s, offset / s->s_blocksize);
1409 reiserfs_warning(s, "sh-2007: read_super_block: "
1410 "bread failed (dev %s, block %lu, size %lu)\n",
1411 reiserfs_bdevname(s), offset / s->s_blocksize,
1416 rs = (struct reiserfs_super_block *)bh->b_data;
1417 if (sb_blocksize(rs) != s->s_blocksize) {
1418 reiserfs_warning(s, "sh-2011: read_super_block: "
1419 "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n",
1420 reiserfs_bdevname(s),
1421 (unsigned long long)bh->b_blocknr,
1427 if (rs->s_v1.s_root_block == cpu_to_le32(-1)) {
1430 "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
1431 "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
1432 "get newer reiserfsprogs package");
1436 SB_BUFFER_WITH_SB(s) = bh;
1437 SB_DISK_SUPER_BLOCK(s) = rs;
1439 if (is_reiserfs_jr(rs)) {
1440 /* magic is of non-standard journal filesystem, look at s_version to
1441 find which format is in use */
1442 if (sb_version(rs) == REISERFS_VERSION_2)
1444 "read_super_block: found reiserfs format \"3.6\""
1445 " with non-standard journal");
1446 else if (sb_version(rs) == REISERFS_VERSION_1)
1448 "read_super_block: found reiserfs format \"3.5\""
1449 " with non-standard journal");
1452 "sh-2012: read_super_block: found unknown "
1453 "format \"%u\" of reiserfs with non-standard magic",
1458 /* s_version of standard format may contain incorrect information,
1459 so we just look at the magic string */
1461 "found reiserfs format \"%s\" with standard journal\n",
1462 is_reiserfs_3_5(rs) ? "3.5" : "3.6");
1464 s->s_op = &reiserfs_sops;
1465 s->s_export_op = &reiserfs_export_ops;
1467 s->s_qcop = &reiserfs_qctl_operations;
1468 s->dq_op = &reiserfs_quota_operations;
1471 /* new format is limited by the 32 bit wide i_blocks field, want to
1472 ** be one full block below that.
1474 s->s_maxbytes = (512LL << 32) - s->s_blocksize;
1478 /* after journal replay, reread all bitmap and super blocks */
1479 static int reread_meta_blocks(struct super_block *s)
1482 ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s)));
1483 wait_on_buffer(SB_BUFFER_WITH_SB(s));
1484 if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
1486 "reread_meta_blocks, error reading the super");
1490 for (i = 0; i < SB_BMAP_NR(s); i++) {
1491 ll_rw_block(READ, 1, &(SB_AP_BITMAP(s)[i].bh));
1492 wait_on_buffer(SB_AP_BITMAP(s)[i].bh);
1493 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
1495 "reread_meta_blocks, error reading bitmap block number %d at %llu",
1497 (unsigned long long)SB_AP_BITMAP(s)[i].
1506 /////////////////////////////////////////////////////
1507 // hash detection stuff
1509 // if root directory is empty - we set default - Yura's - hash and
1511 // FIXME: we look for only one name in a directory. If tea and yura
1512 // bith have the same value - we ask user to send report to the
1514 static __u32 find_hash_out(struct super_block *s)
1517 struct inode *inode;
1519 INITIALIZE_PATH(path);
1520 struct reiserfs_dir_entry de;
1521 __u32 hash = DEFAULT_HASH;
1523 inode = s->s_root->d_inode;
1525 do { // Some serious "goto"-hater was there ;)
1526 u32 teahash, r5hash, yurahash;
1528 make_cpu_key(&key, inode, ~0, TYPE_DIRENTRY, 3);
1529 retval = search_by_entry_key(s, &key, &path, &de);
1530 if (retval == IO_ERROR) {
1534 if (retval == NAME_NOT_FOUND)
1536 set_de_name_and_namelen(&de);
1537 if (deh_offset(&(de.de_deh[de.de_entry_num])) == DOT_DOT_OFFSET) {
1538 /* allow override in this case */
1539 if (reiserfs_rupasov_hash(s)) {
1542 reiserfs_warning(s, "FS seems to be empty, autodetect "
1543 "is using the default hash");
1546 r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen));
1547 teahash = GET_HASH_VALUE(keyed_hash(de.de_name, de.de_namelen));
1548 yurahash = GET_HASH_VALUE(yura_hash(de.de_name, de.de_namelen));
1549 if (((teahash == r5hash)
1551 (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num])))
1552 == r5hash)) || ((teahash == yurahash)
1554 GET_HASH_VALUE(deh_offset
1559 || ((r5hash == yurahash)
1561 GET_HASH_VALUE(deh_offset
1562 (&(de.de_deh[de.de_entry_num])))))) {
1564 "Unable to automatically detect hash function. "
1565 "Please mount with -o hash={tea,rupasov,r5}",
1566 reiserfs_bdevname(s));
1570 if (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num]))) ==
1573 else if (GET_HASH_VALUE
1574 (deh_offset(&(de.de_deh[de.de_entry_num]))) == teahash)
1576 else if (GET_HASH_VALUE
1577 (deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash)
1580 reiserfs_warning(s, "Unrecognised hash function");
1589 // finds out which hash names are sorted with
1590 static int what_hash(struct super_block *s)
1594 code = sb_hash_function_code(SB_DISK_SUPER_BLOCK(s));
1596 /* reiserfs_hash_detect() == true if any of the hash mount options
1597 ** were used. We must check them to make sure the user isn't
1598 ** using a bad hash value
1600 if (code == UNSET_HASH || reiserfs_hash_detect(s))
1601 code = find_hash_out(s);
1603 if (code != UNSET_HASH && reiserfs_hash_detect(s)) {
1604 /* detection has found the hash, and we must check against the
1607 if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
1608 reiserfs_warning(s, "Error, %s hash detected, "
1609 "unable to force rupasov hash",
1610 reiserfs_hashname(code));
1612 } else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
1613 reiserfs_warning(s, "Error, %s hash detected, "
1614 "unable to force tea hash",
1615 reiserfs_hashname(code));
1617 } else if (reiserfs_r5_hash(s) && code != R5_HASH) {
1618 reiserfs_warning(s, "Error, %s hash detected, "
1619 "unable to force r5 hash",
1620 reiserfs_hashname(code));
1624 /* find_hash_out was not called or could not determine the hash */
1625 if (reiserfs_rupasov_hash(s)) {
1627 } else if (reiserfs_tea_hash(s)) {
1629 } else if (reiserfs_r5_hash(s)) {
1634 /* if we are mounted RW, and we have a new valid hash code, update
1637 if (code != UNSET_HASH &&
1638 !(s->s_flags & MS_RDONLY) &&
1639 code != sb_hash_function_code(SB_DISK_SUPER_BLOCK(s))) {
1640 set_sb_hash_function_code(SB_DISK_SUPER_BLOCK(s), code);
1645 // return pointer to appropriate function
1646 static hashf_t hash_function(struct super_block *s)
1648 switch (what_hash(s)) {
1650 reiserfs_info(s, "Using tea hash to sort names\n");
1653 reiserfs_info(s, "Using rupasov hash to sort names\n");
1656 reiserfs_info(s, "Using r5 hash to sort names\n");
1662 // this is used to set up correct value for old partitions
1663 static int function2code(hashf_t func)
1665 if (func == keyed_hash)
1667 if (func == yura_hash)
1669 if (func == r5_hash)
1672 BUG(); // should never happen
1677 #define SWARN(silent, s, ...) \
1679 reiserfs_warning (s, __VA_ARGS__)
1681 static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1683 struct inode *root_inode;
1685 struct reiserfs_transaction_handle th;
1687 unsigned long blocks;
1688 unsigned int commit_max_age = 0;
1690 struct reiserfs_iget_args args;
1691 struct reiserfs_super_block *rs;
1693 struct reiserfs_sb_info *sbi;
1694 int errval = -EINVAL;
1696 sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
1702 memset(sbi, 0, sizeof(struct reiserfs_sb_info));
1703 /* Set default values for options: non-aggressive tails, RO on errors */
1704 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
1705 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
1706 /* no preallocation minimum, be smart in
1707 reiserfs_file_write instead */
1708 REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
1709 /* Preallocate by 16 blocks (17-1) at once */
1710 REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
1711 /* Initialize the rwsem for xattr dir */
1712 init_rwsem(&REISERFS_SB(s)->xattr_dir_sem);
1714 /* setup default block allocator options */
1715 reiserfs_init_alloc_options(s);
1718 if (reiserfs_parse_options
1719 (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name,
1720 &commit_max_age) == 0) {
1725 SWARN(silent, s, "jmacd-7: reiserfs_fill_super: resize option "
1726 "for remount only");
1730 /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
1731 if (!read_super_block(s, REISERFS_OLD_DISK_OFFSET_IN_BYTES))
1733 /* try new format (64-th 1k block), which can contain reiserfs super block */
1734 else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
1736 "sh-2021: reiserfs_fill_super: can not find reiserfs on %s",
1737 reiserfs_bdevname(s));
1741 /* map mount option tagxid */
1742 if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGXID))
1743 s->s_flags |= MS_TAGXID;
1745 rs = SB_DISK_SUPER_BLOCK(s);
1746 /* Let's do basic sanity check to verify that underlying device is not
1747 smaller than the filesystem. If the check fails then abort and scream,
1748 because bad stuff will happen otherwise. */
1749 if (s->s_bdev && s->s_bdev->bd_inode
1750 && i_size_read(s->s_bdev->bd_inode) <
1751 sb_block_count(rs) * sb_blocksize(rs)) {
1753 "Filesystem on %s cannot be mounted because it is bigger than the device",
1754 reiserfs_bdevname(s));
1756 "You may need to run fsck or increase size of your LVM partition");
1758 "Or may be you forgot to reboot after fdisk when it told you to");
1762 sbi->s_mount_state = SB_REISERFS_STATE(s);
1763 sbi->s_mount_state = REISERFS_VALID_FS;
1765 if (old_format ? read_old_bitmaps(s) : read_bitmaps(s)) {
1767 "jmacd-8: reiserfs_fill_super: unable to read bitmap");
1770 #ifdef CONFIG_REISERFS_CHECK
1771 SWARN(silent, s, "CONFIG_REISERFS_CHECK is set ON");
1772 SWARN(silent, s, "- it is slow mode for debugging.");
1775 /* make data=ordered the default */
1776 if (!reiserfs_data_log(s) && !reiserfs_data_ordered(s) &&
1777 !reiserfs_data_writeback(s)) {
1778 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_DATA_ORDERED);
1781 if (reiserfs_data_log(s)) {
1782 reiserfs_info(s, "using journaled data mode\n");
1783 } else if (reiserfs_data_ordered(s)) {
1784 reiserfs_info(s, "using ordered data mode\n");
1786 reiserfs_info(s, "using writeback data mode\n");
1788 if (reiserfs_barrier_flush(s)) {
1789 printk("reiserfs: using flush barriers\n");
1791 // set_device_ro(s->s_dev, 1) ;
1792 if (journal_init(s, jdev_name, old_format, commit_max_age)) {
1794 "sh-2022: reiserfs_fill_super: unable to initialize journal space");
1797 jinit_done = 1; /* once this is set, journal_release must be called
1798 ** if we error out of the mount
1801 if (reread_meta_blocks(s)) {
1803 "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init");
1810 if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
1812 "clm-7000: Detected readonly device, marking FS readonly");
1813 s->s_flags |= MS_RDONLY;
1815 args.objectid = REISERFS_ROOT_OBJECTID;
1816 args.dirid = REISERFS_ROOT_PARENT_OBJECTID;
1818 iget5_locked(s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor,
1819 reiserfs_init_locked_inode, (void *)(&args));
1822 "jmacd-10: reiserfs_fill_super: get root inode failed");
1826 if (root_inode->i_state & I_NEW) {
1827 reiserfs_read_locked_inode(root_inode, &args);
1828 unlock_new_inode(root_inode);
1831 s->s_root = d_alloc_root(root_inode);
1836 // define and initialize hash function
1837 sbi->s_hash_function = hash_function(s);
1838 if (sbi->s_hash_function == NULL) {
1844 if (is_reiserfs_3_5(rs)
1845 || (is_reiserfs_jr(rs) && SB_VERSION(s) == REISERFS_VERSION_1))
1846 set_bit(REISERFS_3_5, &(sbi->s_properties));
1848 set_bit(REISERFS_3_6, &(sbi->s_properties));
1850 if (!(s->s_flags & MS_RDONLY)) {
1852 errval = journal_begin(&th, s, 1);
1858 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
1860 set_sb_umount_state(rs, REISERFS_ERROR_FS);
1861 set_sb_fs_state(rs, 0);
1863 if (old_format_only(s)) {
1864 /* filesystem of format 3.5 either with standard or non-standard
1866 if (convert_reiserfs(s)) {
1867 /* and -o conv is given */
1870 "converting 3.5 filesystem to the 3.6 format");
1872 if (is_reiserfs_3_5(rs))
1873 /* put magic string of 3.6 format. 2.2 will not be able to
1874 mount this filesystem anymore */
1875 memcpy(rs->s_v1.s_magic,
1876 reiserfs_3_6_magic_string,
1878 (reiserfs_3_6_magic_string));
1880 set_sb_version(rs, REISERFS_VERSION_2);
1881 reiserfs_convert_objectid_map_v1(s);
1882 set_bit(REISERFS_3_6, &(sbi->s_properties));
1883 clear_bit(REISERFS_3_5, &(sbi->s_properties));
1884 } else if (!silent) {
1885 reiserfs_info(s, "using 3.5.x disk format\n");
1889 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
1890 errval = journal_end(&th, s, 1);
1897 if ((errval = reiserfs_xattr_init(s, s->s_flags))) {
1903 /* look for files which were to be removed in previous session */
1904 finish_unfinished(s);
1906 if (old_format_only(s) && !silent) {
1907 reiserfs_info(s, "using 3.5.x disk format\n");
1910 if ((errval = reiserfs_xattr_init(s, s->s_flags))) {
1916 // mark hash in super block: it could be unset. overwrite should be ok
1917 set_sb_hash_function_code(rs, function2code(sbi->s_hash_function));
1921 reiserfs_proc_info_init(s);
1923 init_waitqueue_head(&(sbi->s_wait));
1924 spin_lock_init(&sbi->bitmap_lock);
1929 if (jinit_done) { /* kill the commit thread, free journal ram */
1930 journal_release_error(NULL, s);
1932 if (SB_DISK_SUPER_BLOCK(s)) {
1933 for (j = 0; j < SB_BMAP_NR(s); j++) {
1934 if (SB_AP_BITMAP(s))
1935 brelse(SB_AP_BITMAP(s)[j].bh);
1937 vfree(SB_AP_BITMAP(s));
1939 if (SB_BUFFER_WITH_SB(s))
1940 brelse(SB_BUFFER_WITH_SB(s));
1942 for (j = 0; j < MAXQUOTAS; j++) {
1943 kfree(sbi->s_qf_names[j]);
1944 sbi->s_qf_names[j] = NULL;
1949 s->s_fs_info = NULL;
1953 static int reiserfs_statfs(struct super_block *s, struct kstatfs *buf)
1955 struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
1957 buf->f_namelen = (REISERFS_MAX_NAME(s->s_blocksize));
1958 buf->f_bfree = sb_free_blocks(rs);
1959 buf->f_bavail = buf->f_bfree;
1960 buf->f_blocks = sb_block_count(rs) - sb_bmap_nr(rs) - 1;
1961 buf->f_bsize = s->s_blocksize;
1962 /* changed to accommodate gcc folks. */
1963 buf->f_type = REISERFS_SUPER_MAGIC;
1968 static int reiserfs_dquot_initialize(struct inode *inode, int type)
1970 struct reiserfs_transaction_handle th;
1973 /* We may create quota structure so we need to reserve enough blocks */
1974 reiserfs_write_lock(inode->i_sb);
1976 journal_begin(&th, inode->i_sb,
1977 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
1980 ret = dquot_initialize(inode, type);
1982 journal_end(&th, inode->i_sb,
1983 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
1987 reiserfs_write_unlock(inode->i_sb);
1991 static int reiserfs_dquot_drop(struct inode *inode)
1993 struct reiserfs_transaction_handle th;
1996 /* We may delete quota structure so we need to reserve enough blocks */
1997 reiserfs_write_lock(inode->i_sb);
1999 journal_begin(&th, inode->i_sb,
2000 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
2003 ret = dquot_drop(inode);
2005 journal_end(&th, inode->i_sb,
2006 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
2010 reiserfs_write_unlock(inode->i_sb);
2014 static int reiserfs_write_dquot(struct dquot *dquot)
2016 struct reiserfs_transaction_handle th;
2019 reiserfs_write_lock(dquot->dq_sb);
2021 journal_begin(&th, dquot->dq_sb,
2022 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2025 ret = dquot_commit(dquot);
2027 journal_end(&th, dquot->dq_sb,
2028 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2032 reiserfs_write_unlock(dquot->dq_sb);
2036 static int reiserfs_acquire_dquot(struct dquot *dquot)
2038 struct reiserfs_transaction_handle th;
2041 reiserfs_write_lock(dquot->dq_sb);
2043 journal_begin(&th, dquot->dq_sb,
2044 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2047 ret = dquot_acquire(dquot);
2049 journal_end(&th, dquot->dq_sb,
2050 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2054 reiserfs_write_unlock(dquot->dq_sb);
2058 static int reiserfs_release_dquot(struct dquot *dquot)
2060 struct reiserfs_transaction_handle th;
2063 reiserfs_write_lock(dquot->dq_sb);
2065 journal_begin(&th, dquot->dq_sb,
2066 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2069 ret = dquot_release(dquot);
2071 journal_end(&th, dquot->dq_sb,
2072 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2076 reiserfs_write_unlock(dquot->dq_sb);
2080 static int reiserfs_mark_dquot_dirty(struct dquot *dquot)
2082 /* Are we journalling quotas? */
2083 if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
2084 REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
2085 dquot_mark_dquot_dirty(dquot);
2086 return reiserfs_write_dquot(dquot);
2088 return dquot_mark_dquot_dirty(dquot);
2091 static int reiserfs_write_info(struct super_block *sb, int type)
2093 struct reiserfs_transaction_handle th;
2096 /* Data block + inode block */
2097 reiserfs_write_lock(sb);
2098 ret = journal_begin(&th, sb, 2);
2101 ret = dquot_commit_info(sb, type);
2102 err = journal_end(&th, sb, 2);
2106 reiserfs_write_unlock(sb);
2111 * Turn on quotas during mount time - we need to find the quota file and such...
2113 static int reiserfs_quota_on_mount(struct super_block *sb, int type)
2115 return vfs_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type],
2116 REISERFS_SB(sb)->s_jquota_fmt, type);
2120 * Standard function to be called on quota_on
2122 static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2126 struct nameidata nd;
2128 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA)))
2130 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
2133 /* Quotafile not on the same filesystem? */
2134 if (nd.mnt->mnt_sb != sb) {
2138 /* We must not pack tails for quota files on reiserfs for quota IO to work */
2139 if (!REISERFS_I(nd.dentry->d_inode)->i_flags & i_nopack_mask) {
2140 reiserfs_warning(sb,
2141 "reiserfs: Quota file must have tail packing disabled.");
2145 /* Not journalling quota? No more tests needed... */
2146 if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
2147 !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
2149 return vfs_quota_on(sb, type, format_id, path);
2151 /* Quotafile not of fs root? */
2152 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
2153 reiserfs_warning(sb,
2154 "reiserfs: Quota file not on filesystem root. "
2155 "Journalled quota will not work.");
2157 return vfs_quota_on(sb, type, format_id, path);
2160 /* Read data from quotafile - avoid pagecache and such because we cannot afford
2161 * acquiring the locks... As quota files are never truncated and quota code
2162 * itself serializes the operations (and noone else should touch the files)
2163 * we don't have to be afraid of races */
2164 static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data,
2165 size_t len, loff_t off)
2167 struct inode *inode = sb_dqopt(sb)->files[type];
2168 unsigned long blk = off >> sb->s_blocksize_bits;
2169 int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
2171 struct buffer_head tmp_bh, *bh;
2172 loff_t i_size = i_size_read(inode);
2176 if (off + len > i_size)
2179 while (toread > 0) {
2181 sb->s_blocksize - offset <
2182 toread ? sb->s_blocksize - offset : toread;
2184 /* Quota files are without tails so we can safely use this function */
2185 reiserfs_write_lock(sb);
2186 err = reiserfs_get_block(inode, blk, &tmp_bh, 0);
2187 reiserfs_write_unlock(sb);
2190 if (!buffer_mapped(&tmp_bh)) /* A hole? */
2191 memset(data, 0, tocopy);
2193 bh = sb_bread(sb, tmp_bh.b_blocknr);
2196 memcpy(data, bh->b_data + offset, tocopy);
2207 /* Write to quotafile (we know the transaction is already started and has
2208 * enough credits) */
2209 static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2210 const char *data, size_t len, loff_t off)
2212 struct inode *inode = sb_dqopt(sb)->files[type];
2213 unsigned long blk = off >> sb->s_blocksize_bits;
2214 int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
2215 int journal_quota = REISERFS_SB(sb)->s_qf_names[type] != NULL;
2216 size_t towrite = len;
2217 struct buffer_head tmp_bh, *bh;
2219 mutex_lock(&inode->i_mutex);
2220 while (towrite > 0) {
2221 tocopy = sb->s_blocksize - offset < towrite ?
2222 sb->s_blocksize - offset : towrite;
2224 err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE);
2227 if (offset || tocopy != sb->s_blocksize)
2228 bh = sb_bread(sb, tmp_bh.b_blocknr);
2230 bh = sb_getblk(sb, tmp_bh.b_blocknr);
2236 memcpy(bh->b_data + offset, data, tocopy);
2237 flush_dcache_page(bh->b_page);
2238 set_buffer_uptodate(bh);
2240 reiserfs_prepare_for_journal(sb, bh, 1);
2241 journal_mark_dirty(current->journal_info, sb, bh);
2243 reiserfs_add_ordered_list(inode, bh);
2253 if (inode->i_size < off + len - towrite)
2254 i_size_write(inode, off + len - towrite);
2256 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2257 mark_inode_dirty(inode);
2258 mutex_unlock(&inode->i_mutex);
2259 return len - towrite;
2264 static struct super_block *get_super_block(struct file_system_type *fs_type,
2265 int flags, const char *dev_name,
2268 return get_sb_bdev(fs_type, flags, dev_name, data, reiserfs_fill_super);
2271 static int __init init_reiserfs_fs(void)
2275 if ((ret = init_inodecache())) {
2279 if ((ret = reiserfs_xattr_register_handlers()))
2280 goto failed_reiserfs_xattr_register_handlers;
2282 reiserfs_proc_info_global_init();
2283 reiserfs_proc_register_global("version",
2284 reiserfs_global_version_in_proc);
2286 ret = register_filesystem(&reiserfs_fs_type);
2292 reiserfs_xattr_unregister_handlers();
2294 failed_reiserfs_xattr_register_handlers:
2295 reiserfs_proc_unregister_global("version");
2296 reiserfs_proc_info_global_done();
2297 destroy_inodecache();
2302 static void __exit exit_reiserfs_fs(void)
2304 reiserfs_xattr_unregister_handlers();
2305 reiserfs_proc_unregister_global("version");
2306 reiserfs_proc_info_global_done();
2307 unregister_filesystem(&reiserfs_fs_type);
2308 destroy_inodecache();
2311 struct file_system_type reiserfs_fs_type = {
2312 .owner = THIS_MODULE,
2314 .get_sb = get_super_block,
2315 .kill_sb = kill_block_super,
2316 .fs_flags = FS_REQUIRES_DEV,
2319 MODULE_DESCRIPTION("ReiserFS journaled filesystem");
2320 MODULE_AUTHOR("Hans Reiser <reiser@namesys.com>");
2321 MODULE_LICENSE("GPL");
2323 module_init(init_reiserfs_fs);
2324 module_exit(exit_reiserfs_fs);