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));
45 int is_reiserfs_3_6 (struct reiserfs_super_block * rs)
47 return !strncmp (rs->s_v1.s_magic, reiserfs_3_6_magic_string,
48 strlen (reiserfs_3_6_magic_string));
52 int is_reiserfs_jr (struct reiserfs_super_block * rs)
54 return !strncmp (rs->s_v1.s_magic, reiserfs_jr_magic_string,
55 strlen (reiserfs_jr_magic_string));
59 static int is_any_reiserfs_magic_string (struct reiserfs_super_block * rs)
61 return (is_reiserfs_3_5 (rs) || is_reiserfs_3_6 (rs) ||
65 static int reiserfs_remount (struct super_block * s, int * flags, char * data);
66 static int reiserfs_statfs (struct super_block * s, struct kstatfs * buf);
68 static int reiserfs_sync_fs (struct super_block * s, int wait)
70 if (!(s->s_flags & MS_RDONLY)) {
71 struct reiserfs_transaction_handle th;
72 reiserfs_write_lock(s);
73 if (!journal_begin(&th, s, 1))
74 if (!journal_end_sync(&th, s, 1))
75 reiserfs_flush_old_commits(s);
76 s->s_dirt = 0; /* Even if it's not true.
77 * We'll loop forever in sync_supers otherwise */
78 reiserfs_write_unlock(s);
85 static void reiserfs_write_super(struct super_block *s)
87 reiserfs_sync_fs(s, 1);
90 static void reiserfs_write_super_lockfs (struct super_block * s)
92 struct reiserfs_transaction_handle th ;
93 reiserfs_write_lock(s);
94 if (!(s->s_flags & MS_RDONLY)) {
95 int err = journal_begin(&th, s, 1) ;
97 reiserfs_block_writes(&th) ;
99 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
100 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
101 reiserfs_block_writes(&th) ;
102 journal_end_sync(&th, s, 1) ;
106 reiserfs_write_unlock(s);
109 static void reiserfs_unlockfs(struct super_block *s) {
110 reiserfs_allow_writes(s) ;
113 extern const struct reiserfs_key MAX_KEY;
116 /* this is used to delete "save link" when there are no items of a
117 file it points to. It can either happen if unlink is completed but
118 "save unlink" removal, or if file has both unlink and truncate
119 pending and as unlink completes first (because key of "save link"
120 protecting unlink is bigger that a key lf "save link" which
121 protects truncate), so there left no items to make truncate
123 static int remove_save_link_only (struct super_block * s, struct reiserfs_key * key, int oid_free)
125 struct reiserfs_transaction_handle th;
128 /* we are going to do one balancing */
129 err = journal_begin (&th, s, JOURNAL_PER_BALANCE_CNT);
133 reiserfs_delete_solid_item (&th, NULL, key);
135 /* removals are protected by direct items */
136 reiserfs_release_objectid (&th, le32_to_cpu (key->k_objectid));
138 return journal_end (&th, s, JOURNAL_PER_BALANCE_CNT);
142 static int reiserfs_quota_on_mount(struct super_block *, int);
145 /* look for uncompleted unlinks and truncates and complete them */
146 static int finish_unfinished (struct super_block * s)
148 INITIALIZE_PATH (path);
149 struct cpu_key max_cpu_key, obj_key;
150 struct reiserfs_key save_link_key;
152 struct item_head * ih;
153 struct buffer_head * bh;
157 struct inode * inode;
165 /* compose key to look for "save" links */
166 max_cpu_key.version = KEY_FORMAT_3_5;
167 max_cpu_key.on_disk_key = MAX_KEY;
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);
183 reiserfs_warning(s, "reiserfs: cannot turn on journalled quota: error %d", ret);
189 REISERFS_SB(s)->s_is_unlinked_ok = 1;
191 retval = search_item (s, &max_cpu_key, &path);
192 if (retval != ITEM_NOT_FOUND) {
193 reiserfs_warning (s, "vs-2140: finish_unfinished: search_by_key returned %d",
198 bh = get_last_bh (&path);
199 item_pos = get_item_pos (&path);
200 if (item_pos != B_NR_ITEMS (bh)) {
201 reiserfs_warning (s, "vs-2060: finish_unfinished: wrong position found");
205 ih = B_N_PITEM_HEAD (bh, item_pos);
207 if (le32_to_cpu (ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID)
208 /* there are no "save" links anymore */
211 save_link_key = ih->ih_key;
212 if (is_indirect_le_ih (ih))
217 /* reiserfs_iget needs k_dirid and k_objectid only */
218 item = B_I_PITEM (bh, ih);
219 obj_key.on_disk_key.k_dir_id = le32_to_cpu (*(__u32 *)item);
220 obj_key.on_disk_key.k_objectid = le32_to_cpu (ih->ih_key.k_objectid);
221 obj_key.on_disk_key.u.k_offset_v1.k_offset = 0;
222 obj_key.on_disk_key.u.k_offset_v1.k_uniqueness = 0;
226 inode = reiserfs_iget (s, &obj_key);
228 /* the unlink almost completed, it just did not manage to remove
229 "save" link and release objectid */
230 reiserfs_warning (s, "vs-2180: finish_unfinished: iget failed for %K",
232 retval = remove_save_link_only (s, &save_link_key, 1);
236 if (!truncate && inode->i_nlink) {
237 /* file is not unlinked */
238 reiserfs_warning (s, "vs-2185: finish_unfinished: file %K is not unlinked",
240 retval = remove_save_link_only (s, &save_link_key, 0);
245 if (truncate && S_ISDIR (inode->i_mode) ) {
246 /* We got a truncate request for a dir which is impossible.
247 The only imaginable way is to execute unfinished truncate request
248 then boot into old kernel, remove the file and create dir with
250 reiserfs_warning(s, "green-2101: impossible truncate on a directory %k. Please report", INODE_PKEY (inode));
251 retval = remove_save_link_only (s, &save_link_key, 0);
258 REISERFS_I(inode) -> i_flags |= i_link_saved_truncate_mask;
259 /* not completed truncate found. New size was committed together
261 reiserfs_info (s, "Truncating %k to %Ld ..",
262 INODE_PKEY (inode), inode->i_size);
263 reiserfs_truncate_file (inode, 0/*don't update modification time*/);
264 retval = remove_save_link (inode, truncate);
266 REISERFS_I(inode) -> i_flags |= i_link_saved_unlink_mask;
267 /* not completed unlink (rmdir) found */
268 reiserfs_info (s, "Removing %k..", INODE_PKEY (inode));
269 /* removal gets completed in iput */
277 REISERFS_SB(s)->s_is_unlinked_ok = 0;
280 /* Turn quotas off */
281 for (i = 0; i < MAXQUOTAS; i++) {
282 if (sb_dqopt(s)->files[i])
283 vfs_quota_off_mount(s, i);
286 /* Restore the flag back */
287 s->s_flags &= ~MS_ACTIVE;
291 reiserfs_info (s, "There were %d uncompleted unlinks/truncates. "
292 "Completed\n", done);
296 /* to protect file being unlinked from getting lost we "safe" link files
297 being unlinked. This link will be deleted in the same transaction with last
298 item of file. mounting the filesytem we scan all these links and remove
299 files which almost got lost */
300 void add_save_link (struct reiserfs_transaction_handle * th,
301 struct inode * inode, int truncate)
303 INITIALIZE_PATH (path);
309 BUG_ON (!th->t_trans_id);
311 /* file can only get one "save link" of each kind */
313 ( REISERFS_I(inode) -> i_flags & i_link_saved_truncate_mask ),
314 "saved link already exists for truncated inode %lx",
315 ( long ) inode -> i_ino );
317 ( REISERFS_I(inode) -> i_flags & i_link_saved_unlink_mask ),
318 "saved link already exists for unlinked inode %lx",
319 ( long ) inode -> i_ino );
321 /* setup key of "save" link */
322 key.version = KEY_FORMAT_3_5;
323 key.on_disk_key.k_dir_id = MAX_KEY_OBJECTID;
324 key.on_disk_key.k_objectid = inode->i_ino;
326 /* unlink, rmdir, rename */
327 set_cpu_key_k_offset (&key, 1 + inode->i_sb->s_blocksize);
328 set_cpu_key_k_type (&key, TYPE_DIRECT);
330 /* item head of "safe" link */
331 make_le_item_head (&ih, &key, key.version, 1 + inode->i_sb->s_blocksize, TYPE_DIRECT,
332 4/*length*/, 0xffff/*free space*/);
335 if (S_ISDIR (inode->i_mode))
336 reiserfs_warning(inode->i_sb, "green-2102: Adding a truncate savelink for a directory %k! Please report", INODE_PKEY(inode));
337 set_cpu_key_k_offset (&key, 1);
338 set_cpu_key_k_type (&key, TYPE_INDIRECT);
340 /* item head of "safe" link */
341 make_le_item_head (&ih, &key, key.version, 1, TYPE_INDIRECT,
342 4/*length*/, 0/*free space*/);
346 /* look for its place in the tree */
347 retval = search_item (inode->i_sb, &key, &path);
348 if (retval != ITEM_NOT_FOUND) {
349 if ( retval != -ENOSPC )
350 reiserfs_warning (inode->i_sb, "vs-2100: add_save_link:"
351 "search_by_key (%K) returned %d", &key, retval);
356 /* body of "save" link */
357 link = INODE_PKEY (inode)->k_dir_id;
359 /* put "save" link inot tree, don't charge quota to anyone */
360 retval = reiserfs_insert_item (th, &path, &key, &ih, NULL, (char *)&link);
362 if (retval != -ENOSPC)
363 reiserfs_warning (inode->i_sb, "vs-2120: add_save_link: insert_item returned %d",
367 REISERFS_I(inode) -> i_flags |= i_link_saved_truncate_mask;
369 REISERFS_I(inode) -> i_flags |= i_link_saved_unlink_mask;
374 /* this opens transaction unlike add_save_link */
375 int remove_save_link (struct inode * inode, int truncate)
377 struct reiserfs_transaction_handle th;
378 struct reiserfs_key key;
381 /* we are going to do one balancing only */
382 err = journal_begin (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
386 /* setup key of "save" link */
387 key.k_dir_id = cpu_to_le32 (MAX_KEY_OBJECTID);
388 key.k_objectid = INODE_PKEY (inode)->k_objectid;
390 /* unlink, rmdir, rename */
391 set_le_key_k_offset (KEY_FORMAT_3_5, &key,
392 1 + inode->i_sb->s_blocksize);
393 set_le_key_k_type (KEY_FORMAT_3_5, &key, TYPE_DIRECT);
396 set_le_key_k_offset (KEY_FORMAT_3_5, &key, 1);
397 set_le_key_k_type (KEY_FORMAT_3_5, &key, TYPE_INDIRECT);
401 ( REISERFS_I(inode) -> i_flags & i_link_saved_truncate_mask ) ) ||
403 ( REISERFS_I(inode) -> i_flags & i_link_saved_unlink_mask ) ) )
404 /* don't take quota bytes from anywhere */
405 reiserfs_delete_solid_item (&th, NULL, &key);
407 reiserfs_release_objectid (&th, inode->i_ino);
408 REISERFS_I(inode) -> i_flags &= ~i_link_saved_unlink_mask;
410 REISERFS_I(inode) -> i_flags &= ~i_link_saved_truncate_mask;
412 return journal_end (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
416 static void reiserfs_put_super (struct super_block * s)
419 struct reiserfs_transaction_handle th ;
422 if (REISERFS_SB(s)->xattr_root) {
423 d_invalidate (REISERFS_SB(s)->xattr_root);
424 dput (REISERFS_SB(s)->xattr_root);
427 if (REISERFS_SB(s)->priv_root) {
428 d_invalidate (REISERFS_SB(s)->priv_root);
429 dput (REISERFS_SB(s)->priv_root);
432 /* change file system state to current state if it was mounted with read-write permissions */
433 if (!(s->s_flags & MS_RDONLY)) {
434 if (!journal_begin(&th, s, 10)) {
435 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
436 set_sb_umount_state( SB_DISK_SUPER_BLOCK(s), REISERFS_SB(s)->s_mount_state );
437 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
441 /* note, journal_release checks for readonly mount, and can decide not
442 ** to do a journal_end
444 journal_release(&th, s) ;
446 for (i = 0; i < SB_BMAP_NR (s); i ++)
447 brelse (SB_AP_BITMAP (s)[i].bh);
449 vfree (SB_AP_BITMAP (s));
451 brelse (SB_BUFFER_WITH_SB (s));
453 print_statistics (s);
455 if (REISERFS_SB(s)->s_kmallocs != 0) {
456 reiserfs_warning (s, "vs-2004: reiserfs_put_super: allocated memory left %d",
457 REISERFS_SB(s)->s_kmallocs);
460 if (REISERFS_SB(s)->reserved_blocks != 0) {
461 reiserfs_warning (s, "green-2005: reiserfs_put_super: reserved blocks left %d",
462 REISERFS_SB(s)->reserved_blocks);
465 reiserfs_proc_info_done( s );
473 static kmem_cache_t * reiserfs_inode_cachep;
475 static struct inode *reiserfs_alloc_inode(struct super_block *sb)
477 struct reiserfs_inode_info *ei;
478 ei = (struct reiserfs_inode_info *)kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL);
481 return &ei->vfs_inode;
484 static void reiserfs_destroy_inode(struct inode *inode)
486 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
489 static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
491 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *) foo;
493 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
494 SLAB_CTOR_CONSTRUCTOR) {
495 INIT_LIST_HEAD(&ei->i_prealloc_list) ;
496 inode_init_once(&ei->vfs_inode);
497 ei->i_acl_access = NULL;
498 ei->i_acl_default = NULL;
502 static int init_inodecache(void)
504 reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache",
505 sizeof(struct reiserfs_inode_info),
506 0, SLAB_RECLAIM_ACCOUNT,
508 if (reiserfs_inode_cachep == NULL)
513 static void destroy_inodecache(void)
515 if (kmem_cache_destroy(reiserfs_inode_cachep))
516 reiserfs_warning (NULL, "reiserfs_inode_cache: not all structures were freed");
519 /* we don't mark inodes dirty, we just log them */
520 static void reiserfs_dirty_inode (struct inode * inode) {
521 struct reiserfs_transaction_handle th ;
524 if (inode->i_sb->s_flags & MS_RDONLY) {
525 reiserfs_warning(inode->i_sb, "clm-6006: writing inode %lu on readonly FS",
529 reiserfs_write_lock(inode->i_sb);
531 /* this is really only used for atime updates, so they don't have
532 ** to be included in O_SYNC or fsync
534 err = journal_begin(&th, inode->i_sb, 1) ;
536 reiserfs_write_unlock (inode->i_sb);
539 reiserfs_update_sd (&th, inode);
540 journal_end(&th, inode->i_sb, 1) ;
541 reiserfs_write_unlock(inode->i_sb);
544 static void reiserfs_clear_inode (struct inode *inode)
546 struct posix_acl *acl;
548 acl = REISERFS_I(inode)->i_acl_access;
549 if (acl && !IS_ERR (acl))
550 posix_acl_release (acl);
551 REISERFS_I(inode)->i_acl_access = NULL;
553 acl = REISERFS_I(inode)->i_acl_default;
554 if (acl && !IS_ERR (acl))
555 posix_acl_release (acl);
556 REISERFS_I(inode)->i_acl_default = NULL;
560 static ssize_t reiserfs_quota_write(struct super_block *, int, const char *, size_t, loff_t);
561 static ssize_t reiserfs_quota_read(struct super_block *, int, char *, size_t, loff_t);
564 static struct super_operations reiserfs_sops =
566 .alloc_inode = reiserfs_alloc_inode,
567 .destroy_inode = reiserfs_destroy_inode,
568 .write_inode = reiserfs_write_inode,
569 .dirty_inode = reiserfs_dirty_inode,
570 .delete_inode = reiserfs_delete_inode,
571 .clear_inode = reiserfs_clear_inode,
572 .put_super = reiserfs_put_super,
573 .write_super = reiserfs_write_super,
574 .sync_fs = reiserfs_sync_fs,
575 .write_super_lockfs = reiserfs_write_super_lockfs,
576 .unlockfs = reiserfs_unlockfs,
577 .statfs = reiserfs_statfs,
578 .remount_fs = reiserfs_remount,
580 .quota_read = reiserfs_quota_read,
581 .quota_write = reiserfs_quota_write,
586 #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")
588 static int reiserfs_dquot_initialize(struct inode *, int);
589 static int reiserfs_dquot_drop(struct inode *);
590 static int reiserfs_write_dquot(struct dquot *);
591 static int reiserfs_acquire_dquot(struct dquot *);
592 static int reiserfs_release_dquot(struct dquot *);
593 static int reiserfs_mark_dquot_dirty(struct dquot *);
594 static int reiserfs_write_info(struct super_block *, int);
595 static int reiserfs_quota_on(struct super_block *, int, int, char *);
597 static struct dquot_operations reiserfs_quota_operations =
599 .initialize = reiserfs_dquot_initialize,
600 .drop = reiserfs_dquot_drop,
601 .alloc_space = dquot_alloc_space,
602 .alloc_inode = dquot_alloc_inode,
603 .free_space = dquot_free_space,
604 .free_inode = dquot_free_inode,
605 .transfer = dquot_transfer,
606 .write_dquot = reiserfs_write_dquot,
607 .acquire_dquot = reiserfs_acquire_dquot,
608 .release_dquot = reiserfs_release_dquot,
609 .mark_dirty = reiserfs_mark_dquot_dirty,
610 .write_info = reiserfs_write_info,
613 static struct quotactl_ops reiserfs_qctl_operations =
615 .quota_on = reiserfs_quota_on,
616 .quota_off = vfs_quota_off,
617 .quota_sync = vfs_quota_sync,
618 .get_info = vfs_get_dqinfo,
619 .set_info = vfs_set_dqinfo,
620 .get_dqblk = vfs_get_dqblk,
621 .set_dqblk = vfs_set_dqblk,
625 static struct export_operations reiserfs_export_ops = {
626 .encode_fh = reiserfs_encode_fh,
627 .decode_fh = reiserfs_decode_fh,
628 .get_parent = reiserfs_get_parent,
629 .get_dentry = reiserfs_get_dentry,
632 /* this struct is used in reiserfs_getopt () for containing the value for those
633 mount options that have values rather than being toggles. */
636 int setmask; /* bitmask which is to set on mount_options bitmask when this
637 value is found, 0 is no bits are to be changed. */
638 int clrmask; /* bitmask which is to clear on mount_options bitmask when this
639 value is found, 0 is no bits are to be changed. This is
640 applied BEFORE setmask */
643 /* Set this bit in arg_required to allow empty arguments */
644 #define REISERFS_OPT_ALLOWEMPTY 31
646 /* this struct is used in reiserfs_getopt() for describing the set of reiserfs
650 int arg_required; /* 0 if argument is not required, not 0 otherwise */
651 const arg_desc_t * values; /* list of values accepted by an option */
652 int setmask; /* bitmask which is to set on mount_options bitmask when this
653 value is found, 0 is no bits are to be changed. */
654 int clrmask; /* bitmask which is to clear on mount_options bitmask when this
655 value is found, 0 is no bits are to be changed. This is
656 applied BEFORE setmask */
659 /* possible values for -o data= */
660 static const arg_desc_t logging_mode[] = {
661 {"ordered", 1<<REISERFS_DATA_ORDERED, (1<<REISERFS_DATA_LOG|1<<REISERFS_DATA_WRITEBACK)},
662 {"journal", 1<<REISERFS_DATA_LOG, (1<<REISERFS_DATA_ORDERED|1<<REISERFS_DATA_WRITEBACK)},
663 {"writeback", 1<<REISERFS_DATA_WRITEBACK, (1<<REISERFS_DATA_ORDERED|1<<REISERFS_DATA_LOG)},
667 /* possible values for -o barrier= */
668 static const arg_desc_t barrier_mode[] = {
669 {"none", 1<<REISERFS_BARRIER_NONE, 1<<REISERFS_BARRIER_FLUSH},
670 {"flush", 1<<REISERFS_BARRIER_FLUSH, 1<<REISERFS_BARRIER_NONE},
674 /* possible values for "-o block-allocator=" and bits which are to be set in
675 s_mount_opt of reiserfs specific part of in-core super block */
676 static const arg_desc_t balloc[] = {
677 {"noborder", 1<<REISERFS_NO_BORDER, 0},
678 {"border", 0, 1<<REISERFS_NO_BORDER},
679 {"no_unhashed_relocation", 1<<REISERFS_NO_UNHASHED_RELOCATION, 0},
680 {"hashed_relocation", 1<<REISERFS_HASHED_RELOCATION, 0},
681 {"test4", 1<<REISERFS_TEST4, 0},
682 {"notest4", 0, 1<<REISERFS_TEST4},
686 static const arg_desc_t tails[] = {
687 {"on", 1<<REISERFS_LARGETAIL, 1<<REISERFS_SMALLTAIL},
688 {"off", 0, (1<<REISERFS_LARGETAIL)|(1<<REISERFS_SMALLTAIL)},
689 {"small", 1<<REISERFS_SMALLTAIL, 1<<REISERFS_LARGETAIL},
693 static const arg_desc_t error_actions[] = {
694 {"panic", 1 << REISERFS_ERROR_PANIC,
695 (1 << REISERFS_ERROR_RO | 1 << REISERFS_ERROR_CONTINUE)},
696 {"ro-remount", 1 << REISERFS_ERROR_RO,
697 (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_CONTINUE)},
698 #ifdef REISERFS_JOURNAL_ERROR_ALLOWS_NO_LOG
699 {"continue", 1 << REISERFS_ERROR_CONTINUE,
700 (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_RO)},
705 int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 128k.
706 There might be broken applications that are
707 confused by this. Use nolargeio mount option
708 to get usual i/o size = PAGE_SIZE.
711 /* proceed only one option from a list *cur - string containing of mount options
712 opts - array of options which are accepted
713 opt_arg - if option is found and requires an argument and if it is specifed
714 in the input - pointer to the argument is stored here
715 bit_flags - if option requires to set a certain bit - it is set here
716 return -1 if unknown option is found, opt->arg_required otherwise */
717 static int reiserfs_getopt ( struct super_block * s, char ** cur, opt_desc_t * opts, char ** opt_arg,
718 unsigned long * bit_flags)
727 const opt_desc_t * opt;
728 const arg_desc_t * arg;
733 /* assume argument cannot contain commas */
734 *cur = strchr (p, ',');
740 if ( !strncmp (p, "alloc=", 6) ) {
741 /* Ugly special case, probably we should redo options parser so that
742 it can understand several arguments for some options, also so that
743 it can fill several bitfields with option values. */
744 if ( reiserfs_parse_alloc_options( s, p + 6) ) {
752 /* for every option in the list */
753 for (opt = opts; opt->option_name; opt ++) {
754 if (!strncmp (p, opt->option_name, strlen (opt->option_name))) {
756 if (opt->clrmask == (1 << REISERFS_UNSUPPORTED_OPT))
757 reiserfs_warning (s, "%s not supported.", p);
759 *bit_flags &= ~opt->clrmask;
760 if (opt->setmask == (1 << REISERFS_UNSUPPORTED_OPT))
761 reiserfs_warning (s, "%s not supported.", p);
763 *bit_flags |= opt->setmask;
768 if (!opt->option_name) {
769 reiserfs_warning (s, "unknown mount option \"%s\"", p);
773 p += strlen (opt->option_name);
776 if (!opt->arg_required) {
777 reiserfs_warning (s, "the option \"%s\" does not require an argument",
784 if (opt->arg_required) {
785 reiserfs_warning (s, "the option \"%s\" requires an argument", opt->option_name);
790 reiserfs_warning (s, "head of option \"%s\" is only correct", opt->option_name);
794 /* move to the argument, or to next option if argument is not required */
797 if ( opt->arg_required && !(opt->arg_required & (1<<REISERFS_OPT_ALLOWEMPTY)) && !strlen (p) ) {
798 /* this catches "option=," if not allowed */
799 reiserfs_warning (s, "empty argument for \"%s\"", opt->option_name);
804 /* *=NULLopt_arg contains pointer to argument */
806 return opt->arg_required & ~(1<<REISERFS_OPT_ALLOWEMPTY);
809 /* values possible for this option are listed in opt->values */
810 for (arg = opt->values; arg->value; arg ++) {
811 if (!strcmp (p, arg->value)) {
813 *bit_flags &= ~arg->clrmask;
814 *bit_flags |= arg->setmask;
816 return opt->arg_required;
820 reiserfs_warning (s, "bad value \"%s\" for option \"%s\"", p, opt->option_name);
824 /* returns 0 if something is wrong in option string, 1 - otherwise */
825 static int reiserfs_parse_options (struct super_block * s, char * options, /* string given via mount's -o */
826 unsigned long * mount_options,
827 /* after the parsing phase, contains the
828 collection of bitflags defining what
829 mount options were selected. */
830 unsigned long * blocks, /* strtol-ed from NNN of resize=NNN */
832 unsigned int * commit_max_age)
837 opt_desc_t opts[] = {
838 /* Compatibility stuff, so that -o notail for old setups still work */
839 {"tails", .arg_required = 't', .values = tails},
840 {"notail", .clrmask = (1<<REISERFS_LARGETAIL)|(1<<REISERFS_SMALLTAIL)},
841 {"conv", .setmask = 1<<REISERFS_CONVERT},
842 {"attrs", .setmask = 1<<REISERFS_ATTRS},
843 {"noattrs", .clrmask = 1<<REISERFS_ATTRS},
844 #ifdef CONFIG_REISERFS_FS_XATTR
845 {"user_xattr", .setmask = 1<<REISERFS_XATTRS_USER},
846 {"nouser_xattr",.clrmask = 1<<REISERFS_XATTRS_USER},
848 {"user_xattr", .setmask = 1<<REISERFS_UNSUPPORTED_OPT},
849 {"nouser_xattr",.clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
851 {"tagxid", .setmask = 1<<REISERFS_TAGXID},
852 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
853 {"acl", .setmask = 1<<REISERFS_POSIXACL},
854 {"noacl", .clrmask = 1<<REISERFS_POSIXACL},
856 {"acl", .setmask = 1<<REISERFS_UNSUPPORTED_OPT},
857 {"noacl", .clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
859 {"nolog",}, /* This is unsupported */
860 {"replayonly", .setmask = 1<<REPLAYONLY},
861 {"block-allocator", .arg_required = 'a', .values = balloc},
862 {"data", .arg_required = 'd', .values = logging_mode},
863 {"barrier", .arg_required = 'b', .values = barrier_mode},
864 {"resize", .arg_required = 'r', .values = NULL},
865 {"jdev", .arg_required = 'j', .values = NULL},
866 {"nolargeio", .arg_required = 'w', .values = NULL},
867 {"commit", .arg_required = 'c', .values = NULL},
870 {"errors", .arg_required = 'e', .values = error_actions},
871 {"usrjquota", .arg_required = 'u'|(1<<REISERFS_OPT_ALLOWEMPTY), .values = NULL},
872 {"grpjquota", .arg_required = 'g'|(1<<REISERFS_OPT_ALLOWEMPTY), .values = NULL},
873 {"jqfmt", .arg_required = 'f', .values = NULL},
878 if (!options || !*options)
879 /* use default configuration: create tails, journaling on, no
880 conversion to newest format */
883 for (pos = options; pos; ) {
884 c = reiserfs_getopt (s, &pos, opts, &arg, mount_options);
886 /* wrong option is given */
894 *blocks = simple_strtoul (arg, &p, 0);
896 /* NNN does not look like a number */
897 reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
904 unsigned long val = simple_strtoul (arg, &p, 0);
905 /* commit=NNN (time in seconds) */
906 if ( *p != '\0' || val >= (unsigned int)-1) {
907 reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg); return 0;
909 *commit_max_age = (unsigned int)val;
914 int val = simple_strtoul (arg, &p, 0);
917 reiserfs_warning (s, "reiserfs_parse_options: non-numeric value %s for nolargeio option", arg);
921 reiserfs_default_io_size = PAGE_SIZE;
923 reiserfs_default_io_size = 128 * 1024;
927 if (arg && *arg && jdev_name) {
928 if ( *jdev_name ) { //Hm, already assigned?
929 reiserfs_warning (s, "reiserfs_parse_options: journal device was already specified to be %s", *jdev_name);
937 if (c == 'u' || c == 'g') {
938 int qtype = c == 'u' ? USRQUOTA : GRPQUOTA;
940 if (sb_any_quota_enabled(s)) {
941 reiserfs_warning(s, "reiserfs_parse_options: cannot change journalled quota options when quota turned on.");
944 if (*arg) { /* Some filename specified? */
945 if (REISERFS_SB(s)->s_qf_names[qtype] && strcmp(REISERFS_SB(s)->s_qf_names[qtype], arg)) {
946 reiserfs_warning(s, "reiserfs_parse_options: %s quota file already specified.", QTYPE2NAME(qtype));
949 if (strchr(arg, '/')) {
950 reiserfs_warning(s, "reiserfs_parse_options: quotafile must be on filesystem root.");
953 REISERFS_SB(s)->s_qf_names[qtype] = kmalloc(strlen(arg)+1, GFP_KERNEL);
954 if (!REISERFS_SB(s)->s_qf_names[qtype]) {
955 reiserfs_warning(s, "reiserfs_parse_options: not enough memory for storing quotafile name.");
958 strcpy(REISERFS_SB(s)->s_qf_names[qtype], arg);
961 if (REISERFS_SB(s)->s_qf_names[qtype]) {
962 kfree(REISERFS_SB(s)->s_qf_names[qtype]);
963 REISERFS_SB(s)->s_qf_names[qtype] = NULL;
968 if (!strcmp(arg, "vfsold"))
969 REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_OLD;
970 else if (!strcmp(arg, "vfsv0"))
971 REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_V0;
973 reiserfs_warning(s, "reiserfs_parse_options: unknown quota format specified.");
978 if (c == 'u' || c == 'g' || c == 'f') {
979 reiserfs_warning(s, "reiserfs_parse_options: journalled quota options not supported.");
986 if (!REISERFS_SB(s)->s_jquota_fmt && (REISERFS_SB(s)->s_qf_names[USRQUOTA] || REISERFS_SB(s)->s_qf_names[GRPQUOTA])) {
987 reiserfs_warning(s, "reiserfs_parse_options: journalled quota format not specified.");
994 static void switch_data_mode(struct super_block *s, unsigned long mode) {
995 REISERFS_SB(s)->s_mount_opt &= ~((1 << REISERFS_DATA_LOG) |
996 (1 << REISERFS_DATA_ORDERED) |
997 (1 << REISERFS_DATA_WRITEBACK));
998 REISERFS_SB(s)->s_mount_opt |= (1 << mode);
1001 static void handle_data_mode(struct super_block *s, unsigned long mount_options)
1003 if (mount_options & (1 << REISERFS_DATA_LOG)) {
1004 if (!reiserfs_data_log(s)) {
1005 switch_data_mode(s, REISERFS_DATA_LOG);
1006 reiserfs_info (s, "switching to journaled data mode\n");
1008 } else if (mount_options & (1 << REISERFS_DATA_ORDERED)) {
1009 if (!reiserfs_data_ordered(s)) {
1010 switch_data_mode(s, REISERFS_DATA_ORDERED);
1011 reiserfs_info (s, "switching to ordered data mode\n");
1013 } else if (mount_options & (1 << REISERFS_DATA_WRITEBACK)) {
1014 if (!reiserfs_data_writeback(s)) {
1015 switch_data_mode(s, REISERFS_DATA_WRITEBACK);
1016 reiserfs_info (s, "switching to writeback data mode\n");
1021 static void handle_barrier_mode(struct super_block *s, unsigned long bits) {
1022 int flush = (1 << REISERFS_BARRIER_FLUSH);
1023 int none = (1 << REISERFS_BARRIER_NONE);
1024 int all_barrier = flush | none;
1026 if (bits & all_barrier) {
1027 REISERFS_SB(s)->s_mount_opt &= ~all_barrier;
1029 REISERFS_SB(s)->s_mount_opt |= flush;
1030 printk("reiserfs: enabling write barrier flush mode\n");
1031 } else if (bits & none) {
1032 REISERFS_SB(s)->s_mount_opt |= none;
1033 printk("reiserfs: write barriers turned off\n");
1038 static void handle_attrs( struct super_block *s )
1040 struct reiserfs_super_block * rs;
1042 if( reiserfs_attrs( s ) ) {
1043 rs = SB_DISK_SUPER_BLOCK (s);
1044 if( old_format_only(s) ) {
1045 reiserfs_warning(s, "reiserfs: cannot support attributes on 3.5.x disk format" );
1046 REISERFS_SB(s) -> s_mount_opt &= ~ ( 1 << REISERFS_ATTRS );
1049 if( !( le32_to_cpu( rs -> s_flags ) & reiserfs_attrs_cleared ) ) {
1050 reiserfs_warning(s, "reiserfs: cannot support attributes until flag is set in super-block" );
1051 REISERFS_SB(s) -> s_mount_opt &= ~ ( 1 << REISERFS_ATTRS );
1056 static int reiserfs_remount (struct super_block * s, int * mount_flags, char * arg)
1058 struct reiserfs_super_block * rs;
1059 struct reiserfs_transaction_handle th ;
1060 unsigned long blocks;
1061 unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
1062 unsigned long safe_mask = 0;
1063 unsigned int commit_max_age = (unsigned int)-1;
1064 struct reiserfs_journal *journal = SB_JOURNAL(s);
1070 rs = SB_DISK_SUPER_BLOCK (s);
1072 if (!reiserfs_parse_options(s, arg, &mount_options, &blocks, NULL, &commit_max_age)) {
1074 for (i = 0; i < MAXQUOTAS; i++)
1075 if (REISERFS_SB(s)->s_qf_names[i]) {
1076 kfree(REISERFS_SB(s)->s_qf_names[i]);
1077 REISERFS_SB(s)->s_qf_names[i] = NULL;
1085 /* Add options that are safe here */
1086 safe_mask |= 1 << REISERFS_SMALLTAIL;
1087 safe_mask |= 1 << REISERFS_LARGETAIL;
1088 safe_mask |= 1 << REISERFS_NO_BORDER;
1089 safe_mask |= 1 << REISERFS_NO_UNHASHED_RELOCATION;
1090 safe_mask |= 1 << REISERFS_HASHED_RELOCATION;
1091 safe_mask |= 1 << REISERFS_TEST4;
1092 safe_mask |= 1 << REISERFS_ATTRS;
1093 safe_mask |= 1 << REISERFS_XATTRS_USER;
1094 safe_mask |= 1 << REISERFS_POSIXACL;
1095 safe_mask |= 1 << REISERFS_BARRIER_FLUSH;
1096 safe_mask |= 1 << REISERFS_BARRIER_NONE;
1097 safe_mask |= 1 << REISERFS_ERROR_RO;
1098 safe_mask |= 1 << REISERFS_ERROR_CONTINUE;
1099 safe_mask |= 1 << REISERFS_ERROR_PANIC;
1101 /* Update the bitmask, taking care to keep
1102 * the bits we're not allowed to change here */
1103 REISERFS_SB(s)->s_mount_opt = (REISERFS_SB(s)->s_mount_opt & ~safe_mask) | (mount_options & safe_mask);
1105 if(commit_max_age != 0 && commit_max_age != (unsigned int)-1) {
1106 journal->j_max_commit_age = commit_max_age;
1107 journal->j_max_trans_age = commit_max_age;
1109 else if(commit_max_age == 0)
1111 /* 0 means restore defaults. */
1112 journal->j_max_commit_age = journal->j_default_max_commit_age;
1113 journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
1117 int rc = reiserfs_resize(s, blocks);
1122 if (*mount_flags & MS_RDONLY) {
1123 reiserfs_xattr_init (s, *mount_flags);
1124 /* remount read-only */
1125 if (s->s_flags & MS_RDONLY)
1126 /* it is read-only already */
1128 /* try to remount file system with read-only permissions */
1129 if (sb_umount_state(rs) == REISERFS_VALID_FS || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) {
1133 err = journal_begin(&th, s, 10) ;
1137 /* Mounting a rw partition read-only. */
1138 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
1139 set_sb_umount_state( rs, REISERFS_SB(s)->s_mount_state );
1140 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
1142 /* remount read-write */
1143 if (!(s->s_flags & MS_RDONLY)) {
1144 reiserfs_xattr_init (s, *mount_flags);
1145 return 0; /* We are read-write already */
1148 if (reiserfs_is_journal_aborted (journal))
1149 return journal->j_errno;
1151 handle_data_mode(s, mount_options);
1152 handle_barrier_mode(s, mount_options);
1153 REISERFS_SB(s)->s_mount_state = sb_umount_state(rs) ;
1154 s->s_flags &= ~MS_RDONLY ; /* now it is safe to call journal_begin */
1155 err = journal_begin(&th, s, 10) ;
1159 /* Mount a partition which is read-only, read-write */
1160 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
1161 REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
1162 s->s_flags &= ~MS_RDONLY;
1163 set_sb_umount_state( rs, REISERFS_ERROR_FS );
1164 /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */
1165 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
1166 REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS ;
1168 /* this will force a full flush of all journal lists */
1169 SB_JOURNAL(s)->j_must_wait = 1 ;
1170 err = journal_end(&th, s, 10) ;
1175 if (!( *mount_flags & MS_RDONLY ) ) {
1176 finish_unfinished( s );
1177 reiserfs_xattr_init (s, *mount_flags);
1183 /* load_bitmap_info_data - Sets up the reiserfs_bitmap_info structure from disk.
1184 * @sb - superblock for this filesystem
1185 * @bi - the bitmap info to be loaded. Requires that bi->bh is valid.
1187 * This routine counts how many free bits there are, finding the first zero
1188 * as a side effect. Could also be implemented as a loop of test_bit() calls, or
1189 * a loop of find_first_zero_bit() calls. This implementation is similar to
1190 * find_first_zero_bit(), but doesn't return after it finds the first bit.
1191 * Should only be called on fs mount, but should be fairly efficient anyways.
1193 * bi->first_zero_hint is considered unset if it == 0, since the bitmap itself
1194 * will * invariably occupt block 0 represented in the bitmap. The only
1195 * exception to this is when free_count also == 0, since there will be no
1196 * free blocks at all.
1199 static void load_bitmap_info_data (struct super_block *sb,
1200 struct reiserfs_bitmap_info *bi)
1202 unsigned long *cur = (unsigned long *)bi->bh->b_data;
1204 while ((char *)cur < (bi->bh->b_data + sb->s_blocksize)) {
1206 /* No need to scan if all 0's or all 1's.
1207 * Since we're only counting 0's, we can simply ignore all 1's */
1209 if (bi->first_zero_hint == 0) {
1210 bi->first_zero_hint = ((char *)cur - bi->bh->b_data) << 3;
1212 bi->free_count += sizeof(unsigned long)*8;
1213 } else if (*cur != ~0L) {
1215 for (b = 0; b < sizeof(unsigned long)*8; b++) {
1216 if (!reiserfs_test_le_bit (b, cur)) {
1218 if (bi->first_zero_hint == 0)
1219 bi->first_zero_hint =
1220 (((char *)cur - bi->bh->b_data) << 3) + b;
1227 #ifdef CONFIG_REISERFS_CHECK
1228 // This outputs a lot of unneded info on big FSes
1229 // reiserfs_warning ("bitmap loaded from block %d: %d free blocks",
1230 // bi->bh->b_blocknr, bi->free_count);
1234 static int read_bitmaps (struct super_block * s)
1238 SB_AP_BITMAP (s) = vmalloc (sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
1239 if (SB_AP_BITMAP (s) == 0)
1241 memset (SB_AP_BITMAP (s), 0, sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
1242 for (i = 0, bmap_nr = REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1;
1243 i < SB_BMAP_NR(s); i++, bmap_nr = s->s_blocksize * 8 * i) {
1244 SB_AP_BITMAP (s)[i].bh = sb_getblk(s, bmap_nr);
1245 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh))
1246 ll_rw_block(READ, 1, &SB_AP_BITMAP(s)[i].bh);
1248 for (i = 0; i < SB_BMAP_NR(s); i++) {
1249 wait_on_buffer(SB_AP_BITMAP (s)[i].bh);
1250 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
1251 reiserfs_warning(s,"sh-2029: reiserfs read_bitmaps: "
1252 "bitmap block (#%lu) reading failed",
1253 SB_AP_BITMAP(s)[i].bh->b_blocknr);
1254 for (i = 0; i < SB_BMAP_NR(s); i++)
1255 brelse(SB_AP_BITMAP(s)[i].bh);
1256 vfree(SB_AP_BITMAP(s));
1257 SB_AP_BITMAP(s) = NULL;
1260 load_bitmap_info_data (s, SB_AP_BITMAP (s) + i);
1265 static int read_old_bitmaps (struct super_block * s)
1268 struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK(s);
1269 int bmp1 = (REISERFS_OLD_DISK_OFFSET_IN_BYTES / s->s_blocksize) + 1; /* first of bitmap blocks */
1271 /* read true bitmap */
1272 SB_AP_BITMAP (s) = vmalloc (sizeof (struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
1273 if (SB_AP_BITMAP (s) == 0)
1276 memset (SB_AP_BITMAP (s), 0, sizeof (struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
1278 for (i = 0; i < sb_bmap_nr(rs); i ++) {
1279 SB_AP_BITMAP (s)[i].bh = sb_bread (s, bmp1 + i);
1280 if (!SB_AP_BITMAP (s)[i].bh)
1282 load_bitmap_info_data (s, SB_AP_BITMAP (s) + i);
1288 static int read_super_block (struct super_block * s, int offset)
1290 struct buffer_head * bh;
1291 struct reiserfs_super_block * rs;
1295 bh = sb_bread (s, offset / s->s_blocksize);
1297 reiserfs_warning (s, "sh-2006: read_super_block: "
1298 "bread failed (dev %s, block %lu, size %lu)",
1299 reiserfs_bdevname (s), offset / s->s_blocksize, s->s_blocksize);
1303 rs = (struct reiserfs_super_block *)bh->b_data;
1304 if (!is_any_reiserfs_magic_string (rs)) {
1310 // ok, reiserfs signature (old or new) found in at the given offset
1312 fs_blocksize = sb_blocksize(rs);
1314 sb_set_blocksize (s, fs_blocksize);
1316 bh = sb_bread (s, offset / s->s_blocksize);
1318 reiserfs_warning (s, "sh-2007: read_super_block: "
1319 "bread failed (dev %s, block %lu, size %lu)\n",
1320 reiserfs_bdevname (s), offset / s->s_blocksize, s->s_blocksize);
1324 rs = (struct reiserfs_super_block *)bh->b_data;
1325 if (sb_blocksize(rs) != s->s_blocksize) {
1326 reiserfs_warning (s, "sh-2011: read_super_block: "
1327 "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n",
1328 reiserfs_bdevname (s), (unsigned long long)bh->b_blocknr, s->s_blocksize);
1333 if ( rs->s_v1.s_root_block == -1 ) {
1335 reiserfs_warning (s, "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
1336 "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
1337 "get newer reiserfsprogs package");
1341 SB_BUFFER_WITH_SB (s) = bh;
1342 SB_DISK_SUPER_BLOCK (s) = rs;
1344 if (is_reiserfs_jr (rs)) {
1345 /* magic is of non-standard journal filesystem, look at s_version to
1346 find which format is in use */
1347 if (sb_version(rs) == REISERFS_VERSION_2)
1348 reiserfs_warning (s, "read_super_block: found reiserfs format \"3.6\""
1349 " with non-standard journal");
1350 else if (sb_version(rs) == REISERFS_VERSION_1)
1351 reiserfs_warning (s, "read_super_block: found reiserfs format \"3.5\""
1352 " with non-standard journal");
1354 reiserfs_warning (s, "sh-2012: read_super_block: found unknown "
1355 "format \"%u\" of reiserfs with non-standard magic",
1361 /* s_version of standard format may contain incorrect information,
1362 so we just look at the magic string */
1363 reiserfs_info (s, "found reiserfs format \"%s\" with standard journal\n",
1364 is_reiserfs_3_5 (rs) ? "3.5" : "3.6");
1366 s->s_op = &reiserfs_sops;
1367 s->s_export_op = &reiserfs_export_ops;
1369 s->s_qcop = &reiserfs_qctl_operations;
1370 s->dq_op = &reiserfs_quota_operations;
1373 /* new format is limited by the 32 bit wide i_blocks field, want to
1374 ** be one full block below that.
1376 s->s_maxbytes = (512LL << 32) - s->s_blocksize ;
1382 /* after journal replay, reread all bitmap and super blocks */
1383 static int reread_meta_blocks(struct super_block *s) {
1385 ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))) ;
1386 wait_on_buffer(SB_BUFFER_WITH_SB(s)) ;
1387 if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
1388 reiserfs_warning (s, "reread_meta_blocks, error reading the super") ;
1392 for (i = 0; i < SB_BMAP_NR(s) ; i++) {
1393 ll_rw_block(READ, 1, &(SB_AP_BITMAP(s)[i].bh)) ;
1394 wait_on_buffer(SB_AP_BITMAP(s)[i].bh) ;
1395 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
1396 reiserfs_warning (s, "reread_meta_blocks, error reading bitmap block number %d at %llu",
1397 i, (unsigned long long)SB_AP_BITMAP(s)[i].bh->b_blocknr) ;
1406 /////////////////////////////////////////////////////
1407 // hash detection stuff
1410 // if root directory is empty - we set default - Yura's - hash and
1412 // FIXME: we look for only one name in a directory. If tea and yura
1413 // bith have the same value - we ask user to send report to the
1415 static __u32 find_hash_out (struct super_block * s)
1418 struct inode * inode;
1420 INITIALIZE_PATH (path);
1421 struct reiserfs_dir_entry de;
1422 __u32 hash = DEFAULT_HASH;
1424 inode = s->s_root->d_inode;
1426 do { // Some serious "goto"-hater was there ;)
1427 u32 teahash, r5hash, yurahash;
1429 make_cpu_key (&key, inode, ~0, TYPE_DIRENTRY, 3);
1430 retval = search_by_entry_key (s, &key, &path, &de);
1431 if (retval == IO_ERROR) {
1435 if (retval == NAME_NOT_FOUND)
1437 set_de_name_and_namelen (&de);
1438 if (deh_offset( &(de.de_deh[de.de_entry_num]) ) == DOT_DOT_OFFSET) {
1439 /* allow override in this case */
1440 if (reiserfs_rupasov_hash(s)) {
1443 reiserfs_warning(s,"FS seems to be empty, autodetect "
1444 "is using the default hash");
1447 r5hash=GET_HASH_VALUE (r5_hash (de.de_name, de.de_namelen));
1448 teahash=GET_HASH_VALUE (keyed_hash (de.de_name, de.de_namelen));
1449 yurahash=GET_HASH_VALUE (yura_hash (de.de_name, de.de_namelen));
1450 if ( ( (teahash == r5hash) && (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash) ) ||
1451 ( (teahash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ||
1452 ( (r5hash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ) {
1453 reiserfs_warning(s,"Unable to automatically detect hash function. "
1454 "Please mount with -o hash={tea,rupasov,r5}",
1455 reiserfs_bdevname (s));
1459 if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == yurahash)
1461 else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == teahash)
1463 else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == r5hash)
1466 reiserfs_warning (s,"Unrecognised hash function");
1475 // finds out which hash names are sorted with
1476 static int what_hash (struct super_block * s)
1480 code = sb_hash_function_code(SB_DISK_SUPER_BLOCK(s));
1482 /* reiserfs_hash_detect() == true if any of the hash mount options
1483 ** were used. We must check them to make sure the user isn't
1484 ** using a bad hash value
1486 if (code == UNSET_HASH || reiserfs_hash_detect(s))
1487 code = find_hash_out (s);
1489 if (code != UNSET_HASH && reiserfs_hash_detect(s)) {
1490 /* detection has found the hash, and we must check against the
1493 if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
1494 reiserfs_warning (s, "Error, %s hash detected, "
1495 "unable to force rupasov hash", reiserfs_hashname(code)) ;
1497 } else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
1498 reiserfs_warning (s, "Error, %s hash detected, "
1499 "unable to force tea hash", reiserfs_hashname(code)) ;
1501 } else if (reiserfs_r5_hash(s) && code != R5_HASH) {
1502 reiserfs_warning (s, "Error, %s hash detected, "
1503 "unable to force r5 hash", reiserfs_hashname(code)) ;
1507 /* find_hash_out was not called or could not determine the hash */
1508 if (reiserfs_rupasov_hash(s)) {
1510 } else if (reiserfs_tea_hash(s)) {
1512 } else if (reiserfs_r5_hash(s)) {
1517 /* if we are mounted RW, and we have a new valid hash code, update
1520 if (code != UNSET_HASH &&
1521 !(s->s_flags & MS_RDONLY) &&
1522 code != sb_hash_function_code(SB_DISK_SUPER_BLOCK(s))) {
1523 set_sb_hash_function_code(SB_DISK_SUPER_BLOCK(s), code);
1528 // return pointer to appropriate function
1529 static hashf_t hash_function (struct super_block * s)
1531 switch (what_hash (s)) {
1533 reiserfs_info (s, "Using tea hash to sort names\n");
1536 reiserfs_info (s, "Using rupasov hash to sort names\n");
1539 reiserfs_info (s, "Using r5 hash to sort names\n");
1545 // this is used to set up correct value for old partitions
1546 static int function2code (hashf_t func)
1548 if (func == keyed_hash)
1550 if (func == yura_hash)
1552 if (func == r5_hash)
1555 BUG() ; // should never happen
1560 #define SWARN(silent, s, ...) \
1562 reiserfs_warning (s, __VA_ARGS__)
1564 static int reiserfs_fill_super (struct super_block * s, void * data, int silent)
1566 struct inode *root_inode;
1568 struct reiserfs_transaction_handle th ;
1570 unsigned long blocks;
1571 unsigned int commit_max_age = 0;
1572 int jinit_done = 0 ;
1573 struct reiserfs_iget_args args ;
1574 struct reiserfs_super_block * rs;
1576 struct reiserfs_sb_info *sbi;
1577 int errval = -EINVAL;
1579 sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
1585 memset (sbi, 0, sizeof (struct reiserfs_sb_info));
1586 /* Set default values for options: non-aggressive tails, RO on errors */
1587 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
1588 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
1589 /* no preallocation minimum, be smart in
1590 reiserfs_file_write instead */
1591 REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
1592 /* Preallocate by 16 blocks (17-1) at once */
1593 REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
1594 /* Initialize the rwsem for xattr dir */
1595 init_rwsem(&REISERFS_SB(s)->xattr_dir_sem);
1597 /* setup default block allocator options */
1598 reiserfs_init_alloc_options(s);
1601 if (reiserfs_parse_options (s, (char *) data, &(sbi->s_mount_opt), &blocks, &jdev_name, &commit_max_age) == 0) {
1606 SWARN (silent, s, "jmacd-7: reiserfs_fill_super: resize option "
1607 "for remount only");
1611 /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
1612 if (!read_super_block (s, REISERFS_OLD_DISK_OFFSET_IN_BYTES))
1614 /* try new format (64-th 1k block), which can contain reiserfs super block */
1615 else if (read_super_block (s, REISERFS_DISK_OFFSET_IN_BYTES)) {
1616 SWARN(silent, s, "sh-2021: reiserfs_fill_super: can not find reiserfs on %s", reiserfs_bdevname (s));
1620 rs = SB_DISK_SUPER_BLOCK (s);
1621 /* Let's do basic sanity check to verify that underlying device is not
1622 smaller than the filesystem. If the check fails then abort and scream,
1623 because bad stuff will happen otherwise. */
1624 if ( s->s_bdev && s->s_bdev->bd_inode && i_size_read(s->s_bdev->bd_inode) < sb_block_count(rs)*sb_blocksize(rs)) {
1625 SWARN (silent, s, "Filesystem on %s cannot be mounted because it is bigger than the device", reiserfs_bdevname(s));
1626 SWARN(silent, s, "You may need to run fsck or increase size of your LVM partition");
1627 SWARN(silent, s, "Or may be you forgot to reboot after fdisk when it told you to");
1631 sbi->s_mount_state = SB_REISERFS_STATE(s);
1632 sbi->s_mount_state = REISERFS_VALID_FS ;
1634 if (old_format ? read_old_bitmaps(s) : read_bitmaps(s)) {
1635 SWARN(silent, s, "jmacd-8: reiserfs_fill_super: unable to read bitmap");
1638 #ifdef CONFIG_REISERFS_CHECK
1639 SWARN (silent, s, "CONFIG_REISERFS_CHECK is set ON");
1640 SWARN (silent, s, "- it is slow mode for debugging.");
1643 /* make data=ordered the default */
1644 if (!reiserfs_data_log(s) && !reiserfs_data_ordered(s) &&
1645 !reiserfs_data_writeback(s))
1647 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_DATA_ORDERED);
1650 if (reiserfs_data_log(s)) {
1651 reiserfs_info (s, "using journaled data mode\n");
1652 } else if (reiserfs_data_ordered(s)) {
1653 reiserfs_info (s, "using ordered data mode\n");
1655 reiserfs_info (s, "using writeback data mode\n");
1657 if (reiserfs_barrier_flush(s)) {
1658 printk("reiserfs: using flush barriers\n");
1661 // set_device_ro(s->s_dev, 1) ;
1662 if( journal_init(s, jdev_name, old_format, commit_max_age) ) {
1663 SWARN(silent, s, "sh-2022: reiserfs_fill_super: unable to initialize journal space") ;
1666 jinit_done = 1 ; /* once this is set, journal_release must be called
1667 ** if we error out of the mount
1670 if (reread_meta_blocks(s)) {
1671 SWARN(silent, s, "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init") ;
1675 if (replay_only (s))
1678 if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
1679 SWARN(silent, s, "clm-7000: Detected readonly device, marking FS readonly") ;
1680 s->s_flags |= MS_RDONLY ;
1682 args.objectid = REISERFS_ROOT_OBJECTID ;
1683 args.dirid = REISERFS_ROOT_PARENT_OBJECTID ;
1684 root_inode = iget5_locked (s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
1686 SWARN(silent, s, "jmacd-10: reiserfs_fill_super: get root inode failed");
1690 if (root_inode->i_state & I_NEW) {
1691 reiserfs_read_locked_inode(root_inode, &args);
1692 unlock_new_inode(root_inode);
1695 s->s_root = d_alloc_root(root_inode);
1701 // define and initialize hash function
1702 sbi->s_hash_function = hash_function (s);
1703 if (sbi->s_hash_function == NULL) {
1709 if (is_reiserfs_3_5 (rs) || (is_reiserfs_jr (rs) && SB_VERSION (s) == REISERFS_VERSION_1))
1710 set_bit(REISERFS_3_5, &(sbi->s_properties));
1712 set_bit(REISERFS_3_6, &(sbi->s_properties));
1714 if (!(s->s_flags & MS_RDONLY)) {
1716 errval = journal_begin(&th, s, 1) ;
1722 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
1724 set_sb_umount_state( rs, REISERFS_ERROR_FS );
1725 set_sb_fs_state (rs, 0);
1727 if (old_format_only(s)) {
1728 /* filesystem of format 3.5 either with standard or non-standard
1730 if (convert_reiserfs (s)) {
1731 /* and -o conv is given */
1733 reiserfs_info (s,"converting 3.5 filesystem to the 3.6 format") ;
1735 if (is_reiserfs_3_5 (rs))
1736 /* put magic string of 3.6 format. 2.2 will not be able to
1737 mount this filesystem anymore */
1738 memcpy (rs->s_v1.s_magic, reiserfs_3_6_magic_string,
1739 sizeof (reiserfs_3_6_magic_string));
1741 set_sb_version(rs,REISERFS_VERSION_2);
1742 reiserfs_convert_objectid_map_v1(s) ;
1743 set_bit(REISERFS_3_6, &(sbi->s_properties));
1744 clear_bit(REISERFS_3_5, &(sbi->s_properties));
1745 } else if (!silent){
1746 reiserfs_info (s, "using 3.5.x disk format\n") ;
1750 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
1751 errval = journal_end(&th, s, 1) ;
1758 if ((errval = reiserfs_xattr_init (s, s->s_flags))) {
1764 /* look for files which were to be removed in previous session */
1765 finish_unfinished (s);
1767 if ( old_format_only(s) && !silent) {
1768 reiserfs_info (s, "using 3.5.x disk format\n") ;
1771 if ((errval = reiserfs_xattr_init (s, s->s_flags))) {
1777 // mark hash in super block: it could be unset. overwrite should be ok
1778 set_sb_hash_function_code( rs, function2code(sbi->s_hash_function ) );
1782 reiserfs_proc_info_init( s );
1784 init_waitqueue_head (&(sbi->s_wait));
1785 spin_lock_init(&sbi->bitmap_lock);
1790 if (jinit_done) { /* kill the commit thread, free journal ram */
1791 journal_release_error(NULL, s) ;
1793 if (SB_DISK_SUPER_BLOCK (s)) {
1794 for (j = 0; j < SB_BMAP_NR (s); j ++) {
1795 if (SB_AP_BITMAP (s))
1796 brelse (SB_AP_BITMAP (s)[j].bh);
1798 if (SB_AP_BITMAP (s))
1799 vfree (SB_AP_BITMAP (s));
1801 if (SB_BUFFER_WITH_SB (s))
1802 brelse(SB_BUFFER_WITH_SB (s));
1804 for (j = 0; j < MAXQUOTAS; j++) {
1805 if (sbi->s_qf_names[j])
1806 kfree(sbi->s_qf_names[j]);
1813 s->s_fs_info = NULL;
1818 static int reiserfs_statfs (struct super_block * s, struct kstatfs * buf)
1820 struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
1822 buf->f_namelen = (REISERFS_MAX_NAME (s->s_blocksize));
1823 buf->f_bfree = sb_free_blocks(rs);
1824 buf->f_bavail = buf->f_bfree;
1825 buf->f_blocks = sb_block_count(rs) - sb_bmap_nr(rs) - 1;
1826 buf->f_bsize = s->s_blocksize;
1827 /* changed to accommodate gcc folks.*/
1828 buf->f_type = REISERFS_SUPER_MAGIC;
1833 static int reiserfs_dquot_initialize(struct inode *inode, int type)
1835 struct reiserfs_transaction_handle th;
1838 /* We may create quota structure so we need to reserve enough blocks */
1839 reiserfs_write_lock(inode->i_sb);
1840 journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
1841 ret = dquot_initialize(inode, type);
1842 journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
1843 reiserfs_write_unlock(inode->i_sb);
1847 static int reiserfs_dquot_drop(struct inode *inode)
1849 struct reiserfs_transaction_handle th;
1852 /* We may delete quota structure so we need to reserve enough blocks */
1853 reiserfs_write_lock(inode->i_sb);
1854 journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
1855 ret = dquot_drop(inode);
1856 journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
1857 reiserfs_write_unlock(inode->i_sb);
1861 static int reiserfs_write_dquot(struct dquot *dquot)
1863 struct reiserfs_transaction_handle th;
1866 reiserfs_write_lock(dquot->dq_sb);
1867 journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS);
1868 ret = dquot_commit(dquot);
1869 journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS);
1870 reiserfs_write_unlock(dquot->dq_sb);
1874 static int reiserfs_acquire_dquot(struct dquot *dquot)
1876 struct reiserfs_transaction_handle th;
1879 reiserfs_write_lock(dquot->dq_sb);
1880 journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
1881 ret = dquot_acquire(dquot);
1882 journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
1883 reiserfs_write_unlock(dquot->dq_sb);
1887 static int reiserfs_release_dquot(struct dquot *dquot)
1889 struct reiserfs_transaction_handle th;
1892 reiserfs_write_lock(dquot->dq_sb);
1893 journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
1894 ret = dquot_release(dquot);
1895 journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
1896 reiserfs_write_unlock(dquot->dq_sb);
1900 static int reiserfs_mark_dquot_dirty(struct dquot *dquot)
1902 /* Are we journalling quotas? */
1903 if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
1904 REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
1905 dquot_mark_dquot_dirty(dquot);
1906 return reiserfs_write_dquot(dquot);
1909 return dquot_mark_dquot_dirty(dquot);
1912 static int reiserfs_write_info(struct super_block *sb, int type)
1914 struct reiserfs_transaction_handle th;
1917 /* Data block + inode block */
1918 reiserfs_write_lock(sb);
1919 journal_begin(&th, sb, 2);
1920 ret = dquot_commit_info(sb, type);
1921 journal_end(&th, sb, 2);
1922 reiserfs_write_unlock(sb);
1927 * Turn on quotas during mount time - we need to find
1928 * the quota file and such...
1930 static int reiserfs_quota_on_mount(struct super_block *sb, int type)
1933 struct dentry *dentry;
1934 struct qstr name = { .name = REISERFS_SB(sb)->s_qf_names[type],
1936 .len = strlen(REISERFS_SB(sb)->s_qf_names[type])};
1938 dentry = lookup_hash(&name, sb->s_root);
1940 return PTR_ERR(dentry);
1941 err = vfs_quota_on_mount(type, REISERFS_SB(sb)->s_jquota_fmt, dentry);
1942 /* Now invalidate and put the dentry - quota got its own reference
1943 * to inode and dentry has at least wrong hash so we had better
1945 d_invalidate(dentry);
1951 * Standard function to be called on quota_on
1953 static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
1956 struct nameidata nd;
1958 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
1961 /* Quotafile not on the same filesystem? */
1962 if (nd.mnt->mnt_sb != sb) {
1966 /* We must not pack tails for quota files on reiserfs for quota IO to work */
1967 if (!REISERFS_I(nd.dentry->d_inode)->i_flags & i_nopack_mask) {
1968 reiserfs_warning(sb, "reiserfs: Quota file must have tail packing disabled.");
1972 /* Not journalling quota? No more tests needed... */
1973 if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
1974 !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
1976 return vfs_quota_on(sb, type, format_id, path);
1978 /* Quotafile not of fs root? */
1979 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
1980 reiserfs_warning(sb, "reiserfs: Quota file not on filesystem root. "
1981 "Journalled quota will not work.");
1983 return vfs_quota_on(sb, type, format_id, path);
1986 /* Read data from quotafile - avoid pagecache and such because we cannot afford
1987 * acquiring the locks... As quota files are never truncated and quota code
1988 * itself serializes the operations (and noone else should touch the files)
1989 * we don't have to be afraid of races */
1990 static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data,
1991 size_t len, loff_t off)
1993 struct inode *inode = sb_dqopt(sb)->files[type];
1994 unsigned long blk = off >> sb->s_blocksize_bits;
1995 int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
1997 struct buffer_head tmp_bh, *bh;
1998 loff_t i_size = i_size_read(inode);
2002 if (off+len > i_size)
2005 while (toread > 0) {
2006 tocopy = sb->s_blocksize - offset < toread ? sb->s_blocksize - offset : toread;
2008 /* Quota files are without tails so we can safely use this function */
2009 reiserfs_write_lock(sb);
2010 err = reiserfs_get_block(inode, blk, &tmp_bh, 0);
2011 reiserfs_write_unlock(sb);
2014 if (!buffer_mapped(&tmp_bh)) /* A hole? */
2015 memset(data, 0, tocopy);
2017 bh = sb_bread(sb, tmp_bh.b_blocknr);
2020 memcpy(data, bh->b_data+offset, tocopy);
2031 /* Write to quotafile (we know the transaction is already started and has
2032 * enough credits) */
2033 static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2034 const char *data, size_t len, loff_t off)
2036 struct inode *inode = sb_dqopt(sb)->files[type];
2037 unsigned long blk = off >> sb->s_blocksize_bits;
2038 int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
2039 int journal_quota = REISERFS_SB(sb)->s_qf_names[type] != NULL;
2040 size_t towrite = len;
2041 struct buffer_head tmp_bh, *bh;
2043 down(&inode->i_sem);
2044 while (towrite > 0) {
2045 tocopy = sb->s_blocksize - offset < towrite ?
2046 sb->s_blocksize - offset : towrite;
2048 err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE);
2051 if (offset || tocopy != sb->s_blocksize)
2052 bh = sb_bread(sb, tmp_bh.b_blocknr);
2054 bh = sb_getblk(sb, tmp_bh.b_blocknr);
2060 memcpy(bh->b_data+offset, data, tocopy);
2061 flush_dcache_page(bh->b_page);
2062 set_buffer_uptodate(bh);
2064 reiserfs_prepare_for_journal(sb, bh, 1);
2065 journal_mark_dirty(current->journal_info, sb, bh);
2067 reiserfs_add_ordered_list(inode, bh);
2077 if (inode->i_size < off+len-towrite)
2078 i_size_write(inode, off+len-towrite);
2080 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2081 mark_inode_dirty(inode);
2083 return len - towrite;
2088 static struct super_block*
2089 get_super_block (struct file_system_type *fs_type, int flags,
2090 const char *dev_name, void *data)
2092 return get_sb_bdev(fs_type, flags, dev_name, data, reiserfs_fill_super);
2096 init_reiserfs_fs ( void )
2100 if ((ret = init_inodecache ())) {
2104 if ((ret = reiserfs_xattr_register_handlers ()))
2105 goto failed_reiserfs_xattr_register_handlers;
2107 reiserfs_proc_info_global_init ();
2108 reiserfs_proc_register_global ("version", reiserfs_global_version_in_proc);
2110 ret = register_filesystem (& reiserfs_fs_type);
2116 reiserfs_xattr_unregister_handlers ();
2118 failed_reiserfs_xattr_register_handlers:
2119 reiserfs_proc_unregister_global ("version");
2120 reiserfs_proc_info_global_done ();
2121 destroy_inodecache ();
2127 exit_reiserfs_fs ( void )
2129 reiserfs_xattr_unregister_handlers ();
2130 reiserfs_proc_unregister_global ("version");
2131 reiserfs_proc_info_global_done ();
2132 unregister_filesystem (& reiserfs_fs_type);
2133 destroy_inodecache ();
2136 struct file_system_type reiserfs_fs_type = {
2137 .owner = THIS_MODULE,
2139 .get_sb = get_super_block,
2140 .kill_sb = kill_block_super,
2141 .fs_flags = FS_REQUIRES_DEV,
2144 MODULE_DESCRIPTION ("ReiserFS journaled filesystem");
2145 MODULE_AUTHOR ("Hans Reiser <reiser@namesys.com>");
2146 MODULE_LICENSE ("GPL");
2148 module_init (init_reiserfs_fs);
2149 module_exit (exit_reiserfs_fs);