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/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>
21 #include <linux/smp_lock.h>
22 #include <linux/init.h>
23 #include <linux/blkdev.h>
24 #include <linux/buffer_head.h>
25 #include <linux/vfs.h>
26 #include <linux/namespace.h>
27 #include <linux/mount.h>
28 #include <linux/namei.h>
29 #include <linux/quotaops.h>
31 struct file_system_type reiserfs_fs_type;
33 static const char reiserfs_3_5_magic_string[] = REISERFS_SUPER_MAGIC_STRING;
34 static const char reiserfs_3_6_magic_string[] = REISER2FS_SUPER_MAGIC_STRING;
35 static const char reiserfs_jr_magic_string[] = REISER2FS_JR_SUPER_MAGIC_STRING;
37 int is_reiserfs_3_5(struct reiserfs_super_block *rs)
39 return !strncmp(rs->s_v1.s_magic, reiserfs_3_5_magic_string,
40 strlen(reiserfs_3_5_magic_string));
43 int is_reiserfs_3_6(struct reiserfs_super_block *rs)
45 return !strncmp(rs->s_v1.s_magic, reiserfs_3_6_magic_string,
46 strlen(reiserfs_3_6_magic_string));
49 int is_reiserfs_jr(struct reiserfs_super_block *rs)
51 return !strncmp(rs->s_v1.s_magic, reiserfs_jr_magic_string,
52 strlen(reiserfs_jr_magic_string));
55 static int is_any_reiserfs_magic_string(struct reiserfs_super_block *rs)
57 return (is_reiserfs_3_5(rs) || is_reiserfs_3_6(rs) ||
61 static int reiserfs_remount(struct super_block *s, int *flags, char *data);
62 static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf);
64 static int reiserfs_sync_fs(struct super_block *s, int wait)
66 if (!(s->s_flags & MS_RDONLY)) {
67 struct reiserfs_transaction_handle th;
68 reiserfs_write_lock(s);
69 if (!journal_begin(&th, s, 1))
70 if (!journal_end_sync(&th, s, 1))
71 reiserfs_flush_old_commits(s);
72 s->s_dirt = 0; /* Even if it's not true.
73 * We'll loop forever in sync_supers otherwise */
74 reiserfs_write_unlock(s);
81 static void reiserfs_write_super(struct super_block *s)
83 reiserfs_sync_fs(s, 1);
86 static void reiserfs_write_super_lockfs(struct super_block *s)
88 struct reiserfs_transaction_handle th;
89 reiserfs_write_lock(s);
90 if (!(s->s_flags & MS_RDONLY)) {
91 int err = journal_begin(&th, s, 1);
93 reiserfs_block_writes(&th);
95 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
97 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
98 reiserfs_block_writes(&th);
99 journal_end_sync(&th, s, 1);
103 reiserfs_write_unlock(s);
106 static void reiserfs_unlockfs(struct super_block *s)
108 reiserfs_allow_writes(s);
111 extern const struct in_core_key MAX_IN_CORE_KEY;
113 /* this is used to delete "save link" when there are no items of a
114 file it points to. It can either happen if unlink is completed but
115 "save unlink" removal, or if file has both unlink and truncate
116 pending and as unlink completes first (because key of "save link"
117 protecting unlink is bigger that a key lf "save link" which
118 protects truncate), so there left no items to make truncate
120 static int remove_save_link_only(struct super_block *s,
121 struct reiserfs_key *key, int oid_free)
123 struct reiserfs_transaction_handle th;
126 /* we are going to do one balancing */
127 err = journal_begin(&th, s, JOURNAL_PER_BALANCE_CNT);
131 reiserfs_delete_solid_item(&th, NULL, key);
133 /* removals are protected by direct items */
134 reiserfs_release_objectid(&th, le32_to_cpu(key->k_objectid));
136 return journal_end(&th, s, JOURNAL_PER_BALANCE_CNT);
140 static int reiserfs_quota_on_mount(struct super_block *, int);
143 /* look for uncompleted unlinks and truncates and complete them */
144 static int finish_unfinished(struct super_block *s)
146 INITIALIZE_PATH(path);
147 struct cpu_key max_cpu_key, obj_key;
148 struct reiserfs_key save_link_key;
150 struct item_head *ih;
151 struct buffer_head *bh;
162 /* compose key to look for "save" links */
163 max_cpu_key.version = KEY_FORMAT_3_5;
164 max_cpu_key.on_disk_key.k_dir_id = ~0U;
165 max_cpu_key.on_disk_key.k_objectid = ~0U;
166 set_cpu_key_k_offset(&max_cpu_key, ~0U);
167 max_cpu_key.key_length = 3;
170 /* Needed for iput() to work correctly and not trash data */
171 if (s->s_flags & MS_ACTIVE) {
175 s->s_flags |= MS_ACTIVE;
177 /* Turn on quotas so that they are updated correctly */
178 for (i = 0; i < MAXQUOTAS; i++) {
179 if (REISERFS_SB(s)->s_qf_names[i]) {
180 int ret = reiserfs_quota_on_mount(s, i);
183 "reiserfs: cannot turn on journalled quota: error %d",
190 REISERFS_SB(s)->s_is_unlinked_ok = 1;
192 retval = search_item(s, &max_cpu_key, &path);
193 if (retval != ITEM_NOT_FOUND) {
195 "vs-2140: finish_unfinished: search_by_key returned %d",
200 bh = get_last_bh(&path);
201 item_pos = get_item_pos(&path);
202 if (item_pos != B_NR_ITEMS(bh)) {
204 "vs-2060: finish_unfinished: wrong position found");
208 ih = B_N_PITEM_HEAD(bh, item_pos);
210 if (le32_to_cpu(ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID)
211 /* there are no "save" links anymore */
214 save_link_key = ih->ih_key;
215 if (is_indirect_le_ih(ih))
220 /* reiserfs_iget needs k_dirid and k_objectid only */
221 item = B_I_PITEM(bh, ih);
222 obj_key.on_disk_key.k_dir_id = le32_to_cpu(*(__le32 *) item);
223 obj_key.on_disk_key.k_objectid =
224 le32_to_cpu(ih->ih_key.k_objectid);
225 obj_key.on_disk_key.k_offset = 0;
226 obj_key.on_disk_key.k_type = 0;
230 inode = reiserfs_iget(s, &obj_key);
232 /* the unlink almost completed, it just did not manage to remove
233 "save" link and release objectid */
235 "vs-2180: finish_unfinished: iget failed for %K",
237 retval = remove_save_link_only(s, &save_link_key, 1);
241 if (!truncate && inode->i_nlink) {
242 /* file is not unlinked */
244 "vs-2185: finish_unfinished: file %K is not unlinked",
246 retval = remove_save_link_only(s, &save_link_key, 0);
251 if (truncate && S_ISDIR(inode->i_mode)) {
252 /* We got a truncate request for a dir which is impossible.
253 The only imaginable way is to execute unfinished truncate request
254 then boot into old kernel, remove the file and create dir with
257 "green-2101: impossible truncate on a directory %k. Please report",
259 retval = remove_save_link_only(s, &save_link_key, 0);
266 REISERFS_I(inode)->i_flags |=
267 i_link_saved_truncate_mask;
268 /* not completed truncate found. New size was committed together
270 reiserfs_info(s, "Truncating %k to %Ld ..",
271 INODE_PKEY(inode), inode->i_size);
272 reiserfs_truncate_file(inode,
274 /*don't update modification time */
276 retval = remove_save_link(inode, truncate);
278 REISERFS_I(inode)->i_flags |= i_link_saved_unlink_mask;
279 /* not completed unlink (rmdir) found */
280 reiserfs_info(s, "Removing %k..", INODE_PKEY(inode));
281 /* removal gets completed in iput */
289 REISERFS_SB(s)->s_is_unlinked_ok = 0;
292 /* Turn quotas off */
293 for (i = 0; i < MAXQUOTAS; i++) {
294 if (sb_dqopt(s)->files[i])
295 vfs_quota_off_mount(s, i);
298 /* Restore the flag back */
299 s->s_flags &= ~MS_ACTIVE;
303 reiserfs_info(s, "There were %d uncompleted unlinks/truncates. "
304 "Completed\n", done);
308 /* to protect file being unlinked from getting lost we "safe" link files
309 being unlinked. This link will be deleted in the same transaction with last
310 item of file. mounting the filesytem we scan all these links and remove
311 files which almost got lost */
312 void add_save_link(struct reiserfs_transaction_handle *th,
313 struct inode *inode, int truncate)
315 INITIALIZE_PATH(path);
321 BUG_ON(!th->t_trans_id);
323 /* file can only get one "save link" of each kind */
325 (REISERFS_I(inode)->i_flags & i_link_saved_truncate_mask),
326 "saved link already exists for truncated inode %lx",
329 (REISERFS_I(inode)->i_flags & i_link_saved_unlink_mask),
330 "saved link already exists for unlinked inode %lx",
333 /* setup key of "save" link */
334 key.version = KEY_FORMAT_3_5;
335 key.on_disk_key.k_dir_id = MAX_KEY_OBJECTID;
336 key.on_disk_key.k_objectid = inode->i_ino;
338 /* unlink, rmdir, rename */
339 set_cpu_key_k_offset(&key, 1 + inode->i_sb->s_blocksize);
340 set_cpu_key_k_type(&key, TYPE_DIRECT);
342 /* item head of "safe" link */
343 make_le_item_head(&ih, &key, key.version,
344 1 + inode->i_sb->s_blocksize, TYPE_DIRECT,
345 4 /*length */ , 0xffff /*free space */ );
348 if (S_ISDIR(inode->i_mode))
349 reiserfs_warning(inode->i_sb,
350 "green-2102: Adding a truncate savelink for a directory %k! Please report",
352 set_cpu_key_k_offset(&key, 1);
353 set_cpu_key_k_type(&key, TYPE_INDIRECT);
355 /* item head of "safe" link */
356 make_le_item_head(&ih, &key, key.version, 1, TYPE_INDIRECT,
357 4 /*length */ , 0 /*free space */ );
361 /* look for its place in the tree */
362 retval = search_item(inode->i_sb, &key, &path);
363 if (retval != ITEM_NOT_FOUND) {
364 if (retval != -ENOSPC)
365 reiserfs_warning(inode->i_sb, "vs-2100: add_save_link:"
366 "search_by_key (%K) returned %d", &key,
372 /* body of "save" link */
373 link = INODE_PKEY(inode)->k_dir_id;
375 /* put "save" link inot tree, don't charge quota to anyone */
377 reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link);
379 if (retval != -ENOSPC)
380 reiserfs_warning(inode->i_sb,
381 "vs-2120: add_save_link: insert_item returned %d",
385 REISERFS_I(inode)->i_flags |=
386 i_link_saved_truncate_mask;
388 REISERFS_I(inode)->i_flags |= i_link_saved_unlink_mask;
392 /* this opens transaction unlike add_save_link */
393 int remove_save_link(struct inode *inode, int truncate)
395 struct reiserfs_transaction_handle th;
396 struct reiserfs_key key;
399 /* we are going to do one balancing only */
400 err = journal_begin(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
404 /* setup key of "save" link */
405 key.k_dir_id = cpu_to_le32(MAX_KEY_OBJECTID);
406 key.k_objectid = INODE_PKEY(inode)->k_objectid;
408 /* unlink, rmdir, rename */
409 set_le_key_k_offset(KEY_FORMAT_3_5, &key,
410 1 + inode->i_sb->s_blocksize);
411 set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_DIRECT);
414 set_le_key_k_offset(KEY_FORMAT_3_5, &key, 1);
415 set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_INDIRECT);
419 (REISERFS_I(inode)->i_flags & i_link_saved_truncate_mask)) ||
421 (REISERFS_I(inode)->i_flags & i_link_saved_unlink_mask)))
422 /* don't take quota bytes from anywhere */
423 reiserfs_delete_solid_item(&th, NULL, &key);
425 reiserfs_release_objectid(&th, inode->i_ino);
426 REISERFS_I(inode)->i_flags &= ~i_link_saved_unlink_mask;
428 REISERFS_I(inode)->i_flags &= ~i_link_saved_truncate_mask;
430 return journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
433 static void reiserfs_kill_sb(struct super_block *s)
435 if (REISERFS_SB(s)) {
436 if (REISERFS_SB(s)->xattr_root) {
437 d_invalidate(REISERFS_SB(s)->xattr_root);
438 dput(REISERFS_SB(s)->xattr_root);
439 REISERFS_SB(s)->xattr_root = NULL;
441 if (REISERFS_SB(s)->priv_root) {
442 d_invalidate(REISERFS_SB(s)->priv_root);
443 dput(REISERFS_SB(s)->priv_root);
444 REISERFS_SB(s)->priv_root = NULL;
450 static void reiserfs_put_super(struct super_block *s)
453 struct reiserfs_transaction_handle th;
456 /* change file system state to current state if it was mounted with read-write permissions */
457 if (!(s->s_flags & MS_RDONLY)) {
458 if (!journal_begin(&th, s, 10)) {
459 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
461 set_sb_umount_state(SB_DISK_SUPER_BLOCK(s),
462 REISERFS_SB(s)->s_mount_state);
463 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
467 /* note, journal_release checks for readonly mount, and can decide not
468 ** to do a journal_end
470 journal_release(&th, s);
472 for (i = 0; i < SB_BMAP_NR(s); i++)
473 brelse(SB_AP_BITMAP(s)[i].bh);
475 vfree(SB_AP_BITMAP(s));
477 brelse(SB_BUFFER_WITH_SB(s));
481 if (REISERFS_SB(s)->reserved_blocks != 0) {
483 "green-2005: reiserfs_put_super: reserved blocks left %d",
484 REISERFS_SB(s)->reserved_blocks);
487 reiserfs_proc_info_done(s);
495 static kmem_cache_t *reiserfs_inode_cachep;
497 static struct inode *reiserfs_alloc_inode(struct super_block *sb)
499 struct reiserfs_inode_info *ei;
500 ei = (struct reiserfs_inode_info *)
501 kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL);
504 return &ei->vfs_inode;
507 static void reiserfs_destroy_inode(struct inode *inode)
509 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
512 static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
514 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
516 if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
517 SLAB_CTOR_CONSTRUCTOR) {
518 INIT_LIST_HEAD(&ei->i_prealloc_list);
519 inode_init_once(&ei->vfs_inode);
520 ei->i_acl_access = NULL;
521 ei->i_acl_default = NULL;
525 static int init_inodecache(void)
527 reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache",
529 reiserfs_inode_info),
530 0, (SLAB_RECLAIM_ACCOUNT|
533 if (reiserfs_inode_cachep == NULL)
538 static void destroy_inodecache(void)
540 if (kmem_cache_destroy(reiserfs_inode_cachep))
541 reiserfs_warning(NULL,
542 "reiserfs_inode_cache: not all structures were freed");
545 /* we don't mark inodes dirty, we just log them */
546 static void reiserfs_dirty_inode(struct inode *inode)
548 struct reiserfs_transaction_handle th;
551 if (inode->i_sb->s_flags & MS_RDONLY) {
552 reiserfs_warning(inode->i_sb,
553 "clm-6006: writing inode %lu on readonly FS",
557 reiserfs_write_lock(inode->i_sb);
559 /* this is really only used for atime updates, so they don't have
560 ** to be included in O_SYNC or fsync
562 err = journal_begin(&th, inode->i_sb, 1);
564 reiserfs_write_unlock(inode->i_sb);
567 reiserfs_update_sd(&th, inode);
568 journal_end(&th, inode->i_sb, 1);
569 reiserfs_write_unlock(inode->i_sb);
572 static void reiserfs_clear_inode(struct inode *inode)
574 struct posix_acl *acl;
576 acl = REISERFS_I(inode)->i_acl_access;
577 if (acl && !IS_ERR(acl))
578 posix_acl_release(acl);
579 REISERFS_I(inode)->i_acl_access = NULL;
581 acl = REISERFS_I(inode)->i_acl_default;
582 if (acl && !IS_ERR(acl))
583 posix_acl_release(acl);
584 REISERFS_I(inode)->i_acl_default = NULL;
588 static ssize_t reiserfs_quota_write(struct super_block *, int, const char *,
590 static ssize_t reiserfs_quota_read(struct super_block *, int, char *, size_t,
594 static struct super_operations reiserfs_sops = {
595 .alloc_inode = reiserfs_alloc_inode,
596 .destroy_inode = reiserfs_destroy_inode,
597 .write_inode = reiserfs_write_inode,
598 .dirty_inode = reiserfs_dirty_inode,
599 .delete_inode = reiserfs_delete_inode,
600 .clear_inode = reiserfs_clear_inode,
601 .put_super = reiserfs_put_super,
602 .write_super = reiserfs_write_super,
603 .sync_fs = reiserfs_sync_fs,
604 .write_super_lockfs = reiserfs_write_super_lockfs,
605 .unlockfs = reiserfs_unlockfs,
606 .statfs = reiserfs_statfs,
607 .remount_fs = reiserfs_remount,
609 .quota_read = reiserfs_quota_read,
610 .quota_write = reiserfs_quota_write,
615 #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")
617 static int reiserfs_dquot_initialize(struct inode *, int);
618 static int reiserfs_dquot_drop(struct inode *);
619 static int reiserfs_write_dquot(struct dquot *);
620 static int reiserfs_acquire_dquot(struct dquot *);
621 static int reiserfs_release_dquot(struct dquot *);
622 static int reiserfs_mark_dquot_dirty(struct dquot *);
623 static int reiserfs_write_info(struct super_block *, int);
624 static int reiserfs_quota_on(struct super_block *, int, int, char *);
626 static struct dquot_operations reiserfs_quota_operations = {
627 .initialize = reiserfs_dquot_initialize,
628 .drop = reiserfs_dquot_drop,
629 .alloc_space = dquot_alloc_space,
630 .alloc_inode = dquot_alloc_inode,
631 .free_space = dquot_free_space,
632 .free_inode = dquot_free_inode,
633 .transfer = dquot_transfer,
634 .write_dquot = reiserfs_write_dquot,
635 .acquire_dquot = reiserfs_acquire_dquot,
636 .release_dquot = reiserfs_release_dquot,
637 .mark_dirty = reiserfs_mark_dquot_dirty,
638 .write_info = reiserfs_write_info,
641 static struct quotactl_ops reiserfs_qctl_operations = {
642 .quota_on = reiserfs_quota_on,
643 .quota_off = vfs_quota_off,
644 .quota_sync = vfs_quota_sync,
645 .get_info = vfs_get_dqinfo,
646 .set_info = vfs_set_dqinfo,
647 .get_dqblk = vfs_get_dqblk,
648 .set_dqblk = vfs_set_dqblk,
652 static struct export_operations reiserfs_export_ops = {
653 .encode_fh = reiserfs_encode_fh,
654 .decode_fh = reiserfs_decode_fh,
655 .get_parent = reiserfs_get_parent,
656 .get_dentry = reiserfs_get_dentry,
659 /* this struct is used in reiserfs_getopt () for containing the value for those
660 mount options that have values rather than being toggles. */
663 int setmask; /* bitmask which is to set on mount_options bitmask when this
664 value is found, 0 is no bits are to be changed. */
665 int clrmask; /* bitmask which is to clear on mount_options bitmask when this
666 value is found, 0 is no bits are to be changed. This is
667 applied BEFORE setmask */
670 /* Set this bit in arg_required to allow empty arguments */
671 #define REISERFS_OPT_ALLOWEMPTY 31
673 /* this struct is used in reiserfs_getopt() for describing the set of reiserfs
677 int arg_required; /* 0 if argument is not required, not 0 otherwise */
678 const arg_desc_t *values; /* list of values accepted by an option */
679 int setmask; /* bitmask which is to set on mount_options bitmask when this
680 value is found, 0 is no bits are to be changed. */
681 int clrmask; /* bitmask which is to clear on mount_options bitmask when this
682 value is found, 0 is no bits are to be changed. This is
683 applied BEFORE setmask */
686 /* possible values for -o data= */
687 static const arg_desc_t logging_mode[] = {
688 {"ordered", 1 << REISERFS_DATA_ORDERED,
689 (1 << REISERFS_DATA_LOG | 1 << REISERFS_DATA_WRITEBACK)},
690 {"journal", 1 << REISERFS_DATA_LOG,
691 (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)},
692 {"writeback", 1 << REISERFS_DATA_WRITEBACK,
693 (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)},
697 /* possible values for -o barrier= */
698 static const arg_desc_t barrier_mode[] = {
699 {"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH},
700 {"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE},
704 /* possible values for "-o block-allocator=" and bits which are to be set in
705 s_mount_opt of reiserfs specific part of in-core super block */
706 static const arg_desc_t balloc[] = {
707 {"noborder", 1 << REISERFS_NO_BORDER, 0},
708 {"border", 0, 1 << REISERFS_NO_BORDER},
709 {"no_unhashed_relocation", 1 << REISERFS_NO_UNHASHED_RELOCATION, 0},
710 {"hashed_relocation", 1 << REISERFS_HASHED_RELOCATION, 0},
711 {"test4", 1 << REISERFS_TEST4, 0},
712 {"notest4", 0, 1 << REISERFS_TEST4},
716 static const arg_desc_t tails[] = {
717 {"on", 1 << REISERFS_LARGETAIL, 1 << REISERFS_SMALLTAIL},
718 {"off", 0, (1 << REISERFS_LARGETAIL) | (1 << REISERFS_SMALLTAIL)},
719 {"small", 1 << REISERFS_SMALLTAIL, 1 << REISERFS_LARGETAIL},
723 static const arg_desc_t error_actions[] = {
724 {"panic", 1 << REISERFS_ERROR_PANIC,
725 (1 << REISERFS_ERROR_RO | 1 << REISERFS_ERROR_CONTINUE)},
726 {"ro-remount", 1 << REISERFS_ERROR_RO,
727 (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_CONTINUE)},
728 #ifdef REISERFS_JOURNAL_ERROR_ALLOWS_NO_LOG
729 {"continue", 1 << REISERFS_ERROR_CONTINUE,
730 (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_RO)},
735 int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 128k.
736 There might be broken applications that are
737 confused by this. Use nolargeio mount option
738 to get usual i/o size = PAGE_SIZE.
741 /* proceed only one option from a list *cur - string containing of mount options
742 opts - array of options which are accepted
743 opt_arg - if option is found and requires an argument and if it is specifed
744 in the input - pointer to the argument is stored here
745 bit_flags - if option requires to set a certain bit - it is set here
746 return -1 if unknown option is found, opt->arg_required otherwise */
747 static int reiserfs_getopt(struct super_block *s, char **cur, opt_desc_t * opts,
748 char **opt_arg, unsigned long *bit_flags)
757 const opt_desc_t *opt;
758 const arg_desc_t *arg;
762 /* assume argument cannot contain commas */
763 *cur = strchr(p, ',');
769 if (!strncmp(p, "alloc=", 6)) {
770 /* Ugly special case, probably we should redo options parser so that
771 it can understand several arguments for some options, also so that
772 it can fill several bitfields with option values. */
773 if (reiserfs_parse_alloc_options(s, p + 6)) {
780 /* for every option in the list */
781 for (opt = opts; opt->option_name; opt++) {
782 if (!strncmp(p, opt->option_name, strlen(opt->option_name))) {
785 (1 << REISERFS_UNSUPPORTED_OPT))
786 reiserfs_warning(s, "%s not supported.",
789 *bit_flags &= ~opt->clrmask;
791 (1 << REISERFS_UNSUPPORTED_OPT))
792 reiserfs_warning(s, "%s not supported.",
795 *bit_flags |= opt->setmask;
800 if (!opt->option_name) {
801 reiserfs_warning(s, "unknown mount option \"%s\"", p);
805 p += strlen(opt->option_name);
808 if (!opt->arg_required) {
810 "the option \"%s\" does not require an argument",
817 if (opt->arg_required) {
819 "the option \"%s\" requires an argument",
825 reiserfs_warning(s, "head of option \"%s\" is only correct",
830 /* move to the argument, or to next option if argument is not required */
833 if (opt->arg_required
834 && !(opt->arg_required & (1 << REISERFS_OPT_ALLOWEMPTY))
836 /* this catches "option=," if not allowed */
837 reiserfs_warning(s, "empty argument for \"%s\"",
843 /* *=NULLopt_arg contains pointer to argument */
845 return opt->arg_required & ~(1 << REISERFS_OPT_ALLOWEMPTY);
848 /* values possible for this option are listed in opt->values */
849 for (arg = opt->values; arg->value; arg++) {
850 if (!strcmp(p, arg->value)) {
852 *bit_flags &= ~arg->clrmask;
853 *bit_flags |= arg->setmask;
855 return opt->arg_required;
859 reiserfs_warning(s, "bad value \"%s\" for option \"%s\"", p,
864 /* returns 0 if something is wrong in option string, 1 - otherwise */
865 static int reiserfs_parse_options(struct super_block *s, char *options, /* string given via mount's -o */
866 unsigned long *mount_options,
867 /* after the parsing phase, contains the
868 collection of bitflags defining what
869 mount options were selected. */
870 unsigned long *blocks, /* strtol-ed from NNN of resize=NNN */
872 unsigned int *commit_max_age)
877 opt_desc_t opts[] = {
878 /* Compatibility stuff, so that -o notail for old setups still work */
879 {"tails",.arg_required = 't',.values = tails},
881 (1 << REISERFS_LARGETAIL) | (1 << REISERFS_SMALLTAIL)},
882 {"conv",.setmask = 1 << REISERFS_CONVERT},
883 {"attrs",.setmask = 1 << REISERFS_ATTRS},
884 {"noattrs",.clrmask = 1 << REISERFS_ATTRS},
885 #ifdef CONFIG_REISERFS_FS_XATTR
886 {"user_xattr",.setmask = 1 << REISERFS_XATTRS_USER},
887 {"nouser_xattr",.clrmask = 1 << REISERFS_XATTRS_USER},
889 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
890 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
892 #ifndef CONFIG_INOXID_NONE
893 {"tagxid",.setmask = 1 << REISERFS_TAGXID},
895 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
896 {"acl",.setmask = 1 << REISERFS_POSIXACL},
897 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
899 {"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
900 {"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
902 {.option_name = "nolog"},
903 {"replayonly",.setmask = 1 << REPLAYONLY},
904 {"block-allocator",.arg_required = 'a',.values = balloc},
905 {"data",.arg_required = 'd',.values = logging_mode},
906 {"barrier",.arg_required = 'b',.values = barrier_mode},
907 {"resize",.arg_required = 'r',.values = NULL},
908 {"jdev",.arg_required = 'j',.values = NULL},
909 {"nolargeio",.arg_required = 'w',.values = NULL},
910 {"commit",.arg_required = 'c',.values = NULL},
911 {"usrquota",.setmask = 1 << REISERFS_QUOTA},
912 {"grpquota",.setmask = 1 << REISERFS_QUOTA},
913 {"noquota",.clrmask = 1 << REISERFS_QUOTA},
914 {"errors",.arg_required = 'e',.values = error_actions},
915 {"usrjquota",.arg_required =
916 'u' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
917 {"grpjquota",.arg_required =
918 'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
919 {"jqfmt",.arg_required = 'f',.values = NULL},
920 {.option_name = NULL}
924 if (!options || !*options)
925 /* use default configuration: create tails, journaling on, no
926 conversion to newest format */
929 for (pos = options; pos;) {
930 c = reiserfs_getopt(s, &pos, opts, &arg, mount_options);
932 /* wrong option is given */
939 /* "resize=NNN" or "resize=auto" */
941 if (!strcmp(arg, "auto")) {
942 /* From JFS code, to auto-get the size. */
944 s->s_bdev->bd_inode->i_size >> s->
947 *blocks = simple_strtoul(arg, &p, 0);
949 /* NNN does not look like a number */
951 "reiserfs_parse_options: bad value %s",
960 unsigned long val = simple_strtoul(arg, &p, 0);
961 /* commit=NNN (time in seconds) */
962 if (*p != '\0' || val >= (unsigned int)-1) {
964 "reiserfs_parse_options: bad value %s",
968 *commit_max_age = (unsigned int)val;
973 int val = simple_strtoul(arg, &p, 0);
977 "reiserfs_parse_options: non-numeric value %s for nolargeio option",
982 reiserfs_default_io_size = PAGE_SIZE;
984 reiserfs_default_io_size = 128 * 1024;
988 if (arg && *arg && jdev_name) {
989 if (*jdev_name) { //Hm, already assigned?
991 "reiserfs_parse_options: journal device was already specified to be %s",
999 if (c == 'u' || c == 'g') {
1000 int qtype = c == 'u' ? USRQUOTA : GRPQUOTA;
1002 if (sb_any_quota_enabled(s)) {
1004 "reiserfs_parse_options: cannot change journalled quota options when quota turned on.");
1007 if (*arg) { /* Some filename specified? */
1008 if (REISERFS_SB(s)->s_qf_names[qtype]
1009 && strcmp(REISERFS_SB(s)->s_qf_names[qtype],
1012 "reiserfs_parse_options: %s quota file already specified.",
1016 if (strchr(arg, '/')) {
1018 "reiserfs_parse_options: quotafile must be on filesystem root.");
1021 REISERFS_SB(s)->s_qf_names[qtype] =
1022 kmalloc(strlen(arg) + 1, GFP_KERNEL);
1023 if (!REISERFS_SB(s)->s_qf_names[qtype]) {
1025 "reiserfs_parse_options: not enough memory for storing quotafile name.");
1028 strcpy(REISERFS_SB(s)->s_qf_names[qtype], arg);
1029 *mount_options |= 1 << REISERFS_QUOTA;
1031 kfree(REISERFS_SB(s)->s_qf_names[qtype]);
1032 REISERFS_SB(s)->s_qf_names[qtype] = NULL;
1036 if (!strcmp(arg, "vfsold"))
1037 REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_OLD;
1038 else if (!strcmp(arg, "vfsv0"))
1039 REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_V0;
1042 "reiserfs_parse_options: unknown quota format specified.");
1047 if (c == 'u' || c == 'g' || c == 'f') {
1049 "reiserfs_parse_options: journalled quota options not supported.");
1056 if (!REISERFS_SB(s)->s_jquota_fmt
1057 && (REISERFS_SB(s)->s_qf_names[USRQUOTA]
1058 || REISERFS_SB(s)->s_qf_names[GRPQUOTA])) {
1060 "reiserfs_parse_options: journalled quota format not specified.");
1063 /* This checking is not precise wrt the quota type but for our purposes it is sufficient */
1064 if (!(*mount_options & (1 << REISERFS_QUOTA))
1065 && sb_any_quota_enabled(s)) {
1067 "reiserfs_parse_options: quota options must be present when quota is turned on.");
1075 static void switch_data_mode(struct super_block *s, unsigned long mode)
1077 REISERFS_SB(s)->s_mount_opt &= ~((1 << REISERFS_DATA_LOG) |
1078 (1 << REISERFS_DATA_ORDERED) |
1079 (1 << REISERFS_DATA_WRITEBACK));
1080 REISERFS_SB(s)->s_mount_opt |= (1 << mode);
1083 static void handle_data_mode(struct super_block *s, unsigned long mount_options)
1085 if (mount_options & (1 << REISERFS_DATA_LOG)) {
1086 if (!reiserfs_data_log(s)) {
1087 switch_data_mode(s, REISERFS_DATA_LOG);
1088 reiserfs_info(s, "switching to journaled data mode\n");
1090 } else if (mount_options & (1 << REISERFS_DATA_ORDERED)) {
1091 if (!reiserfs_data_ordered(s)) {
1092 switch_data_mode(s, REISERFS_DATA_ORDERED);
1093 reiserfs_info(s, "switching to ordered data mode\n");
1095 } else if (mount_options & (1 << REISERFS_DATA_WRITEBACK)) {
1096 if (!reiserfs_data_writeback(s)) {
1097 switch_data_mode(s, REISERFS_DATA_WRITEBACK);
1098 reiserfs_info(s, "switching to writeback data mode\n");
1103 static void handle_barrier_mode(struct super_block *s, unsigned long bits)
1105 int flush = (1 << REISERFS_BARRIER_FLUSH);
1106 int none = (1 << REISERFS_BARRIER_NONE);
1107 int all_barrier = flush | none;
1109 if (bits & all_barrier) {
1110 REISERFS_SB(s)->s_mount_opt &= ~all_barrier;
1112 REISERFS_SB(s)->s_mount_opt |= flush;
1113 printk("reiserfs: enabling write barrier flush mode\n");
1114 } else if (bits & none) {
1115 REISERFS_SB(s)->s_mount_opt |= none;
1116 printk("reiserfs: write barriers turned off\n");
1121 static void handle_attrs(struct super_block *s)
1123 struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
1125 if (reiserfs_attrs(s)) {
1126 if (old_format_only(s)) {
1128 "reiserfs: cannot support attributes on 3.5.x disk format");
1129 REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
1132 if (!(le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared)) {
1134 "reiserfs: cannot support attributes until flag is set in super-block");
1135 REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
1140 static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1142 struct reiserfs_super_block *rs;
1143 struct reiserfs_transaction_handle th;
1144 unsigned long blocks;
1145 unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
1146 unsigned long safe_mask = 0;
1147 unsigned int commit_max_age = (unsigned int)-1;
1148 struct reiserfs_journal *journal = SB_JOURNAL(s);
1154 rs = SB_DISK_SUPER_BLOCK(s);
1156 if (!reiserfs_parse_options
1157 (s, arg, &mount_options, &blocks, NULL, &commit_max_age)) {
1159 for (i = 0; i < MAXQUOTAS; i++) {
1160 kfree(REISERFS_SB(s)->s_qf_names[i]);
1161 REISERFS_SB(s)->s_qf_names[i] = NULL;
1167 if ((mount_options & (1 << REISERFS_TAGXID)) &&
1168 !(s->s_flags & MS_TAGXID)) {
1169 reiserfs_warning(s, "reiserfs: tagxid not permitted on remount.");
1175 /* Add options that are safe here */
1176 safe_mask |= 1 << REISERFS_SMALLTAIL;
1177 safe_mask |= 1 << REISERFS_LARGETAIL;
1178 safe_mask |= 1 << REISERFS_NO_BORDER;
1179 safe_mask |= 1 << REISERFS_NO_UNHASHED_RELOCATION;
1180 safe_mask |= 1 << REISERFS_HASHED_RELOCATION;
1181 safe_mask |= 1 << REISERFS_TEST4;
1182 safe_mask |= 1 << REISERFS_ATTRS;
1183 safe_mask |= 1 << REISERFS_XATTRS_USER;
1184 safe_mask |= 1 << REISERFS_POSIXACL;
1185 safe_mask |= 1 << REISERFS_BARRIER_FLUSH;
1186 safe_mask |= 1 << REISERFS_BARRIER_NONE;
1187 safe_mask |= 1 << REISERFS_ERROR_RO;
1188 safe_mask |= 1 << REISERFS_ERROR_CONTINUE;
1189 safe_mask |= 1 << REISERFS_ERROR_PANIC;
1190 safe_mask |= 1 << REISERFS_QUOTA;
1192 /* Update the bitmask, taking care to keep
1193 * the bits we're not allowed to change here */
1194 REISERFS_SB(s)->s_mount_opt =
1196 s_mount_opt & ~safe_mask) | (mount_options & safe_mask);
1198 if (commit_max_age != 0 && commit_max_age != (unsigned int)-1) {
1199 journal->j_max_commit_age = commit_max_age;
1200 journal->j_max_trans_age = commit_max_age;
1201 } else if (commit_max_age == 0) {
1202 /* 0 means restore defaults. */
1203 journal->j_max_commit_age = journal->j_default_max_commit_age;
1204 journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
1208 int rc = reiserfs_resize(s, blocks);
1213 if (*mount_flags & MS_RDONLY) {
1214 reiserfs_xattr_init(s, *mount_flags);
1215 /* remount read-only */
1216 if (s->s_flags & MS_RDONLY)
1217 /* it is read-only already */
1219 /* try to remount file system with read-only permissions */
1220 if (sb_umount_state(rs) == REISERFS_VALID_FS
1221 || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) {
1225 err = journal_begin(&th, s, 10);
1229 /* Mounting a rw partition read-only. */
1230 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
1231 set_sb_umount_state(rs, REISERFS_SB(s)->s_mount_state);
1232 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
1234 /* remount read-write */
1235 if (!(s->s_flags & MS_RDONLY)) {
1236 reiserfs_xattr_init(s, *mount_flags);
1237 return 0; /* We are read-write already */
1240 if (reiserfs_is_journal_aborted(journal))
1241 return journal->j_errno;
1243 handle_data_mode(s, mount_options);
1244 handle_barrier_mode(s, mount_options);
1245 REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
1246 s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */
1247 err = journal_begin(&th, s, 10);
1251 /* Mount a partition which is read-only, read-write */
1252 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
1253 REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
1254 s->s_flags &= ~MS_RDONLY;
1255 set_sb_umount_state(rs, REISERFS_ERROR_FS);
1256 /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */
1257 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
1258 REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS;
1260 /* this will force a full flush of all journal lists */
1261 SB_JOURNAL(s)->j_must_wait = 1;
1262 err = journal_end(&th, s, 10);
1267 if (!(*mount_flags & MS_RDONLY)) {
1268 finish_unfinished(s);
1269 reiserfs_xattr_init(s, *mount_flags);
1275 /* load_bitmap_info_data - Sets up the reiserfs_bitmap_info structure from disk.
1276 * @sb - superblock for this filesystem
1277 * @bi - the bitmap info to be loaded. Requires that bi->bh is valid.
1279 * This routine counts how many free bits there are, finding the first zero
1280 * as a side effect. Could also be implemented as a loop of test_bit() calls, or
1281 * a loop of find_first_zero_bit() calls. This implementation is similar to
1282 * find_first_zero_bit(), but doesn't return after it finds the first bit.
1283 * Should only be called on fs mount, but should be fairly efficient anyways.
1285 * bi->first_zero_hint is considered unset if it == 0, since the bitmap itself
1286 * will * invariably occupt block 0 represented in the bitmap. The only
1287 * exception to this is when free_count also == 0, since there will be no
1288 * free blocks at all.
1291 static void load_bitmap_info_data(struct super_block *sb,
1292 struct reiserfs_bitmap_info *bi)
1294 unsigned long *cur = (unsigned long *)bi->bh->b_data;
1296 while ((char *)cur < (bi->bh->b_data + sb->s_blocksize)) {
1298 /* No need to scan if all 0's or all 1's.
1299 * Since we're only counting 0's, we can simply ignore all 1's */
1301 if (bi->first_zero_hint == 0) {
1302 bi->first_zero_hint =
1303 ((char *)cur - bi->bh->b_data) << 3;
1305 bi->free_count += sizeof(unsigned long) * 8;
1306 } else if (*cur != ~0L) {
1308 for (b = 0; b < sizeof(unsigned long) * 8; b++) {
1309 if (!reiserfs_test_le_bit(b, cur)) {
1311 if (bi->first_zero_hint == 0)
1312 bi->first_zero_hint =
1314 bi->bh->b_data) << 3) + b;
1321 #ifdef CONFIG_REISERFS_CHECK
1322 // This outputs a lot of unneded info on big FSes
1323 // reiserfs_warning ("bitmap loaded from block %d: %d free blocks",
1324 // bi->bh->b_blocknr, bi->free_count);
1328 static int read_bitmaps(struct super_block *s)
1333 vmalloc(sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
1334 if (SB_AP_BITMAP(s) == 0)
1336 memset(SB_AP_BITMAP(s), 0,
1337 sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
1338 for (i = 0, bmap_nr =
1339 REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1;
1340 i < SB_BMAP_NR(s); i++, bmap_nr = s->s_blocksize * 8 * i) {
1341 SB_AP_BITMAP(s)[i].bh = sb_getblk(s, bmap_nr);
1342 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh))
1343 ll_rw_block(READ, 1, &SB_AP_BITMAP(s)[i].bh);
1345 for (i = 0; i < SB_BMAP_NR(s); i++) {
1346 wait_on_buffer(SB_AP_BITMAP(s)[i].bh);
1347 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
1348 reiserfs_warning(s, "sh-2029: reiserfs read_bitmaps: "
1349 "bitmap block (#%lu) reading failed",
1350 SB_AP_BITMAP(s)[i].bh->b_blocknr);
1351 for (i = 0; i < SB_BMAP_NR(s); i++)
1352 brelse(SB_AP_BITMAP(s)[i].bh);
1353 vfree(SB_AP_BITMAP(s));
1354 SB_AP_BITMAP(s) = NULL;
1357 load_bitmap_info_data(s, SB_AP_BITMAP(s) + i);
1362 static int read_old_bitmaps(struct super_block *s)
1365 struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
1366 int bmp1 = (REISERFS_OLD_DISK_OFFSET_IN_BYTES / s->s_blocksize) + 1; /* first of bitmap blocks */
1368 /* read true bitmap */
1370 vmalloc(sizeof(struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
1371 if (SB_AP_BITMAP(s) == 0)
1374 memset(SB_AP_BITMAP(s), 0,
1375 sizeof(struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
1377 for (i = 0; i < sb_bmap_nr(rs); i++) {
1378 SB_AP_BITMAP(s)[i].bh = sb_bread(s, bmp1 + i);
1379 if (!SB_AP_BITMAP(s)[i].bh)
1381 load_bitmap_info_data(s, SB_AP_BITMAP(s) + i);
1387 static int read_super_block(struct super_block *s, int offset)
1389 struct buffer_head *bh;
1390 struct reiserfs_super_block *rs;
1393 bh = sb_bread(s, offset / s->s_blocksize);
1395 reiserfs_warning(s, "sh-2006: read_super_block: "
1396 "bread failed (dev %s, block %lu, size %lu)",
1397 reiserfs_bdevname(s), offset / s->s_blocksize,
1402 rs = (struct reiserfs_super_block *)bh->b_data;
1403 if (!is_any_reiserfs_magic_string(rs)) {
1408 // ok, reiserfs signature (old or new) found in at the given offset
1410 fs_blocksize = sb_blocksize(rs);
1412 sb_set_blocksize(s, fs_blocksize);
1414 bh = sb_bread(s, offset / s->s_blocksize);
1416 reiserfs_warning(s, "sh-2007: read_super_block: "
1417 "bread failed (dev %s, block %lu, size %lu)\n",
1418 reiserfs_bdevname(s), offset / s->s_blocksize,
1423 rs = (struct reiserfs_super_block *)bh->b_data;
1424 if (sb_blocksize(rs) != s->s_blocksize) {
1425 reiserfs_warning(s, "sh-2011: read_super_block: "
1426 "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n",
1427 reiserfs_bdevname(s),
1428 (unsigned long long)bh->b_blocknr,
1434 if (rs->s_v1.s_root_block == cpu_to_le32(-1)) {
1437 "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
1438 "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
1439 "get newer reiserfsprogs package");
1443 SB_BUFFER_WITH_SB(s) = bh;
1444 SB_DISK_SUPER_BLOCK(s) = rs;
1446 if (is_reiserfs_jr(rs)) {
1447 /* magic is of non-standard journal filesystem, look at s_version to
1448 find which format is in use */
1449 if (sb_version(rs) == REISERFS_VERSION_2)
1451 "read_super_block: found reiserfs format \"3.6\""
1452 " with non-standard journal");
1453 else if (sb_version(rs) == REISERFS_VERSION_1)
1455 "read_super_block: found reiserfs format \"3.5\""
1456 " with non-standard journal");
1459 "sh-2012: read_super_block: found unknown "
1460 "format \"%u\" of reiserfs with non-standard magic",
1465 /* s_version of standard format may contain incorrect information,
1466 so we just look at the magic string */
1468 "found reiserfs format \"%s\" with standard journal\n",
1469 is_reiserfs_3_5(rs) ? "3.5" : "3.6");
1471 s->s_op = &reiserfs_sops;
1472 s->s_export_op = &reiserfs_export_ops;
1474 s->s_qcop = &reiserfs_qctl_operations;
1475 s->dq_op = &reiserfs_quota_operations;
1478 /* new format is limited by the 32 bit wide i_blocks field, want to
1479 ** be one full block below that.
1481 s->s_maxbytes = (512LL << 32) - s->s_blocksize;
1485 /* after journal replay, reread all bitmap and super blocks */
1486 static int reread_meta_blocks(struct super_block *s)
1489 ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s)));
1490 wait_on_buffer(SB_BUFFER_WITH_SB(s));
1491 if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
1493 "reread_meta_blocks, error reading the super");
1497 for (i = 0; i < SB_BMAP_NR(s); i++) {
1498 ll_rw_block(READ, 1, &(SB_AP_BITMAP(s)[i].bh));
1499 wait_on_buffer(SB_AP_BITMAP(s)[i].bh);
1500 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
1502 "reread_meta_blocks, error reading bitmap block number %d at %llu",
1504 (unsigned long long)SB_AP_BITMAP(s)[i].
1513 /////////////////////////////////////////////////////
1514 // hash detection stuff
1516 // if root directory is empty - we set default - Yura's - hash and
1518 // FIXME: we look for only one name in a directory. If tea and yura
1519 // bith have the same value - we ask user to send report to the
1521 static __u32 find_hash_out(struct super_block *s)
1524 struct inode *inode;
1526 INITIALIZE_PATH(path);
1527 struct reiserfs_dir_entry de;
1528 __u32 hash = DEFAULT_HASH;
1530 inode = s->s_root->d_inode;
1532 do { // Some serious "goto"-hater was there ;)
1533 u32 teahash, r5hash, yurahash;
1535 make_cpu_key(&key, inode, ~0, TYPE_DIRENTRY, 3);
1536 retval = search_by_entry_key(s, &key, &path, &de);
1537 if (retval == IO_ERROR) {
1541 if (retval == NAME_NOT_FOUND)
1543 set_de_name_and_namelen(&de);
1544 if (deh_offset(&(de.de_deh[de.de_entry_num])) == DOT_DOT_OFFSET) {
1545 /* allow override in this case */
1546 if (reiserfs_rupasov_hash(s)) {
1549 reiserfs_warning(s, "FS seems to be empty, autodetect "
1550 "is using the default hash");
1553 r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen));
1554 teahash = GET_HASH_VALUE(keyed_hash(de.de_name, de.de_namelen));
1555 yurahash = GET_HASH_VALUE(yura_hash(de.de_name, de.de_namelen));
1556 if (((teahash == r5hash)
1558 (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num])))
1559 == r5hash)) || ((teahash == yurahash)
1561 GET_HASH_VALUE(deh_offset
1566 || ((r5hash == yurahash)
1568 GET_HASH_VALUE(deh_offset
1569 (&(de.de_deh[de.de_entry_num])))))) {
1571 "Unable to automatically detect hash function. "
1572 "Please mount with -o hash={tea,rupasov,r5}",
1573 reiserfs_bdevname(s));
1577 if (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num]))) ==
1580 else if (GET_HASH_VALUE
1581 (deh_offset(&(de.de_deh[de.de_entry_num]))) == teahash)
1583 else if (GET_HASH_VALUE
1584 (deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash)
1587 reiserfs_warning(s, "Unrecognised hash function");
1596 // finds out which hash names are sorted with
1597 static int what_hash(struct super_block *s)
1601 code = sb_hash_function_code(SB_DISK_SUPER_BLOCK(s));
1603 /* reiserfs_hash_detect() == true if any of the hash mount options
1604 ** were used. We must check them to make sure the user isn't
1605 ** using a bad hash value
1607 if (code == UNSET_HASH || reiserfs_hash_detect(s))
1608 code = find_hash_out(s);
1610 if (code != UNSET_HASH && reiserfs_hash_detect(s)) {
1611 /* detection has found the hash, and we must check against the
1614 if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
1615 reiserfs_warning(s, "Error, %s hash detected, "
1616 "unable to force rupasov hash",
1617 reiserfs_hashname(code));
1619 } else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
1620 reiserfs_warning(s, "Error, %s hash detected, "
1621 "unable to force tea hash",
1622 reiserfs_hashname(code));
1624 } else if (reiserfs_r5_hash(s) && code != R5_HASH) {
1625 reiserfs_warning(s, "Error, %s hash detected, "
1626 "unable to force r5 hash",
1627 reiserfs_hashname(code));
1631 /* find_hash_out was not called or could not determine the hash */
1632 if (reiserfs_rupasov_hash(s)) {
1634 } else if (reiserfs_tea_hash(s)) {
1636 } else if (reiserfs_r5_hash(s)) {
1641 /* if we are mounted RW, and we have a new valid hash code, update
1644 if (code != UNSET_HASH &&
1645 !(s->s_flags & MS_RDONLY) &&
1646 code != sb_hash_function_code(SB_DISK_SUPER_BLOCK(s))) {
1647 set_sb_hash_function_code(SB_DISK_SUPER_BLOCK(s), code);
1652 // return pointer to appropriate function
1653 static hashf_t hash_function(struct super_block *s)
1655 switch (what_hash(s)) {
1657 reiserfs_info(s, "Using tea hash to sort names\n");
1660 reiserfs_info(s, "Using rupasov hash to sort names\n");
1663 reiserfs_info(s, "Using r5 hash to sort names\n");
1669 // this is used to set up correct value for old partitions
1670 static int function2code(hashf_t func)
1672 if (func == keyed_hash)
1674 if (func == yura_hash)
1676 if (func == r5_hash)
1679 BUG(); // should never happen
1684 #define SWARN(silent, s, ...) \
1686 reiserfs_warning (s, __VA_ARGS__)
1688 static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1690 struct inode *root_inode;
1692 struct reiserfs_transaction_handle th;
1694 unsigned long blocks;
1695 unsigned int commit_max_age = 0;
1697 struct reiserfs_iget_args args;
1698 struct reiserfs_super_block *rs;
1700 struct reiserfs_sb_info *sbi;
1701 int errval = -EINVAL;
1703 sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
1709 memset(sbi, 0, sizeof(struct reiserfs_sb_info));
1710 /* Set default values for options: non-aggressive tails, RO on errors */
1711 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
1712 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
1713 /* no preallocation minimum, be smart in
1714 reiserfs_file_write instead */
1715 REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
1716 /* Preallocate by 16 blocks (17-1) at once */
1717 REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
1718 /* Initialize the rwsem for xattr dir */
1719 init_rwsem(&REISERFS_SB(s)->xattr_dir_sem);
1721 /* setup default block allocator options */
1722 reiserfs_init_alloc_options(s);
1725 if (reiserfs_parse_options
1726 (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name,
1727 &commit_max_age) == 0) {
1732 SWARN(silent, s, "jmacd-7: reiserfs_fill_super: resize option "
1733 "for remount only");
1737 /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
1738 if (!read_super_block(s, REISERFS_OLD_DISK_OFFSET_IN_BYTES))
1740 /* try new format (64-th 1k block), which can contain reiserfs super block */
1741 else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
1743 "sh-2021: reiserfs_fill_super: can not find reiserfs on %s",
1744 reiserfs_bdevname(s));
1748 /* map mount option tagxid */
1749 if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGXID))
1750 s->s_flags |= MS_TAGXID;
1752 rs = SB_DISK_SUPER_BLOCK(s);
1753 /* Let's do basic sanity check to verify that underlying device is not
1754 smaller than the filesystem. If the check fails then abort and scream,
1755 because bad stuff will happen otherwise. */
1756 if (s->s_bdev && s->s_bdev->bd_inode
1757 && i_size_read(s->s_bdev->bd_inode) <
1758 sb_block_count(rs) * sb_blocksize(rs)) {
1760 "Filesystem on %s cannot be mounted because it is bigger than the device",
1761 reiserfs_bdevname(s));
1763 "You may need to run fsck or increase size of your LVM partition");
1765 "Or may be you forgot to reboot after fdisk when it told you to");
1769 sbi->s_mount_state = SB_REISERFS_STATE(s);
1770 sbi->s_mount_state = REISERFS_VALID_FS;
1772 if (old_format ? read_old_bitmaps(s) : read_bitmaps(s)) {
1774 "jmacd-8: reiserfs_fill_super: unable to read bitmap");
1777 #ifdef CONFIG_REISERFS_CHECK
1778 SWARN(silent, s, "CONFIG_REISERFS_CHECK is set ON");
1779 SWARN(silent, s, "- it is slow mode for debugging.");
1782 /* make data=ordered the default */
1783 if (!reiserfs_data_log(s) && !reiserfs_data_ordered(s) &&
1784 !reiserfs_data_writeback(s)) {
1785 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_DATA_ORDERED);
1788 if (reiserfs_data_log(s)) {
1789 reiserfs_info(s, "using journaled data mode\n");
1790 } else if (reiserfs_data_ordered(s)) {
1791 reiserfs_info(s, "using ordered data mode\n");
1793 reiserfs_info(s, "using writeback data mode\n");
1795 if (reiserfs_barrier_flush(s)) {
1796 printk("reiserfs: using flush barriers\n");
1798 // set_device_ro(s->s_dev, 1) ;
1799 if (journal_init(s, jdev_name, old_format, commit_max_age)) {
1801 "sh-2022: reiserfs_fill_super: unable to initialize journal space");
1804 jinit_done = 1; /* once this is set, journal_release must be called
1805 ** if we error out of the mount
1808 if (reread_meta_blocks(s)) {
1810 "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init");
1817 if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
1819 "clm-7000: Detected readonly device, marking FS readonly");
1820 s->s_flags |= MS_RDONLY;
1822 args.objectid = REISERFS_ROOT_OBJECTID;
1823 args.dirid = REISERFS_ROOT_PARENT_OBJECTID;
1825 iget5_locked(s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor,
1826 reiserfs_init_locked_inode, (void *)(&args));
1829 "jmacd-10: reiserfs_fill_super: get root inode failed");
1833 if (root_inode->i_state & I_NEW) {
1834 reiserfs_read_locked_inode(root_inode, &args);
1835 unlock_new_inode(root_inode);
1838 s->s_root = d_alloc_root(root_inode);
1843 // define and initialize hash function
1844 sbi->s_hash_function = hash_function(s);
1845 if (sbi->s_hash_function == NULL) {
1851 if (is_reiserfs_3_5(rs)
1852 || (is_reiserfs_jr(rs) && SB_VERSION(s) == REISERFS_VERSION_1))
1853 set_bit(REISERFS_3_5, &(sbi->s_properties));
1855 set_bit(REISERFS_3_6, &(sbi->s_properties));
1857 if (!(s->s_flags & MS_RDONLY)) {
1859 errval = journal_begin(&th, s, 1);
1865 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
1867 set_sb_umount_state(rs, REISERFS_ERROR_FS);
1868 set_sb_fs_state(rs, 0);
1870 if (old_format_only(s)) {
1871 /* filesystem of format 3.5 either with standard or non-standard
1873 if (convert_reiserfs(s)) {
1874 /* and -o conv is given */
1877 "converting 3.5 filesystem to the 3.6 format");
1879 if (is_reiserfs_3_5(rs))
1880 /* put magic string of 3.6 format. 2.2 will not be able to
1881 mount this filesystem anymore */
1882 memcpy(rs->s_v1.s_magic,
1883 reiserfs_3_6_magic_string,
1885 (reiserfs_3_6_magic_string));
1887 set_sb_version(rs, REISERFS_VERSION_2);
1888 reiserfs_convert_objectid_map_v1(s);
1889 set_bit(REISERFS_3_6, &(sbi->s_properties));
1890 clear_bit(REISERFS_3_5, &(sbi->s_properties));
1891 } else if (!silent) {
1892 reiserfs_info(s, "using 3.5.x disk format\n");
1896 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
1897 errval = journal_end(&th, s, 1);
1904 if ((errval = reiserfs_xattr_init(s, s->s_flags))) {
1910 /* look for files which were to be removed in previous session */
1911 finish_unfinished(s);
1913 if (old_format_only(s) && !silent) {
1914 reiserfs_info(s, "using 3.5.x disk format\n");
1917 if ((errval = reiserfs_xattr_init(s, s->s_flags))) {
1923 // mark hash in super block: it could be unset. overwrite should be ok
1924 set_sb_hash_function_code(rs, function2code(sbi->s_hash_function));
1928 reiserfs_proc_info_init(s);
1930 init_waitqueue_head(&(sbi->s_wait));
1931 spin_lock_init(&sbi->bitmap_lock);
1936 if (jinit_done) { /* kill the commit thread, free journal ram */
1937 journal_release_error(NULL, s);
1939 if (SB_DISK_SUPER_BLOCK(s)) {
1940 for (j = 0; j < SB_BMAP_NR(s); j++) {
1941 if (SB_AP_BITMAP(s))
1942 brelse(SB_AP_BITMAP(s)[j].bh);
1944 vfree(SB_AP_BITMAP(s));
1946 if (SB_BUFFER_WITH_SB(s))
1947 brelse(SB_BUFFER_WITH_SB(s));
1949 for (j = 0; j < MAXQUOTAS; j++) {
1950 kfree(sbi->s_qf_names[j]);
1951 sbi->s_qf_names[j] = NULL;
1956 s->s_fs_info = NULL;
1960 static int reiserfs_statfs(struct dentry *dentry, struct kstatfs *buf)
1962 struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(dentry->d_sb);
1964 buf->f_namelen = (REISERFS_MAX_NAME(s->s_blocksize));
1965 buf->f_bfree = sb_free_blocks(rs);
1966 buf->f_bavail = buf->f_bfree;
1967 buf->f_blocks = sb_block_count(rs) - sb_bmap_nr(rs) - 1;
1968 buf->f_bsize = dentry->d_sb->s_blocksize;
1969 /* changed to accommodate gcc folks. */
1970 buf->f_type = REISERFS_SUPER_MAGIC;
1975 static int reiserfs_dquot_initialize(struct inode *inode, int type)
1977 struct reiserfs_transaction_handle th;
1980 /* We may create quota structure so we need to reserve enough blocks */
1981 reiserfs_write_lock(inode->i_sb);
1983 journal_begin(&th, inode->i_sb,
1984 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
1987 ret = dquot_initialize(inode, type);
1989 journal_end(&th, inode->i_sb,
1990 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
1994 reiserfs_write_unlock(inode->i_sb);
1998 static int reiserfs_dquot_drop(struct inode *inode)
2000 struct reiserfs_transaction_handle th;
2003 /* We may delete quota structure so we need to reserve enough blocks */
2004 reiserfs_write_lock(inode->i_sb);
2006 journal_begin(&th, inode->i_sb,
2007 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
2010 ret = dquot_drop(inode);
2012 journal_end(&th, inode->i_sb,
2013 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
2017 reiserfs_write_unlock(inode->i_sb);
2021 static int reiserfs_write_dquot(struct dquot *dquot)
2023 struct reiserfs_transaction_handle th;
2026 reiserfs_write_lock(dquot->dq_sb);
2028 journal_begin(&th, dquot->dq_sb,
2029 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2032 ret = dquot_commit(dquot);
2034 journal_end(&th, dquot->dq_sb,
2035 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2039 reiserfs_write_unlock(dquot->dq_sb);
2043 static int reiserfs_acquire_dquot(struct dquot *dquot)
2045 struct reiserfs_transaction_handle th;
2048 reiserfs_write_lock(dquot->dq_sb);
2050 journal_begin(&th, dquot->dq_sb,
2051 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2054 ret = dquot_acquire(dquot);
2056 journal_end(&th, dquot->dq_sb,
2057 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2061 reiserfs_write_unlock(dquot->dq_sb);
2065 static int reiserfs_release_dquot(struct dquot *dquot)
2067 struct reiserfs_transaction_handle th;
2070 reiserfs_write_lock(dquot->dq_sb);
2072 journal_begin(&th, dquot->dq_sb,
2073 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2076 ret = dquot_release(dquot);
2078 journal_end(&th, dquot->dq_sb,
2079 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2083 reiserfs_write_unlock(dquot->dq_sb);
2087 static int reiserfs_mark_dquot_dirty(struct dquot *dquot)
2089 /* Are we journalling quotas? */
2090 if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
2091 REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
2092 dquot_mark_dquot_dirty(dquot);
2093 return reiserfs_write_dquot(dquot);
2095 return dquot_mark_dquot_dirty(dquot);
2098 static int reiserfs_write_info(struct super_block *sb, int type)
2100 struct reiserfs_transaction_handle th;
2103 /* Data block + inode block */
2104 reiserfs_write_lock(sb);
2105 ret = journal_begin(&th, sb, 2);
2108 ret = dquot_commit_info(sb, type);
2109 err = journal_end(&th, sb, 2);
2113 reiserfs_write_unlock(sb);
2118 * Turn on quotas during mount time - we need to find the quota file and such...
2120 static int reiserfs_quota_on_mount(struct super_block *sb, int type)
2122 return vfs_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type],
2123 REISERFS_SB(sb)->s_jquota_fmt, type);
2127 * Standard function to be called on quota_on
2129 static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2133 struct nameidata nd;
2135 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA)))
2137 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
2140 /* Quotafile not on the same filesystem? */
2141 if (nd.mnt->mnt_sb != sb) {
2145 /* We must not pack tails for quota files on reiserfs for quota IO to work */
2146 if (!REISERFS_I(nd.dentry->d_inode)->i_flags & i_nopack_mask) {
2147 reiserfs_warning(sb,
2148 "reiserfs: Quota file must have tail packing disabled.");
2152 /* Not journalling quota? No more tests needed... */
2153 if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
2154 !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
2156 return vfs_quota_on(sb, type, format_id, path);
2158 /* Quotafile not of fs root? */
2159 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
2160 reiserfs_warning(sb,
2161 "reiserfs: Quota file not on filesystem root. "
2162 "Journalled quota will not work.");
2164 return vfs_quota_on(sb, type, format_id, path);
2167 /* Read data from quotafile - avoid pagecache and such because we cannot afford
2168 * acquiring the locks... As quota files are never truncated and quota code
2169 * itself serializes the operations (and noone else should touch the files)
2170 * we don't have to be afraid of races */
2171 static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data,
2172 size_t len, loff_t off)
2174 struct inode *inode = sb_dqopt(sb)->files[type];
2175 unsigned long blk = off >> sb->s_blocksize_bits;
2176 int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
2178 struct buffer_head tmp_bh, *bh;
2179 loff_t i_size = i_size_read(inode);
2183 if (off + len > i_size)
2186 while (toread > 0) {
2188 sb->s_blocksize - offset <
2189 toread ? sb->s_blocksize - offset : toread;
2191 /* Quota files are without tails so we can safely use this function */
2192 reiserfs_write_lock(sb);
2193 err = reiserfs_get_block(inode, blk, &tmp_bh, 0);
2194 reiserfs_write_unlock(sb);
2197 if (!buffer_mapped(&tmp_bh)) /* A hole? */
2198 memset(data, 0, tocopy);
2200 bh = sb_bread(sb, tmp_bh.b_blocknr);
2203 memcpy(data, bh->b_data + offset, tocopy);
2214 /* Write to quotafile (we know the transaction is already started and has
2215 * enough credits) */
2216 static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2217 const char *data, size_t len, loff_t off)
2219 struct inode *inode = sb_dqopt(sb)->files[type];
2220 unsigned long blk = off >> sb->s_blocksize_bits;
2221 int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
2222 int journal_quota = REISERFS_SB(sb)->s_qf_names[type] != NULL;
2223 size_t towrite = len;
2224 struct buffer_head tmp_bh, *bh;
2226 mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
2227 while (towrite > 0) {
2228 tocopy = sb->s_blocksize - offset < towrite ?
2229 sb->s_blocksize - offset : towrite;
2231 err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE);
2234 if (offset || tocopy != sb->s_blocksize)
2235 bh = sb_bread(sb, tmp_bh.b_blocknr);
2237 bh = sb_getblk(sb, tmp_bh.b_blocknr);
2243 memcpy(bh->b_data + offset, data, tocopy);
2244 flush_dcache_page(bh->b_page);
2245 set_buffer_uptodate(bh);
2247 reiserfs_prepare_for_journal(sb, bh, 1);
2248 journal_mark_dirty(current->journal_info, sb, bh);
2250 reiserfs_add_ordered_list(inode, bh);
2260 if (inode->i_size < off + len - towrite)
2261 i_size_write(inode, off + len - towrite);
2263 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2264 mark_inode_dirty(inode);
2265 mutex_unlock(&inode->i_mutex);
2266 return len - towrite;
2271 static int get_super_block(struct file_system_type *fs_type,
2272 int flags, const char *dev_name,
2273 void *data, struct vfsmount *mnt)
2275 return get_sb_bdev(fs_type, flags, dev_name, data, reiserfs_fill_super,
2279 static int __init init_reiserfs_fs(void)
2283 if ((ret = init_inodecache())) {
2287 if ((ret = reiserfs_xattr_register_handlers()))
2288 goto failed_reiserfs_xattr_register_handlers;
2290 reiserfs_proc_info_global_init();
2291 reiserfs_proc_register_global("version",
2292 reiserfs_global_version_in_proc);
2294 ret = register_filesystem(&reiserfs_fs_type);
2300 reiserfs_xattr_unregister_handlers();
2302 failed_reiserfs_xattr_register_handlers:
2303 reiserfs_proc_unregister_global("version");
2304 reiserfs_proc_info_global_done();
2305 destroy_inodecache();
2310 static void __exit exit_reiserfs_fs(void)
2312 reiserfs_xattr_unregister_handlers();
2313 reiserfs_proc_unregister_global("version");
2314 reiserfs_proc_info_global_done();
2315 unregister_filesystem(&reiserfs_fs_type);
2316 destroy_inodecache();
2319 struct file_system_type reiserfs_fs_type = {
2320 .owner = THIS_MODULE,
2322 .get_sb = get_super_block,
2323 .kill_sb = reiserfs_kill_sb,
2324 .fs_flags = FS_REQUIRES_DEV,
2327 MODULE_DESCRIPTION("ReiserFS journaled filesystem");
2328 MODULE_AUTHOR("Hans Reiser <reiser@namesys.com>");
2329 MODULE_LICENSE("GPL");
2331 module_init(init_reiserfs_fs);
2332 module_exit(exit_reiserfs_fs);