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 in_core_key MAX_IN_CORE_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.k_dir_id = ~0U;
168 max_cpu_key.on_disk_key.k_objectid = ~0U;
169 set_cpu_key_k_offset (&max_cpu_key, ~0U);
170 max_cpu_key.key_length = 3;
173 /* Needed for iput() to work correctly and not trash data */
174 if (s->s_flags & MS_ACTIVE) {
178 s->s_flags |= MS_ACTIVE;
180 /* Turn on quotas so that they are updated correctly */
181 for (i = 0; i < MAXQUOTAS; i++) {
182 if (REISERFS_SB(s)->s_qf_names[i]) {
183 int ret = reiserfs_quota_on_mount(s, i);
185 reiserfs_warning(s, "reiserfs: cannot turn on journalled quota: error %d", ret);
191 REISERFS_SB(s)->s_is_unlinked_ok = 1;
193 retval = search_item (s, &max_cpu_key, &path);
194 if (retval != ITEM_NOT_FOUND) {
195 reiserfs_warning (s, "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)) {
203 reiserfs_warning (s, "vs-2060: finish_unfinished: wrong position found");
207 ih = B_N_PITEM_HEAD (bh, item_pos);
209 if (le32_to_cpu (ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID)
210 /* there are no "save" links anymore */
213 save_link_key = ih->ih_key;
214 if (is_indirect_le_ih (ih))
219 /* reiserfs_iget needs k_dirid and k_objectid only */
220 item = B_I_PITEM (bh, ih);
221 obj_key.on_disk_key.k_dir_id = le32_to_cpu (*(__le32 *)item);
222 obj_key.on_disk_key.k_objectid = le32_to_cpu (ih->ih_key.k_objectid);
223 obj_key.on_disk_key.k_offset = 0;
224 obj_key.on_disk_key.k_type = 0;
228 inode = reiserfs_iget (s, &obj_key);
230 /* the unlink almost completed, it just did not manage to remove
231 "save" link and release objectid */
232 reiserfs_warning (s, "vs-2180: finish_unfinished: iget failed for %K",
234 retval = remove_save_link_only (s, &save_link_key, 1);
238 if (!truncate && inode->i_nlink) {
239 /* file is not unlinked */
240 reiserfs_warning (s, "vs-2185: finish_unfinished: file %K is not unlinked",
242 retval = remove_save_link_only (s, &save_link_key, 0);
247 if (truncate && S_ISDIR (inode->i_mode) ) {
248 /* We got a truncate request for a dir which is impossible.
249 The only imaginable way is to execute unfinished truncate request
250 then boot into old kernel, remove the file and create dir with
252 reiserfs_warning(s, "green-2101: impossible truncate on a directory %k. Please report", INODE_PKEY (inode));
253 retval = remove_save_link_only (s, &save_link_key, 0);
260 REISERFS_I(inode) -> i_flags |= i_link_saved_truncate_mask;
261 /* not completed truncate found. New size was committed together
263 reiserfs_info (s, "Truncating %k to %Ld ..",
264 INODE_PKEY (inode), inode->i_size);
265 reiserfs_truncate_file (inode, 0/*don't update modification time*/);
266 retval = remove_save_link (inode, truncate);
268 REISERFS_I(inode) -> i_flags |= i_link_saved_unlink_mask;
269 /* not completed unlink (rmdir) found */
270 reiserfs_info (s, "Removing %k..", INODE_PKEY (inode));
271 /* removal gets completed in iput */
279 REISERFS_SB(s)->s_is_unlinked_ok = 0;
282 /* Turn quotas off */
283 for (i = 0; i < MAXQUOTAS; i++) {
284 if (sb_dqopt(s)->files[i])
285 vfs_quota_off_mount(s, i);
288 /* Restore the flag back */
289 s->s_flags &= ~MS_ACTIVE;
293 reiserfs_info (s, "There were %d uncompleted unlinks/truncates. "
294 "Completed\n", done);
298 /* to protect file being unlinked from getting lost we "safe" link files
299 being unlinked. This link will be deleted in the same transaction with last
300 item of file. mounting the filesytem we scan all these links and remove
301 files which almost got lost */
302 void add_save_link (struct reiserfs_transaction_handle * th,
303 struct inode * inode, int truncate)
305 INITIALIZE_PATH (path);
311 BUG_ON (!th->t_trans_id);
313 /* file can only get one "save link" of each kind */
315 ( REISERFS_I(inode) -> i_flags & i_link_saved_truncate_mask ),
316 "saved link already exists for truncated inode %lx",
317 ( long ) inode -> i_ino );
319 ( REISERFS_I(inode) -> i_flags & i_link_saved_unlink_mask ),
320 "saved link already exists for unlinked inode %lx",
321 ( long ) inode -> i_ino );
323 /* setup key of "save" link */
324 key.version = KEY_FORMAT_3_5;
325 key.on_disk_key.k_dir_id = MAX_KEY_OBJECTID;
326 key.on_disk_key.k_objectid = inode->i_ino;
328 /* unlink, rmdir, rename */
329 set_cpu_key_k_offset (&key, 1 + inode->i_sb->s_blocksize);
330 set_cpu_key_k_type (&key, TYPE_DIRECT);
332 /* item head of "safe" link */
333 make_le_item_head (&ih, &key, key.version, 1 + inode->i_sb->s_blocksize, TYPE_DIRECT,
334 4/*length*/, 0xffff/*free space*/);
337 if (S_ISDIR (inode->i_mode))
338 reiserfs_warning(inode->i_sb, "green-2102: Adding a truncate savelink for a directory %k! Please report", INODE_PKEY(inode));
339 set_cpu_key_k_offset (&key, 1);
340 set_cpu_key_k_type (&key, TYPE_INDIRECT);
342 /* item head of "safe" link */
343 make_le_item_head (&ih, &key, key.version, 1, TYPE_INDIRECT,
344 4/*length*/, 0/*free space*/);
348 /* look for its place in the tree */
349 retval = search_item (inode->i_sb, &key, &path);
350 if (retval != ITEM_NOT_FOUND) {
351 if ( retval != -ENOSPC )
352 reiserfs_warning (inode->i_sb, "vs-2100: add_save_link:"
353 "search_by_key (%K) returned %d", &key, retval);
358 /* body of "save" link */
359 link = INODE_PKEY (inode)->k_dir_id;
361 /* put "save" link inot tree, don't charge quota to anyone */
362 retval = reiserfs_insert_item (th, &path, &key, &ih, NULL, (char *)&link);
364 if (retval != -ENOSPC)
365 reiserfs_warning (inode->i_sb, "vs-2120: add_save_link: insert_item returned %d",
369 REISERFS_I(inode) -> i_flags |= i_link_saved_truncate_mask;
371 REISERFS_I(inode) -> i_flags |= i_link_saved_unlink_mask;
376 /* this opens transaction unlike add_save_link */
377 int remove_save_link (struct inode * inode, int truncate)
379 struct reiserfs_transaction_handle th;
380 struct reiserfs_key key;
383 /* we are going to do one balancing only */
384 err = journal_begin (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
388 /* setup key of "save" link */
389 key.k_dir_id = cpu_to_le32 (MAX_KEY_OBJECTID);
390 key.k_objectid = INODE_PKEY (inode)->k_objectid;
392 /* unlink, rmdir, rename */
393 set_le_key_k_offset (KEY_FORMAT_3_5, &key,
394 1 + inode->i_sb->s_blocksize);
395 set_le_key_k_type (KEY_FORMAT_3_5, &key, TYPE_DIRECT);
398 set_le_key_k_offset (KEY_FORMAT_3_5, &key, 1);
399 set_le_key_k_type (KEY_FORMAT_3_5, &key, TYPE_INDIRECT);
403 ( REISERFS_I(inode) -> i_flags & i_link_saved_truncate_mask ) ) ||
405 ( REISERFS_I(inode) -> i_flags & i_link_saved_unlink_mask ) ) )
406 /* don't take quota bytes from anywhere */
407 reiserfs_delete_solid_item (&th, NULL, &key);
409 reiserfs_release_objectid (&th, inode->i_ino);
410 REISERFS_I(inode) -> i_flags &= ~i_link_saved_unlink_mask;
412 REISERFS_I(inode) -> i_flags &= ~i_link_saved_truncate_mask;
414 return journal_end (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
418 static void reiserfs_put_super (struct super_block * s)
421 struct reiserfs_transaction_handle th ;
424 if (REISERFS_SB(s)->xattr_root) {
425 d_invalidate (REISERFS_SB(s)->xattr_root);
426 dput (REISERFS_SB(s)->xattr_root);
429 if (REISERFS_SB(s)->priv_root) {
430 d_invalidate (REISERFS_SB(s)->priv_root);
431 dput (REISERFS_SB(s)->priv_root);
434 /* change file system state to current state if it was mounted with read-write permissions */
435 if (!(s->s_flags & MS_RDONLY)) {
436 if (!journal_begin(&th, s, 10)) {
437 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
438 set_sb_umount_state( SB_DISK_SUPER_BLOCK(s), REISERFS_SB(s)->s_mount_state );
439 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
443 /* note, journal_release checks for readonly mount, and can decide not
444 ** to do a journal_end
446 journal_release(&th, s) ;
448 for (i = 0; i < SB_BMAP_NR (s); i ++)
449 brelse (SB_AP_BITMAP (s)[i].bh);
451 vfree (SB_AP_BITMAP (s));
453 brelse (SB_BUFFER_WITH_SB (s));
455 print_statistics (s);
457 if (REISERFS_SB(s)->s_kmallocs != 0) {
458 reiserfs_warning (s, "vs-2004: reiserfs_put_super: allocated memory left %d",
459 REISERFS_SB(s)->s_kmallocs);
462 if (REISERFS_SB(s)->reserved_blocks != 0) {
463 reiserfs_warning (s, "green-2005: reiserfs_put_super: reserved blocks left %d",
464 REISERFS_SB(s)->reserved_blocks);
467 reiserfs_proc_info_done( s );
475 static kmem_cache_t * reiserfs_inode_cachep;
477 static struct inode *reiserfs_alloc_inode(struct super_block *sb)
479 struct reiserfs_inode_info *ei;
480 ei = (struct reiserfs_inode_info *)kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL);
483 return &ei->vfs_inode;
486 static void reiserfs_destroy_inode(struct inode *inode)
488 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
491 static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
493 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *) foo;
495 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
496 SLAB_CTOR_CONSTRUCTOR) {
497 INIT_LIST_HEAD(&ei->i_prealloc_list) ;
498 inode_init_once(&ei->vfs_inode);
499 ei->i_acl_access = NULL;
500 ei->i_acl_default = NULL;
504 static int init_inodecache(void)
506 reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache",
507 sizeof(struct reiserfs_inode_info),
508 0, SLAB_RECLAIM_ACCOUNT,
510 if (reiserfs_inode_cachep == NULL)
515 static void destroy_inodecache(void)
517 if (kmem_cache_destroy(reiserfs_inode_cachep))
518 reiserfs_warning (NULL, "reiserfs_inode_cache: not all structures were freed");
521 /* we don't mark inodes dirty, we just log them */
522 static void reiserfs_dirty_inode (struct inode * inode) {
523 struct reiserfs_transaction_handle th ;
526 if (inode->i_sb->s_flags & MS_RDONLY) {
527 reiserfs_warning(inode->i_sb, "clm-6006: writing inode %lu on readonly FS",
531 reiserfs_write_lock(inode->i_sb);
533 /* this is really only used for atime updates, so they don't have
534 ** to be included in O_SYNC or fsync
536 err = journal_begin(&th, inode->i_sb, 1) ;
538 reiserfs_write_unlock (inode->i_sb);
541 reiserfs_update_sd (&th, inode);
542 journal_end(&th, inode->i_sb, 1) ;
543 reiserfs_write_unlock(inode->i_sb);
546 static void reiserfs_clear_inode (struct inode *inode)
548 struct posix_acl *acl;
550 acl = REISERFS_I(inode)->i_acl_access;
551 if (acl && !IS_ERR (acl))
552 posix_acl_release (acl);
553 REISERFS_I(inode)->i_acl_access = NULL;
555 acl = REISERFS_I(inode)->i_acl_default;
556 if (acl && !IS_ERR (acl))
557 posix_acl_release (acl);
558 REISERFS_I(inode)->i_acl_default = NULL;
562 static ssize_t reiserfs_quota_write(struct super_block *, int, const char *, size_t, loff_t);
563 static ssize_t reiserfs_quota_read(struct super_block *, int, char *, size_t, loff_t);
566 static struct super_operations reiserfs_sops =
568 .alloc_inode = reiserfs_alloc_inode,
569 .destroy_inode = reiserfs_destroy_inode,
570 .write_inode = reiserfs_write_inode,
571 .dirty_inode = reiserfs_dirty_inode,
572 .delete_inode = reiserfs_delete_inode,
573 .clear_inode = reiserfs_clear_inode,
574 .put_super = reiserfs_put_super,
575 .write_super = reiserfs_write_super,
576 .sync_fs = reiserfs_sync_fs,
577 .write_super_lockfs = reiserfs_write_super_lockfs,
578 .unlockfs = reiserfs_unlockfs,
579 .statfs = reiserfs_statfs,
580 .remount_fs = reiserfs_remount,
582 .quota_read = reiserfs_quota_read,
583 .quota_write = reiserfs_quota_write,
588 #define QTYPE2NAME(t) ((t)==USRQUOTA?"user":"group")
590 static int reiserfs_dquot_initialize(struct inode *, int);
591 static int reiserfs_dquot_drop(struct inode *);
592 static int reiserfs_write_dquot(struct dquot *);
593 static int reiserfs_acquire_dquot(struct dquot *);
594 static int reiserfs_release_dquot(struct dquot *);
595 static int reiserfs_mark_dquot_dirty(struct dquot *);
596 static int reiserfs_write_info(struct super_block *, int);
597 static int reiserfs_quota_on(struct super_block *, int, int, char *);
599 static struct dquot_operations reiserfs_quota_operations =
601 .initialize = reiserfs_dquot_initialize,
602 .drop = reiserfs_dquot_drop,
603 .alloc_space = dquot_alloc_space,
604 .alloc_inode = dquot_alloc_inode,
605 .free_space = dquot_free_space,
606 .free_inode = dquot_free_inode,
607 .transfer = dquot_transfer,
608 .write_dquot = reiserfs_write_dquot,
609 .acquire_dquot = reiserfs_acquire_dquot,
610 .release_dquot = reiserfs_release_dquot,
611 .mark_dirty = reiserfs_mark_dquot_dirty,
612 .write_info = reiserfs_write_info,
615 static struct quotactl_ops reiserfs_qctl_operations =
617 .quota_on = reiserfs_quota_on,
618 .quota_off = vfs_quota_off,
619 .quota_sync = vfs_quota_sync,
620 .get_info = vfs_get_dqinfo,
621 .set_info = vfs_set_dqinfo,
622 .get_dqblk = vfs_get_dqblk,
623 .set_dqblk = vfs_set_dqblk,
627 static struct export_operations reiserfs_export_ops = {
628 .encode_fh = reiserfs_encode_fh,
629 .decode_fh = reiserfs_decode_fh,
630 .get_parent = reiserfs_get_parent,
631 .get_dentry = reiserfs_get_dentry,
634 /* this struct is used in reiserfs_getopt () for containing the value for those
635 mount options that have values rather than being toggles. */
638 int setmask; /* bitmask which is to set on mount_options bitmask when this
639 value is found, 0 is no bits are to be changed. */
640 int clrmask; /* bitmask which is to clear on mount_options bitmask when this
641 value is found, 0 is no bits are to be changed. This is
642 applied BEFORE setmask */
645 /* Set this bit in arg_required to allow empty arguments */
646 #define REISERFS_OPT_ALLOWEMPTY 31
648 /* this struct is used in reiserfs_getopt() for describing the set of reiserfs
652 int arg_required; /* 0 if argument is not required, not 0 otherwise */
653 const arg_desc_t * values; /* list of values accepted by an option */
654 int setmask; /* bitmask which is to set on mount_options bitmask when this
655 value is found, 0 is no bits are to be changed. */
656 int clrmask; /* bitmask which is to clear on mount_options bitmask when this
657 value is found, 0 is no bits are to be changed. This is
658 applied BEFORE setmask */
661 /* possible values for -o data= */
662 static const arg_desc_t logging_mode[] = {
663 {"ordered", 1<<REISERFS_DATA_ORDERED, (1<<REISERFS_DATA_LOG|1<<REISERFS_DATA_WRITEBACK)},
664 {"journal", 1<<REISERFS_DATA_LOG, (1<<REISERFS_DATA_ORDERED|1<<REISERFS_DATA_WRITEBACK)},
665 {"writeback", 1<<REISERFS_DATA_WRITEBACK, (1<<REISERFS_DATA_ORDERED|1<<REISERFS_DATA_LOG)},
669 /* possible values for -o barrier= */
670 static const arg_desc_t barrier_mode[] = {
671 {"none", 1<<REISERFS_BARRIER_NONE, 1<<REISERFS_BARRIER_FLUSH},
672 {"flush", 1<<REISERFS_BARRIER_FLUSH, 1<<REISERFS_BARRIER_NONE},
676 /* possible values for "-o block-allocator=" and bits which are to be set in
677 s_mount_opt of reiserfs specific part of in-core super block */
678 static const arg_desc_t balloc[] = {
679 {"noborder", 1<<REISERFS_NO_BORDER, 0},
680 {"border", 0, 1<<REISERFS_NO_BORDER},
681 {"no_unhashed_relocation", 1<<REISERFS_NO_UNHASHED_RELOCATION, 0},
682 {"hashed_relocation", 1<<REISERFS_HASHED_RELOCATION, 0},
683 {"test4", 1<<REISERFS_TEST4, 0},
684 {"notest4", 0, 1<<REISERFS_TEST4},
688 static const arg_desc_t tails[] = {
689 {"on", 1<<REISERFS_LARGETAIL, 1<<REISERFS_SMALLTAIL},
690 {"off", 0, (1<<REISERFS_LARGETAIL)|(1<<REISERFS_SMALLTAIL)},
691 {"small", 1<<REISERFS_SMALLTAIL, 1<<REISERFS_LARGETAIL},
695 static const arg_desc_t error_actions[] = {
696 {"panic", 1 << REISERFS_ERROR_PANIC,
697 (1 << REISERFS_ERROR_RO | 1 << REISERFS_ERROR_CONTINUE)},
698 {"ro-remount", 1 << REISERFS_ERROR_RO,
699 (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_CONTINUE)},
700 #ifdef REISERFS_JOURNAL_ERROR_ALLOWS_NO_LOG
701 {"continue", 1 << REISERFS_ERROR_CONTINUE,
702 (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_RO)},
707 int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 128k.
708 There might be broken applications that are
709 confused by this. Use nolargeio mount option
710 to get usual i/o size = PAGE_SIZE.
713 /* proceed only one option from a list *cur - string containing of mount options
714 opts - array of options which are accepted
715 opt_arg - if option is found and requires an argument and if it is specifed
716 in the input - pointer to the argument is stored here
717 bit_flags - if option requires to set a certain bit - it is set here
718 return -1 if unknown option is found, opt->arg_required otherwise */
719 static int reiserfs_getopt ( struct super_block * s, char ** cur, opt_desc_t * opts, char ** opt_arg,
720 unsigned long * bit_flags)
729 const opt_desc_t * opt;
730 const arg_desc_t * arg;
735 /* assume argument cannot contain commas */
736 *cur = strchr (p, ',');
742 if ( !strncmp (p, "alloc=", 6) ) {
743 /* Ugly special case, probably we should redo options parser so that
744 it can understand several arguments for some options, also so that
745 it can fill several bitfields with option values. */
746 if ( reiserfs_parse_alloc_options( s, p + 6) ) {
754 /* for every option in the list */
755 for (opt = opts; opt->option_name; opt ++) {
756 if (!strncmp (p, opt->option_name, strlen (opt->option_name))) {
758 if (opt->clrmask == (1 << REISERFS_UNSUPPORTED_OPT))
759 reiserfs_warning (s, "%s not supported.", p);
761 *bit_flags &= ~opt->clrmask;
762 if (opt->setmask == (1 << REISERFS_UNSUPPORTED_OPT))
763 reiserfs_warning (s, "%s not supported.", p);
765 *bit_flags |= opt->setmask;
770 if (!opt->option_name) {
771 reiserfs_warning (s, "unknown mount option \"%s\"", p);
775 p += strlen (opt->option_name);
778 if (!opt->arg_required) {
779 reiserfs_warning (s, "the option \"%s\" does not require an argument",
786 if (opt->arg_required) {
787 reiserfs_warning (s, "the option \"%s\" requires an argument", opt->option_name);
792 reiserfs_warning (s, "head of option \"%s\" is only correct", opt->option_name);
796 /* move to the argument, or to next option if argument is not required */
799 if ( opt->arg_required && !(opt->arg_required & (1<<REISERFS_OPT_ALLOWEMPTY)) && !strlen (p) ) {
800 /* this catches "option=," if not allowed */
801 reiserfs_warning (s, "empty argument for \"%s\"", opt->option_name);
806 /* *=NULLopt_arg contains pointer to argument */
808 return opt->arg_required & ~(1<<REISERFS_OPT_ALLOWEMPTY);
811 /* values possible for this option are listed in opt->values */
812 for (arg = opt->values; arg->value; arg ++) {
813 if (!strcmp (p, arg->value)) {
815 *bit_flags &= ~arg->clrmask;
816 *bit_flags |= arg->setmask;
818 return opt->arg_required;
822 reiserfs_warning (s, "bad value \"%s\" for option \"%s\"", p, opt->option_name);
826 /* returns 0 if something is wrong in option string, 1 - otherwise */
827 static int reiserfs_parse_options (struct super_block * s, char * options, /* string given via mount's -o */
828 unsigned long * mount_options,
829 /* after the parsing phase, contains the
830 collection of bitflags defining what
831 mount options were selected. */
832 unsigned long * blocks, /* strtol-ed from NNN of resize=NNN */
834 unsigned int * commit_max_age)
839 opt_desc_t opts[] = {
840 /* Compatibility stuff, so that -o notail for old setups still work */
841 {"tails", .arg_required = 't', .values = tails},
842 {"notail", .clrmask = (1<<REISERFS_LARGETAIL)|(1<<REISERFS_SMALLTAIL)},
843 {"conv", .setmask = 1<<REISERFS_CONVERT},
844 {"attrs", .setmask = 1<<REISERFS_ATTRS},
845 {"noattrs", .clrmask = 1<<REISERFS_ATTRS},
846 #ifdef CONFIG_REISERFS_FS_XATTR
847 {"user_xattr", .setmask = 1<<REISERFS_XATTRS_USER},
848 {"nouser_xattr",.clrmask = 1<<REISERFS_XATTRS_USER},
850 {"user_xattr", .setmask = 1<<REISERFS_UNSUPPORTED_OPT},
851 {"nouser_xattr",.clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
853 {"tagxid", .setmask = 1<<REISERFS_TAGXID},
854 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
855 {"acl", .setmask = 1<<REISERFS_POSIXACL},
856 {"noacl", .clrmask = 1<<REISERFS_POSIXACL},
858 {"acl", .setmask = 1<<REISERFS_UNSUPPORTED_OPT},
859 {"noacl", .clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
861 {"nolog",}, /* This is unsupported */
862 {"replayonly", .setmask = 1<<REPLAYONLY},
863 {"block-allocator", .arg_required = 'a', .values = balloc},
864 {"data", .arg_required = 'd', .values = logging_mode},
865 {"barrier", .arg_required = 'b', .values = barrier_mode},
866 {"resize", .arg_required = 'r', .values = NULL},
867 {"jdev", .arg_required = 'j', .values = NULL},
868 {"nolargeio", .arg_required = 'w', .values = NULL},
869 {"commit", .arg_required = 'c', .values = NULL},
872 {"errors", .arg_required = 'e', .values = error_actions},
873 {"usrjquota", .arg_required = 'u'|(1<<REISERFS_OPT_ALLOWEMPTY), .values = NULL},
874 {"grpjquota", .arg_required = 'g'|(1<<REISERFS_OPT_ALLOWEMPTY), .values = NULL},
875 {"jqfmt", .arg_required = 'f', .values = NULL},
880 if (!options || !*options)
881 /* use default configuration: create tails, journaling on, no
882 conversion to newest format */
885 for (pos = options; pos; ) {
886 c = reiserfs_getopt (s, &pos, opts, &arg, mount_options);
888 /* wrong option is given */
895 /* "resize=NNN" or "resize=auto" */
897 if (!strcmp(arg, "auto")) {
898 /* From JFS code, to auto-get the size.*/
899 *blocks = s->s_bdev->bd_inode->i_size >> s->s_blocksize_bits;
901 *blocks = simple_strtoul (arg, &p, 0);
903 /* NNN does not look like a number */
904 reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
912 unsigned long val = simple_strtoul (arg, &p, 0);
913 /* commit=NNN (time in seconds) */
914 if ( *p != '\0' || val >= (unsigned int)-1) {
915 reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
918 *commit_max_age = (unsigned int)val;
923 int val = simple_strtoul (arg, &p, 0);
926 reiserfs_warning (s, "reiserfs_parse_options: non-numeric value %s for nolargeio option", arg);
930 reiserfs_default_io_size = PAGE_SIZE;
932 reiserfs_default_io_size = 128 * 1024;
936 if (arg && *arg && jdev_name) {
937 if ( *jdev_name ) { //Hm, already assigned?
938 reiserfs_warning (s, "reiserfs_parse_options: journal device was already specified to be %s", *jdev_name);
946 if (c == 'u' || c == 'g') {
947 int qtype = c == 'u' ? USRQUOTA : GRPQUOTA;
949 if (sb_any_quota_enabled(s)) {
950 reiserfs_warning(s, "reiserfs_parse_options: cannot change journalled quota options when quota turned on.");
953 if (*arg) { /* Some filename specified? */
954 if (REISERFS_SB(s)->s_qf_names[qtype] && strcmp(REISERFS_SB(s)->s_qf_names[qtype], arg)) {
955 reiserfs_warning(s, "reiserfs_parse_options: %s quota file already specified.", QTYPE2NAME(qtype));
958 if (strchr(arg, '/')) {
959 reiserfs_warning(s, "reiserfs_parse_options: quotafile must be on filesystem root.");
962 REISERFS_SB(s)->s_qf_names[qtype] = kmalloc(strlen(arg)+1, GFP_KERNEL);
963 if (!REISERFS_SB(s)->s_qf_names[qtype]) {
964 reiserfs_warning(s, "reiserfs_parse_options: not enough memory for storing quotafile name.");
967 strcpy(REISERFS_SB(s)->s_qf_names[qtype], arg);
970 if (REISERFS_SB(s)->s_qf_names[qtype]) {
971 kfree(REISERFS_SB(s)->s_qf_names[qtype]);
972 REISERFS_SB(s)->s_qf_names[qtype] = NULL;
977 if (!strcmp(arg, "vfsold"))
978 REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_OLD;
979 else if (!strcmp(arg, "vfsv0"))
980 REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_V0;
982 reiserfs_warning(s, "reiserfs_parse_options: unknown quota format specified.");
987 if (c == 'u' || c == 'g' || c == 'f') {
988 reiserfs_warning(s, "reiserfs_parse_options: journalled quota options not supported.");
995 if (!REISERFS_SB(s)->s_jquota_fmt && (REISERFS_SB(s)->s_qf_names[USRQUOTA] || REISERFS_SB(s)->s_qf_names[GRPQUOTA])) {
996 reiserfs_warning(s, "reiserfs_parse_options: journalled quota format not specified.");
1003 static void switch_data_mode(struct super_block *s, unsigned long mode) {
1004 REISERFS_SB(s)->s_mount_opt &= ~((1 << REISERFS_DATA_LOG) |
1005 (1 << REISERFS_DATA_ORDERED) |
1006 (1 << REISERFS_DATA_WRITEBACK));
1007 REISERFS_SB(s)->s_mount_opt |= (1 << mode);
1010 static void handle_data_mode(struct super_block *s, unsigned long mount_options)
1012 if (mount_options & (1 << REISERFS_DATA_LOG)) {
1013 if (!reiserfs_data_log(s)) {
1014 switch_data_mode(s, REISERFS_DATA_LOG);
1015 reiserfs_info (s, "switching to journaled data mode\n");
1017 } else if (mount_options & (1 << REISERFS_DATA_ORDERED)) {
1018 if (!reiserfs_data_ordered(s)) {
1019 switch_data_mode(s, REISERFS_DATA_ORDERED);
1020 reiserfs_info (s, "switching to ordered data mode\n");
1022 } else if (mount_options & (1 << REISERFS_DATA_WRITEBACK)) {
1023 if (!reiserfs_data_writeback(s)) {
1024 switch_data_mode(s, REISERFS_DATA_WRITEBACK);
1025 reiserfs_info (s, "switching to writeback data mode\n");
1030 static void handle_barrier_mode(struct super_block *s, unsigned long bits) {
1031 int flush = (1 << REISERFS_BARRIER_FLUSH);
1032 int none = (1 << REISERFS_BARRIER_NONE);
1033 int all_barrier = flush | none;
1035 if (bits & all_barrier) {
1036 REISERFS_SB(s)->s_mount_opt &= ~all_barrier;
1038 REISERFS_SB(s)->s_mount_opt |= flush;
1039 printk("reiserfs: enabling write barrier flush mode\n");
1040 } else if (bits & none) {
1041 REISERFS_SB(s)->s_mount_opt |= none;
1042 printk("reiserfs: write barriers turned off\n");
1047 static void handle_attrs( struct super_block *s )
1049 struct reiserfs_super_block * rs;
1051 if( reiserfs_attrs( s ) ) {
1052 rs = SB_DISK_SUPER_BLOCK (s);
1053 if( old_format_only(s) ) {
1054 reiserfs_warning(s, "reiserfs: cannot support attributes on 3.5.x disk format" );
1055 REISERFS_SB(s) -> s_mount_opt &= ~ ( 1 << REISERFS_ATTRS );
1058 if( !( le32_to_cpu( rs -> s_flags ) & reiserfs_attrs_cleared ) ) {
1059 reiserfs_warning(s, "reiserfs: cannot support attributes until flag is set in super-block" );
1060 REISERFS_SB(s) -> s_mount_opt &= ~ ( 1 << REISERFS_ATTRS );
1065 static int reiserfs_remount (struct super_block * s, int * mount_flags, char * arg)
1067 struct reiserfs_super_block * rs;
1068 struct reiserfs_transaction_handle th ;
1069 unsigned long blocks;
1070 unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
1071 unsigned long safe_mask = 0;
1072 unsigned int commit_max_age = (unsigned int)-1;
1073 struct reiserfs_journal *journal = SB_JOURNAL(s);
1079 rs = SB_DISK_SUPER_BLOCK (s);
1081 if (!reiserfs_parse_options(s, arg, &mount_options, &blocks, NULL, &commit_max_age)) {
1083 for (i = 0; i < MAXQUOTAS; i++)
1084 if (REISERFS_SB(s)->s_qf_names[i]) {
1085 kfree(REISERFS_SB(s)->s_qf_names[i]);
1086 REISERFS_SB(s)->s_qf_names[i] = NULL;
1094 /* Add options that are safe here */
1095 safe_mask |= 1 << REISERFS_SMALLTAIL;
1096 safe_mask |= 1 << REISERFS_LARGETAIL;
1097 safe_mask |= 1 << REISERFS_NO_BORDER;
1098 safe_mask |= 1 << REISERFS_NO_UNHASHED_RELOCATION;
1099 safe_mask |= 1 << REISERFS_HASHED_RELOCATION;
1100 safe_mask |= 1 << REISERFS_TEST4;
1101 safe_mask |= 1 << REISERFS_ATTRS;
1102 safe_mask |= 1 << REISERFS_XATTRS_USER;
1103 safe_mask |= 1 << REISERFS_POSIXACL;
1104 safe_mask |= 1 << REISERFS_BARRIER_FLUSH;
1105 safe_mask |= 1 << REISERFS_BARRIER_NONE;
1106 safe_mask |= 1 << REISERFS_ERROR_RO;
1107 safe_mask |= 1 << REISERFS_ERROR_CONTINUE;
1108 safe_mask |= 1 << REISERFS_ERROR_PANIC;
1110 /* Update the bitmask, taking care to keep
1111 * the bits we're not allowed to change here */
1112 REISERFS_SB(s)->s_mount_opt = (REISERFS_SB(s)->s_mount_opt & ~safe_mask) | (mount_options & safe_mask);
1114 if(commit_max_age != 0 && commit_max_age != (unsigned int)-1) {
1115 journal->j_max_commit_age = commit_max_age;
1116 journal->j_max_trans_age = commit_max_age;
1118 else if(commit_max_age == 0)
1120 /* 0 means restore defaults. */
1121 journal->j_max_commit_age = journal->j_default_max_commit_age;
1122 journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
1126 int rc = reiserfs_resize(s, blocks);
1131 if (*mount_flags & MS_RDONLY) {
1132 reiserfs_xattr_init (s, *mount_flags);
1133 /* remount read-only */
1134 if (s->s_flags & MS_RDONLY)
1135 /* it is read-only already */
1137 /* try to remount file system with read-only permissions */
1138 if (sb_umount_state(rs) == REISERFS_VALID_FS || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) {
1142 err = journal_begin(&th, s, 10) ;
1146 /* Mounting a rw partition read-only. */
1147 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
1148 set_sb_umount_state( rs, REISERFS_SB(s)->s_mount_state );
1149 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
1151 /* remount read-write */
1152 if (!(s->s_flags & MS_RDONLY)) {
1153 reiserfs_xattr_init (s, *mount_flags);
1154 return 0; /* We are read-write already */
1157 if (reiserfs_is_journal_aborted (journal))
1158 return journal->j_errno;
1160 handle_data_mode(s, mount_options);
1161 handle_barrier_mode(s, mount_options);
1162 REISERFS_SB(s)->s_mount_state = sb_umount_state(rs) ;
1163 s->s_flags &= ~MS_RDONLY ; /* now it is safe to call journal_begin */
1164 err = journal_begin(&th, s, 10) ;
1168 /* Mount a partition which is read-only, read-write */
1169 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
1170 REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
1171 s->s_flags &= ~MS_RDONLY;
1172 set_sb_umount_state( rs, REISERFS_ERROR_FS );
1173 /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */
1174 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
1175 REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS ;
1177 /* this will force a full flush of all journal lists */
1178 SB_JOURNAL(s)->j_must_wait = 1 ;
1179 err = journal_end(&th, s, 10) ;
1184 if (!( *mount_flags & MS_RDONLY ) ) {
1185 finish_unfinished( s );
1186 reiserfs_xattr_init (s, *mount_flags);
1192 /* load_bitmap_info_data - Sets up the reiserfs_bitmap_info structure from disk.
1193 * @sb - superblock for this filesystem
1194 * @bi - the bitmap info to be loaded. Requires that bi->bh is valid.
1196 * This routine counts how many free bits there are, finding the first zero
1197 * as a side effect. Could also be implemented as a loop of test_bit() calls, or
1198 * a loop of find_first_zero_bit() calls. This implementation is similar to
1199 * find_first_zero_bit(), but doesn't return after it finds the first bit.
1200 * Should only be called on fs mount, but should be fairly efficient anyways.
1202 * bi->first_zero_hint is considered unset if it == 0, since the bitmap itself
1203 * will * invariably occupt block 0 represented in the bitmap. The only
1204 * exception to this is when free_count also == 0, since there will be no
1205 * free blocks at all.
1208 static void load_bitmap_info_data (struct super_block *sb,
1209 struct reiserfs_bitmap_info *bi)
1211 unsigned long *cur = (unsigned long *)bi->bh->b_data;
1213 while ((char *)cur < (bi->bh->b_data + sb->s_blocksize)) {
1215 /* No need to scan if all 0's or all 1's.
1216 * Since we're only counting 0's, we can simply ignore all 1's */
1218 if (bi->first_zero_hint == 0) {
1219 bi->first_zero_hint = ((char *)cur - bi->bh->b_data) << 3;
1221 bi->free_count += sizeof(unsigned long)*8;
1222 } else if (*cur != ~0L) {
1224 for (b = 0; b < sizeof(unsigned long)*8; b++) {
1225 if (!reiserfs_test_le_bit (b, cur)) {
1227 if (bi->first_zero_hint == 0)
1228 bi->first_zero_hint =
1229 (((char *)cur - bi->bh->b_data) << 3) + b;
1236 #ifdef CONFIG_REISERFS_CHECK
1237 // This outputs a lot of unneded info on big FSes
1238 // reiserfs_warning ("bitmap loaded from block %d: %d free blocks",
1239 // bi->bh->b_blocknr, bi->free_count);
1243 static int read_bitmaps (struct super_block * s)
1247 SB_AP_BITMAP (s) = vmalloc (sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
1248 if (SB_AP_BITMAP (s) == 0)
1250 memset (SB_AP_BITMAP (s), 0, sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
1251 for (i = 0, bmap_nr = REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1;
1252 i < SB_BMAP_NR(s); i++, bmap_nr = s->s_blocksize * 8 * i) {
1253 SB_AP_BITMAP (s)[i].bh = sb_getblk(s, bmap_nr);
1254 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh))
1255 ll_rw_block(READ, 1, &SB_AP_BITMAP(s)[i].bh);
1257 for (i = 0; i < SB_BMAP_NR(s); i++) {
1258 wait_on_buffer(SB_AP_BITMAP (s)[i].bh);
1259 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
1260 reiserfs_warning(s,"sh-2029: reiserfs read_bitmaps: "
1261 "bitmap block (#%lu) reading failed",
1262 SB_AP_BITMAP(s)[i].bh->b_blocknr);
1263 for (i = 0; i < SB_BMAP_NR(s); i++)
1264 brelse(SB_AP_BITMAP(s)[i].bh);
1265 vfree(SB_AP_BITMAP(s));
1266 SB_AP_BITMAP(s) = NULL;
1269 load_bitmap_info_data (s, SB_AP_BITMAP (s) + i);
1274 static int read_old_bitmaps (struct super_block * s)
1277 struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK(s);
1278 int bmp1 = (REISERFS_OLD_DISK_OFFSET_IN_BYTES / s->s_blocksize) + 1; /* first of bitmap blocks */
1280 /* read true bitmap */
1281 SB_AP_BITMAP (s) = vmalloc (sizeof (struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
1282 if (SB_AP_BITMAP (s) == 0)
1285 memset (SB_AP_BITMAP (s), 0, sizeof (struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
1287 for (i = 0; i < sb_bmap_nr(rs); i ++) {
1288 SB_AP_BITMAP (s)[i].bh = sb_bread (s, bmp1 + i);
1289 if (!SB_AP_BITMAP (s)[i].bh)
1291 load_bitmap_info_data (s, SB_AP_BITMAP (s) + i);
1297 static int read_super_block (struct super_block * s, int offset)
1299 struct buffer_head * bh;
1300 struct reiserfs_super_block * rs;
1304 bh = sb_bread (s, offset / s->s_blocksize);
1306 reiserfs_warning (s, "sh-2006: read_super_block: "
1307 "bread failed (dev %s, block %lu, size %lu)",
1308 reiserfs_bdevname (s), offset / s->s_blocksize, s->s_blocksize);
1312 rs = (struct reiserfs_super_block *)bh->b_data;
1313 if (!is_any_reiserfs_magic_string (rs)) {
1319 // ok, reiserfs signature (old or new) found in at the given offset
1321 fs_blocksize = sb_blocksize(rs);
1323 sb_set_blocksize (s, fs_blocksize);
1325 bh = sb_bread (s, offset / s->s_blocksize);
1327 reiserfs_warning (s, "sh-2007: read_super_block: "
1328 "bread failed (dev %s, block %lu, size %lu)\n",
1329 reiserfs_bdevname (s), offset / s->s_blocksize, s->s_blocksize);
1333 rs = (struct reiserfs_super_block *)bh->b_data;
1334 if (sb_blocksize(rs) != s->s_blocksize) {
1335 reiserfs_warning (s, "sh-2011: read_super_block: "
1336 "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n",
1337 reiserfs_bdevname (s), (unsigned long long)bh->b_blocknr, s->s_blocksize);
1342 if ( rs->s_v1.s_root_block == cpu_to_le32(-1) ) {
1344 reiserfs_warning (s, "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
1345 "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
1346 "get newer reiserfsprogs package");
1350 SB_BUFFER_WITH_SB (s) = bh;
1351 SB_DISK_SUPER_BLOCK (s) = rs;
1353 if (is_reiserfs_jr (rs)) {
1354 /* magic is of non-standard journal filesystem, look at s_version to
1355 find which format is in use */
1356 if (sb_version(rs) == REISERFS_VERSION_2)
1357 reiserfs_warning (s, "read_super_block: found reiserfs format \"3.6\""
1358 " with non-standard journal");
1359 else if (sb_version(rs) == REISERFS_VERSION_1)
1360 reiserfs_warning (s, "read_super_block: found reiserfs format \"3.5\""
1361 " with non-standard journal");
1363 reiserfs_warning (s, "sh-2012: read_super_block: found unknown "
1364 "format \"%u\" of reiserfs with non-standard magic",
1370 /* s_version of standard format may contain incorrect information,
1371 so we just look at the magic string */
1372 reiserfs_info (s, "found reiserfs format \"%s\" with standard journal\n",
1373 is_reiserfs_3_5 (rs) ? "3.5" : "3.6");
1375 s->s_op = &reiserfs_sops;
1376 s->s_export_op = &reiserfs_export_ops;
1378 s->s_qcop = &reiserfs_qctl_operations;
1379 s->dq_op = &reiserfs_quota_operations;
1382 /* new format is limited by the 32 bit wide i_blocks field, want to
1383 ** be one full block below that.
1385 s->s_maxbytes = (512LL << 32) - s->s_blocksize ;
1391 /* after journal replay, reread all bitmap and super blocks */
1392 static int reread_meta_blocks(struct super_block *s) {
1394 ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))) ;
1395 wait_on_buffer(SB_BUFFER_WITH_SB(s)) ;
1396 if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
1397 reiserfs_warning (s, "reread_meta_blocks, error reading the super") ;
1401 for (i = 0; i < SB_BMAP_NR(s) ; i++) {
1402 ll_rw_block(READ, 1, &(SB_AP_BITMAP(s)[i].bh)) ;
1403 wait_on_buffer(SB_AP_BITMAP(s)[i].bh) ;
1404 if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
1405 reiserfs_warning (s, "reread_meta_blocks, error reading bitmap block number %d at %llu",
1406 i, (unsigned long long)SB_AP_BITMAP(s)[i].bh->b_blocknr) ;
1415 /////////////////////////////////////////////////////
1416 // hash detection stuff
1419 // if root directory is empty - we set default - Yura's - hash and
1421 // FIXME: we look for only one name in a directory. If tea and yura
1422 // bith have the same value - we ask user to send report to the
1424 static __u32 find_hash_out (struct super_block * s)
1427 struct inode * inode;
1429 INITIALIZE_PATH (path);
1430 struct reiserfs_dir_entry de;
1431 __u32 hash = DEFAULT_HASH;
1433 inode = s->s_root->d_inode;
1435 do { // Some serious "goto"-hater was there ;)
1436 u32 teahash, r5hash, yurahash;
1438 make_cpu_key (&key, inode, ~0, TYPE_DIRENTRY, 3);
1439 retval = search_by_entry_key (s, &key, &path, &de);
1440 if (retval == IO_ERROR) {
1444 if (retval == NAME_NOT_FOUND)
1446 set_de_name_and_namelen (&de);
1447 if (deh_offset( &(de.de_deh[de.de_entry_num]) ) == DOT_DOT_OFFSET) {
1448 /* allow override in this case */
1449 if (reiserfs_rupasov_hash(s)) {
1452 reiserfs_warning(s,"FS seems to be empty, autodetect "
1453 "is using the default hash");
1456 r5hash=GET_HASH_VALUE (r5_hash (de.de_name, de.de_namelen));
1457 teahash=GET_HASH_VALUE (keyed_hash (de.de_name, de.de_namelen));
1458 yurahash=GET_HASH_VALUE (yura_hash (de.de_name, de.de_namelen));
1459 if ( ( (teahash == r5hash) && (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash) ) ||
1460 ( (teahash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ||
1461 ( (r5hash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ) {
1462 reiserfs_warning(s,"Unable to automatically detect hash function. "
1463 "Please mount with -o hash={tea,rupasov,r5}",
1464 reiserfs_bdevname (s));
1468 if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == yurahash)
1470 else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == teahash)
1472 else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == r5hash)
1475 reiserfs_warning (s,"Unrecognised hash function");
1484 // finds out which hash names are sorted with
1485 static int what_hash (struct super_block * s)
1489 code = sb_hash_function_code(SB_DISK_SUPER_BLOCK(s));
1491 /* reiserfs_hash_detect() == true if any of the hash mount options
1492 ** were used. We must check them to make sure the user isn't
1493 ** using a bad hash value
1495 if (code == UNSET_HASH || reiserfs_hash_detect(s))
1496 code = find_hash_out (s);
1498 if (code != UNSET_HASH && reiserfs_hash_detect(s)) {
1499 /* detection has found the hash, and we must check against the
1502 if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
1503 reiserfs_warning (s, "Error, %s hash detected, "
1504 "unable to force rupasov hash", reiserfs_hashname(code)) ;
1506 } else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
1507 reiserfs_warning (s, "Error, %s hash detected, "
1508 "unable to force tea hash", reiserfs_hashname(code)) ;
1510 } else if (reiserfs_r5_hash(s) && code != R5_HASH) {
1511 reiserfs_warning (s, "Error, %s hash detected, "
1512 "unable to force r5 hash", reiserfs_hashname(code)) ;
1516 /* find_hash_out was not called or could not determine the hash */
1517 if (reiserfs_rupasov_hash(s)) {
1519 } else if (reiserfs_tea_hash(s)) {
1521 } else if (reiserfs_r5_hash(s)) {
1526 /* if we are mounted RW, and we have a new valid hash code, update
1529 if (code != UNSET_HASH &&
1530 !(s->s_flags & MS_RDONLY) &&
1531 code != sb_hash_function_code(SB_DISK_SUPER_BLOCK(s))) {
1532 set_sb_hash_function_code(SB_DISK_SUPER_BLOCK(s), code);
1537 // return pointer to appropriate function
1538 static hashf_t hash_function (struct super_block * s)
1540 switch (what_hash (s)) {
1542 reiserfs_info (s, "Using tea hash to sort names\n");
1545 reiserfs_info (s, "Using rupasov hash to sort names\n");
1548 reiserfs_info (s, "Using r5 hash to sort names\n");
1554 // this is used to set up correct value for old partitions
1555 static int function2code (hashf_t func)
1557 if (func == keyed_hash)
1559 if (func == yura_hash)
1561 if (func == r5_hash)
1564 BUG() ; // should never happen
1569 #define SWARN(silent, s, ...) \
1571 reiserfs_warning (s, __VA_ARGS__)
1573 static int reiserfs_fill_super (struct super_block * s, void * data, int silent)
1575 struct inode *root_inode;
1577 struct reiserfs_transaction_handle th ;
1579 unsigned long blocks;
1580 unsigned int commit_max_age = 0;
1581 int jinit_done = 0 ;
1582 struct reiserfs_iget_args args ;
1583 struct reiserfs_super_block * rs;
1585 struct reiserfs_sb_info *sbi;
1586 int errval = -EINVAL;
1588 sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
1594 memset (sbi, 0, sizeof (struct reiserfs_sb_info));
1595 /* Set default values for options: non-aggressive tails, RO on errors */
1596 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
1597 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
1598 /* no preallocation minimum, be smart in
1599 reiserfs_file_write instead */
1600 REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
1601 /* Preallocate by 16 blocks (17-1) at once */
1602 REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
1603 /* Initialize the rwsem for xattr dir */
1604 init_rwsem(&REISERFS_SB(s)->xattr_dir_sem);
1606 /* setup default block allocator options */
1607 reiserfs_init_alloc_options(s);
1610 if (reiserfs_parse_options (s, (char *) data, &(sbi->s_mount_opt), &blocks, &jdev_name, &commit_max_age) == 0) {
1615 SWARN (silent, s, "jmacd-7: reiserfs_fill_super: resize option "
1616 "for remount only");
1620 /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
1621 if (!read_super_block (s, REISERFS_OLD_DISK_OFFSET_IN_BYTES))
1623 /* try new format (64-th 1k block), which can contain reiserfs super block */
1624 else if (read_super_block (s, REISERFS_DISK_OFFSET_IN_BYTES)) {
1625 SWARN(silent, s, "sh-2021: reiserfs_fill_super: can not find reiserfs on %s", reiserfs_bdevname (s));
1629 /* map mount option tagxid */
1630 if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGXID))
1631 s->s_flags |= MS_TAGXID ;
1633 rs = SB_DISK_SUPER_BLOCK (s);
1634 /* Let's do basic sanity check to verify that underlying device is not
1635 smaller than the filesystem. If the check fails then abort and scream,
1636 because bad stuff will happen otherwise. */
1637 if ( s->s_bdev && s->s_bdev->bd_inode && i_size_read(s->s_bdev->bd_inode) < sb_block_count(rs)*sb_blocksize(rs)) {
1638 SWARN (silent, s, "Filesystem on %s cannot be mounted because it is bigger than the device", reiserfs_bdevname(s));
1639 SWARN(silent, s, "You may need to run fsck or increase size of your LVM partition");
1640 SWARN(silent, s, "Or may be you forgot to reboot after fdisk when it told you to");
1644 sbi->s_mount_state = SB_REISERFS_STATE(s);
1645 sbi->s_mount_state = REISERFS_VALID_FS ;
1647 if (old_format ? read_old_bitmaps(s) : read_bitmaps(s)) {
1648 SWARN(silent, s, "jmacd-8: reiserfs_fill_super: unable to read bitmap");
1651 #ifdef CONFIG_REISERFS_CHECK
1652 SWARN (silent, s, "CONFIG_REISERFS_CHECK is set ON");
1653 SWARN (silent, s, "- it is slow mode for debugging.");
1656 /* make data=ordered the default */
1657 if (!reiserfs_data_log(s) && !reiserfs_data_ordered(s) &&
1658 !reiserfs_data_writeback(s))
1660 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_DATA_ORDERED);
1663 if (reiserfs_data_log(s)) {
1664 reiserfs_info (s, "using journaled data mode\n");
1665 } else if (reiserfs_data_ordered(s)) {
1666 reiserfs_info (s, "using ordered data mode\n");
1668 reiserfs_info (s, "using writeback data mode\n");
1670 if (reiserfs_barrier_flush(s)) {
1671 printk("reiserfs: using flush barriers\n");
1674 // set_device_ro(s->s_dev, 1) ;
1675 if( journal_init(s, jdev_name, old_format, commit_max_age) ) {
1676 SWARN(silent, s, "sh-2022: reiserfs_fill_super: unable to initialize journal space") ;
1679 jinit_done = 1 ; /* once this is set, journal_release must be called
1680 ** if we error out of the mount
1683 if (reread_meta_blocks(s)) {
1684 SWARN(silent, s, "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init") ;
1688 if (replay_only (s))
1691 if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
1692 SWARN(silent, s, "clm-7000: Detected readonly device, marking FS readonly") ;
1693 s->s_flags |= MS_RDONLY ;
1695 args.objectid = REISERFS_ROOT_OBJECTID ;
1696 args.dirid = REISERFS_ROOT_PARENT_OBJECTID ;
1697 root_inode = iget5_locked (s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
1699 SWARN(silent, s, "jmacd-10: reiserfs_fill_super: get root inode failed");
1703 if (root_inode->i_state & I_NEW) {
1704 reiserfs_read_locked_inode(root_inode, &args);
1705 unlock_new_inode(root_inode);
1708 s->s_root = d_alloc_root(root_inode);
1714 // define and initialize hash function
1715 sbi->s_hash_function = hash_function (s);
1716 if (sbi->s_hash_function == NULL) {
1722 if (is_reiserfs_3_5 (rs) || (is_reiserfs_jr (rs) && SB_VERSION (s) == REISERFS_VERSION_1))
1723 set_bit(REISERFS_3_5, &(sbi->s_properties));
1725 set_bit(REISERFS_3_6, &(sbi->s_properties));
1727 if (!(s->s_flags & MS_RDONLY)) {
1729 errval = journal_begin(&th, s, 1) ;
1735 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
1737 set_sb_umount_state( rs, REISERFS_ERROR_FS );
1738 set_sb_fs_state (rs, 0);
1740 if (old_format_only(s)) {
1741 /* filesystem of format 3.5 either with standard or non-standard
1743 if (convert_reiserfs (s)) {
1744 /* and -o conv is given */
1746 reiserfs_info (s,"converting 3.5 filesystem to the 3.6 format") ;
1748 if (is_reiserfs_3_5 (rs))
1749 /* put magic string of 3.6 format. 2.2 will not be able to
1750 mount this filesystem anymore */
1751 memcpy (rs->s_v1.s_magic, reiserfs_3_6_magic_string,
1752 sizeof (reiserfs_3_6_magic_string));
1754 set_sb_version(rs,REISERFS_VERSION_2);
1755 reiserfs_convert_objectid_map_v1(s) ;
1756 set_bit(REISERFS_3_6, &(sbi->s_properties));
1757 clear_bit(REISERFS_3_5, &(sbi->s_properties));
1758 } else if (!silent){
1759 reiserfs_info (s, "using 3.5.x disk format\n") ;
1763 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
1764 errval = journal_end(&th, s, 1) ;
1771 if ((errval = reiserfs_xattr_init (s, s->s_flags))) {
1777 /* look for files which were to be removed in previous session */
1778 finish_unfinished (s);
1780 if ( old_format_only(s) && !silent) {
1781 reiserfs_info (s, "using 3.5.x disk format\n") ;
1784 if ((errval = reiserfs_xattr_init (s, s->s_flags))) {
1790 // mark hash in super block: it could be unset. overwrite should be ok
1791 set_sb_hash_function_code( rs, function2code(sbi->s_hash_function ) );
1795 reiserfs_proc_info_init( s );
1797 init_waitqueue_head (&(sbi->s_wait));
1798 spin_lock_init(&sbi->bitmap_lock);
1803 if (jinit_done) { /* kill the commit thread, free journal ram */
1804 journal_release_error(NULL, s) ;
1806 if (SB_DISK_SUPER_BLOCK (s)) {
1807 for (j = 0; j < SB_BMAP_NR (s); j ++) {
1808 if (SB_AP_BITMAP (s))
1809 brelse (SB_AP_BITMAP (s)[j].bh);
1811 if (SB_AP_BITMAP (s))
1812 vfree (SB_AP_BITMAP (s));
1814 if (SB_BUFFER_WITH_SB (s))
1815 brelse(SB_BUFFER_WITH_SB (s));
1817 for (j = 0; j < MAXQUOTAS; j++) {
1818 if (sbi->s_qf_names[j])
1819 kfree(sbi->s_qf_names[j]);
1826 s->s_fs_info = NULL;
1831 static int reiserfs_statfs (struct super_block * s, struct kstatfs * buf)
1833 struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
1835 buf->f_namelen = (REISERFS_MAX_NAME (s->s_blocksize));
1836 buf->f_bfree = sb_free_blocks(rs);
1837 buf->f_bavail = buf->f_bfree;
1838 buf->f_blocks = sb_block_count(rs) - sb_bmap_nr(rs) - 1;
1839 buf->f_bsize = s->s_blocksize;
1840 /* changed to accommodate gcc folks.*/
1841 buf->f_type = REISERFS_SUPER_MAGIC;
1846 static int reiserfs_dquot_initialize(struct inode *inode, int type)
1848 struct reiserfs_transaction_handle th;
1851 /* We may create quota structure so we need to reserve enough blocks */
1852 reiserfs_write_lock(inode->i_sb);
1853 journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
1854 ret = dquot_initialize(inode, type);
1855 journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
1856 reiserfs_write_unlock(inode->i_sb);
1860 static int reiserfs_dquot_drop(struct inode *inode)
1862 struct reiserfs_transaction_handle th;
1865 /* We may delete quota structure so we need to reserve enough blocks */
1866 reiserfs_write_lock(inode->i_sb);
1867 journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
1868 ret = dquot_drop(inode);
1869 journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS);
1870 reiserfs_write_unlock(inode->i_sb);
1874 static int reiserfs_write_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_TRANS_BLOCKS);
1881 ret = dquot_commit(dquot);
1882 journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS);
1883 reiserfs_write_unlock(dquot->dq_sb);
1887 static int reiserfs_acquire_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_acquire(dquot);
1895 journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
1896 reiserfs_write_unlock(dquot->dq_sb);
1900 static int reiserfs_release_dquot(struct dquot *dquot)
1902 struct reiserfs_transaction_handle th;
1905 reiserfs_write_lock(dquot->dq_sb);
1906 journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
1907 ret = dquot_release(dquot);
1908 journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS);
1909 reiserfs_write_unlock(dquot->dq_sb);
1913 static int reiserfs_mark_dquot_dirty(struct dquot *dquot)
1915 /* Are we journalling quotas? */
1916 if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
1917 REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
1918 dquot_mark_dquot_dirty(dquot);
1919 return reiserfs_write_dquot(dquot);
1922 return dquot_mark_dquot_dirty(dquot);
1925 static int reiserfs_write_info(struct super_block *sb, int type)
1927 struct reiserfs_transaction_handle th;
1930 /* Data block + inode block */
1931 reiserfs_write_lock(sb);
1932 journal_begin(&th, sb, 2);
1933 ret = dquot_commit_info(sb, type);
1934 journal_end(&th, sb, 2);
1935 reiserfs_write_unlock(sb);
1940 * Turn on quotas during mount time - we need to find
1941 * the quota file and such...
1943 static int reiserfs_quota_on_mount(struct super_block *sb, int type)
1946 struct dentry *dentry;
1947 struct qstr name = { .name = REISERFS_SB(sb)->s_qf_names[type],
1949 .len = strlen(REISERFS_SB(sb)->s_qf_names[type])};
1951 dentry = lookup_hash(&name, sb->s_root);
1953 return PTR_ERR(dentry);
1954 err = vfs_quota_on_mount(type, REISERFS_SB(sb)->s_jquota_fmt, dentry);
1955 /* Now invalidate and put the dentry - quota got its own reference
1956 * to inode and dentry has at least wrong hash so we had better
1958 d_invalidate(dentry);
1964 * Standard function to be called on quota_on
1966 static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
1969 struct nameidata nd;
1971 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
1974 /* Quotafile not on the same filesystem? */
1975 if (nd.mnt->mnt_sb != sb) {
1979 /* We must not pack tails for quota files on reiserfs for quota IO to work */
1980 if (!REISERFS_I(nd.dentry->d_inode)->i_flags & i_nopack_mask) {
1981 reiserfs_warning(sb, "reiserfs: Quota file must have tail packing disabled.");
1985 /* Not journalling quota? No more tests needed... */
1986 if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
1987 !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
1989 return vfs_quota_on(sb, type, format_id, path);
1991 /* Quotafile not of fs root? */
1992 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
1993 reiserfs_warning(sb, "reiserfs: Quota file not on filesystem root. "
1994 "Journalled quota will not work.");
1996 return vfs_quota_on(sb, type, format_id, path);
1999 /* Read data from quotafile - avoid pagecache and such because we cannot afford
2000 * acquiring the locks... As quota files are never truncated and quota code
2001 * itself serializes the operations (and noone else should touch the files)
2002 * we don't have to be afraid of races */
2003 static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data,
2004 size_t len, loff_t off)
2006 struct inode *inode = sb_dqopt(sb)->files[type];
2007 unsigned long blk = off >> sb->s_blocksize_bits;
2008 int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
2010 struct buffer_head tmp_bh, *bh;
2011 loff_t i_size = i_size_read(inode);
2015 if (off+len > i_size)
2018 while (toread > 0) {
2019 tocopy = sb->s_blocksize - offset < toread ? sb->s_blocksize - offset : toread;
2021 /* Quota files are without tails so we can safely use this function */
2022 reiserfs_write_lock(sb);
2023 err = reiserfs_get_block(inode, blk, &tmp_bh, 0);
2024 reiserfs_write_unlock(sb);
2027 if (!buffer_mapped(&tmp_bh)) /* A hole? */
2028 memset(data, 0, tocopy);
2030 bh = sb_bread(sb, tmp_bh.b_blocknr);
2033 memcpy(data, bh->b_data+offset, tocopy);
2044 /* Write to quotafile (we know the transaction is already started and has
2045 * enough credits) */
2046 static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2047 const char *data, size_t len, loff_t off)
2049 struct inode *inode = sb_dqopt(sb)->files[type];
2050 unsigned long blk = off >> sb->s_blocksize_bits;
2051 int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
2052 int journal_quota = REISERFS_SB(sb)->s_qf_names[type] != NULL;
2053 size_t towrite = len;
2054 struct buffer_head tmp_bh, *bh;
2056 down(&inode->i_sem);
2057 while (towrite > 0) {
2058 tocopy = sb->s_blocksize - offset < towrite ?
2059 sb->s_blocksize - offset : towrite;
2061 err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE);
2064 if (offset || tocopy != sb->s_blocksize)
2065 bh = sb_bread(sb, tmp_bh.b_blocknr);
2067 bh = sb_getblk(sb, tmp_bh.b_blocknr);
2073 memcpy(bh->b_data+offset, data, tocopy);
2074 flush_dcache_page(bh->b_page);
2075 set_buffer_uptodate(bh);
2077 reiserfs_prepare_for_journal(sb, bh, 1);
2078 journal_mark_dirty(current->journal_info, sb, bh);
2080 reiserfs_add_ordered_list(inode, bh);
2090 if (inode->i_size < off+len-towrite)
2091 i_size_write(inode, off+len-towrite);
2093 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2094 mark_inode_dirty(inode);
2096 return len - towrite;
2101 static struct super_block*
2102 get_super_block (struct file_system_type *fs_type, int flags,
2103 const char *dev_name, void *data)
2105 return get_sb_bdev(fs_type, flags, dev_name, data, reiserfs_fill_super);
2109 init_reiserfs_fs ( void )
2113 if ((ret = init_inodecache ())) {
2117 if ((ret = reiserfs_xattr_register_handlers ()))
2118 goto failed_reiserfs_xattr_register_handlers;
2120 reiserfs_proc_info_global_init ();
2121 reiserfs_proc_register_global ("version", reiserfs_global_version_in_proc);
2123 ret = register_filesystem (& reiserfs_fs_type);
2129 reiserfs_xattr_unregister_handlers ();
2131 failed_reiserfs_xattr_register_handlers:
2132 reiserfs_proc_unregister_global ("version");
2133 reiserfs_proc_info_global_done ();
2134 destroy_inodecache ();
2140 exit_reiserfs_fs ( void )
2142 reiserfs_xattr_unregister_handlers ();
2143 reiserfs_proc_unregister_global ("version");
2144 reiserfs_proc_info_global_done ();
2145 unregister_filesystem (& reiserfs_fs_type);
2146 destroy_inodecache ();
2149 struct file_system_type reiserfs_fs_type = {
2150 .owner = THIS_MODULE,
2152 .get_sb = get_super_block,
2153 .kill_sb = kill_block_super,
2154 .fs_flags = FS_REQUIRES_DEV,
2157 MODULE_DESCRIPTION ("ReiserFS journaled filesystem");
2158 MODULE_AUTHOR ("Hans Reiser <reiser@namesys.com>");
2159 MODULE_LICENSE ("GPL");
2161 module_init (init_reiserfs_fs);
2162 module_exit (exit_reiserfs_fs);