Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi...
[firefly-linux-kernel-4.4.55.git] / fs / reiserfs / super.c
index 6268bb8195c59675cb3f757aa83146a40c31f4dd..a392cef6acc61e3d237bf8353a302bf4fdf46b67 100644 (file)
@@ -74,7 +74,7 @@ static int reiserfs_sync_fs(struct super_block *s, int wait)
        dquot_writeback_dquots(s, -1);
        reiserfs_write_lock(s);
        if (!journal_begin(&th, s, 1))
-               if (!journal_end_sync(&th, s, 1))
+               if (!journal_end_sync(&th))
                        reiserfs_flush_old_commits(s);
        reiserfs_write_unlock(s);
        return 0;
@@ -136,9 +136,9 @@ static int reiserfs_freeze(struct super_block *s)
                } else {
                        reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
                                                     1);
-                       journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+                       journal_mark_dirty(&th, SB_BUFFER_WITH_SB(s));
                        reiserfs_block_writes(&th);
-                       journal_end_sync(&th, s, 1);
+                       journal_end_sync(&th);
                }
        }
        reiserfs_write_unlock(s);
@@ -178,7 +178,7 @@ static int remove_save_link_only(struct super_block *s,
                /* removals are protected by direct items */
                reiserfs_release_objectid(&th, le32_to_cpu(key->k_objectid));
 
-       return journal_end(&th, s, JOURNAL_PER_BALANCE_CNT);
+       return journal_end(&th);
 }
 
 #ifdef CONFIG_QUOTA
@@ -506,7 +506,7 @@ int remove_save_link(struct inode *inode, int truncate)
        } else
                REISERFS_I(inode)->i_flags &= ~i_link_saved_truncate_mask;
 
-       return journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
+       return journal_end(&th);
 }
 
 static void reiserfs_kill_sb(struct super_block *s)
@@ -551,7 +551,7 @@ static void reiserfs_put_super(struct super_block *s)
                                                     1);
                        set_sb_umount_state(SB_DISK_SUPER_BLOCK(s),
                                            REISERFS_SB(s)->s_mount_state);
-                       journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+                       journal_mark_dirty(&th, SB_BUFFER_WITH_SB(s));
                }
        }
 
@@ -659,7 +659,7 @@ static void reiserfs_dirty_inode(struct inode *inode, int flags)
                goto out;
 
        reiserfs_update_sd(&th, inode);
-       journal_end(&th, inode->i_sb, 1);
+       journal_end(&th);
 
 out:
        reiserfs_write_unlock(inode->i_sb);
@@ -1477,7 +1477,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
                /* Mounting a rw partition read-only. */
                reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
                set_sb_umount_state(rs, REISERFS_SB(s)->s_mount_state);
-               journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+               journal_mark_dirty(&th, SB_BUFFER_WITH_SB(s));
        } else {
                /* remount read-write */
                if (!(s->s_flags & MS_RDONLY)) {
@@ -1509,12 +1509,12 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
                if (!old_format_only(s))
                        set_sb_mnt_count(rs, sb_mnt_count(rs) + 1);
                /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */
-               journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+               journal_mark_dirty(&th, SB_BUFFER_WITH_SB(s));
                REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS;
        }
        /* this will force a full flush of all journal lists */
        SB_JOURNAL(s)->j_must_wait = 1;
-       err = journal_end(&th, s, 10);
+       err = journal_end(&th);
        if (err)
                goto out_err_unlock;
 
@@ -1642,7 +1642,7 @@ static int read_super_block(struct super_block *s, int offset)
 /* after journal replay, reread all bitmap and super blocks */
 static int reread_meta_blocks(struct super_block *s)
 {
-       ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s)));
+       ll_rw_block(READ, 1, &SB_BUFFER_WITH_SB(s));
        wait_on_buffer(SB_BUFFER_WITH_SB(s));
        if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
                reiserfs_warning(s, "reiserfs-2504", "error reading the super");
@@ -1668,71 +1668,60 @@ static __u32 find_hash_out(struct super_block *s)
        struct cpu_key key;
        INITIALIZE_PATH(path);
        struct reiserfs_dir_entry de;
+       struct reiserfs_de_head *deh;
        __u32 hash = DEFAULT_HASH;
+       __u32 deh_hashval, teahash, r5hash, yurahash;
 
        inode = s->s_root->d_inode;
 
-       do {                    /* Some serious "goto"-hater was there ;) */
-               u32 teahash, r5hash, yurahash;
+       make_cpu_key(&key, inode, ~0, TYPE_DIRENTRY, 3);
+       retval = search_by_entry_key(s, &key, &path, &de);
+       if (retval == IO_ERROR) {
+               pathrelse(&path);
+               return UNSET_HASH;
+       }
+       if (retval == NAME_NOT_FOUND)
+               de.de_entry_num--;
 
-               make_cpu_key(&key, inode, ~0, TYPE_DIRENTRY, 3);
-               retval = search_by_entry_key(s, &key, &path, &de);
-               if (retval == IO_ERROR) {
-                       pathrelse(&path);
-                       return UNSET_HASH;
-               }
-               if (retval == NAME_NOT_FOUND)
-                       de.de_entry_num--;
-               set_de_name_and_namelen(&de);
-               if (deh_offset(&(de.de_deh[de.de_entry_num])) == DOT_DOT_OFFSET) {
-                       /* allow override in this case */
-                       if (reiserfs_rupasov_hash(s)) {
-                               hash = YURA_HASH;
-                       }
-                       reiserfs_info(s, "FS seems to be empty, autodetect "
-                                        "is using the default hash\n");
-                       break;
-               }
-               r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen));
-               teahash = GET_HASH_VALUE(keyed_hash(de.de_name, de.de_namelen));
-               yurahash = GET_HASH_VALUE(yura_hash(de.de_name, de.de_namelen));
-               if (((teahash == r5hash)
-                    &&
-                    (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num])))
-                     == r5hash)) || ((teahash == yurahash)
-                                     && (yurahash ==
-                                         GET_HASH_VALUE(deh_offset
-                                                        (&
-                                                         (de.
-                                                          de_deh[de.
-                                                                 de_entry_num])))))
-                   || ((r5hash == yurahash)
-                       && (yurahash ==
-                           GET_HASH_VALUE(deh_offset
-                                          (&(de.de_deh[de.de_entry_num])))))) {
-                       reiserfs_warning(s, "reiserfs-2506", "Unable to "
-                                        "automatically detect hash function. "
-                                        "Please mount with -o "
-                                        "hash={tea,rupasov,r5}");
-                       hash = UNSET_HASH;
-                       break;
-               }
-               if (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num]))) ==
-                   yurahash)
+       set_de_name_and_namelen(&de);
+       deh = de.de_deh + de.de_entry_num;
+
+       if (deh_offset(deh) == DOT_DOT_OFFSET) {
+               /* allow override in this case */
+               if (reiserfs_rupasov_hash(s))
                        hash = YURA_HASH;
-               else if (GET_HASH_VALUE
-                        (deh_offset(&(de.de_deh[de.de_entry_num]))) == teahash)
-                       hash = TEA_HASH;
-               else if (GET_HASH_VALUE
-                        (deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash)
-                       hash = R5_HASH;
-               else {
-                       reiserfs_warning(s, "reiserfs-2506",
-                                        "Unrecognised hash function");
-                       hash = UNSET_HASH;
-               }
-       } while (0);
+               reiserfs_info(s, "FS seems to be empty, autodetect is using the default hash\n");
+               goto out;
+       }
 
+       deh_hashval = GET_HASH_VALUE(deh_offset(deh));
+       r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen));
+       teahash = GET_HASH_VALUE(keyed_hash(de.de_name, de.de_namelen));
+       yurahash = GET_HASH_VALUE(yura_hash(de.de_name, de.de_namelen));
+
+       if ((teahash == r5hash && deh_hashval == r5hash) ||
+           (teahash == yurahash && deh_hashval == yurahash) ||
+           (r5hash == yurahash && deh_hashval == yurahash)) {
+               reiserfs_warning(s, "reiserfs-2506",
+                                "Unable to automatically detect hash "
+                                "function. Please mount with -o "
+                                "hash={tea,rupasov,r5}");
+               hash = UNSET_HASH;
+               goto out;
+       }
+
+       if (deh_hashval == yurahash)
+               hash = YURA_HASH;
+       else if (deh_hashval == teahash)
+               hash = TEA_HASH;
+       else if (deh_hashval == r5hash)
+               hash = R5_HASH;
+       else {
+               reiserfs_warning(s, "reiserfs-2506",
+                                "Unrecognised hash function");
+               hash = UNSET_HASH;
+       }
+out:
        pathrelse(&path);
        return hash;
 }
@@ -1886,7 +1875,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
 
        jdev_name = NULL;
        if (reiserfs_parse_options
-           (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name,
+           (s, (char *)data, &sbi->s_mount_opt, &blocks, &jdev_name,
             &commit_max_age, qf_names, &qfmt) == 0) {
                goto error_unlocked;
        }
@@ -2003,7 +1992,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
        args.dirid = REISERFS_ROOT_PARENT_OBJECTID;
        root_inode =
            iget5_locked(s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor,
-                        reiserfs_init_locked_inode, (void *)(&args));
+                        reiserfs_init_locked_inode, (void *)&args);
        if (!root_inode) {
                SWARN(silent, s, "jmacd-10", "get root inode failed");
                goto error_unlocked;
@@ -2037,11 +2026,11 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
 
        if (is_reiserfs_3_5(rs)
            || (is_reiserfs_jr(rs) && SB_VERSION(s) == REISERFS_VERSION_1))
-               set_bit(REISERFS_3_5, &(sbi->s_properties));
+               set_bit(REISERFS_3_5, &sbi->s_properties);
        else if (old_format)
-               set_bit(REISERFS_OLD_FORMAT, &(sbi->s_properties));
+               set_bit(REISERFS_OLD_FORMAT, &sbi->s_properties);
        else
-               set_bit(REISERFS_3_6, &(sbi->s_properties));
+               set_bit(REISERFS_3_6, &sbi->s_properties);
 
        if (!(s->s_flags & MS_RDONLY)) {
 
@@ -2097,8 +2086,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
 
                                set_sb_version(rs, REISERFS_VERSION_2);
                                reiserfs_convert_objectid_map_v1(s);
-                               set_bit(REISERFS_3_6, &(sbi->s_properties));
-                               clear_bit(REISERFS_3_5, &(sbi->s_properties));
+                               set_bit(REISERFS_3_6, &sbi->s_properties);
+                               clear_bit(REISERFS_3_5, &sbi->s_properties);
                        } else if (!silent) {
                                reiserfs_info(s, "using 3.5.x disk format\n");
                        }
@@ -2106,8 +2095,8 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
                        set_sb_mnt_count(rs, sb_mnt_count(rs) + 1);
 
 
-               journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
-               errval = journal_end(&th, s, 1);
+               journal_mark_dirty(&th, SB_BUFFER_WITH_SB(s));
+               errval = journal_end(&th);
                if (errval) {
                        dput(s->s_root);
                        s->s_root = NULL;
@@ -2220,9 +2209,7 @@ static int reiserfs_write_dquot(struct dquot *dquot)
        depth = reiserfs_write_unlock_nested(dquot->dq_sb);
        ret = dquot_commit(dquot);
        reiserfs_write_lock_nested(dquot->dq_sb, depth);
-       err =
-           journal_end(&th, dquot->dq_sb,
-                       REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
+       err = journal_end(&th);
        if (!ret && err)
                ret = err;
 out:
@@ -2245,9 +2232,7 @@ static int reiserfs_acquire_dquot(struct dquot *dquot)
        depth = reiserfs_write_unlock_nested(dquot->dq_sb);
        ret = dquot_acquire(dquot);
        reiserfs_write_lock_nested(dquot->dq_sb, depth);
-       err =
-           journal_end(&th, dquot->dq_sb,
-                       REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
+       err = journal_end(&th);
        if (!ret && err)
                ret = err;
 out:
@@ -2272,9 +2257,7 @@ static int reiserfs_release_dquot(struct dquot *dquot)
        }
        ret = dquot_release(dquot);
        reiserfs_write_lock(dquot->dq_sb);
-       err =
-           journal_end(&th, dquot->dq_sb,
-                       REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
+       err = journal_end(&th);
        if (!ret && err)
                ret = err;
        reiserfs_write_unlock(dquot->dq_sb);
@@ -2307,7 +2290,7 @@ static int reiserfs_write_info(struct super_block *sb, int type)
        depth = reiserfs_write_unlock_nested(sb);
        ret = dquot_commit_info(sb, type);
        reiserfs_write_lock_nested(sb, depth);
-       err = journal_end(&th, sb, 2);
+       err = journal_end(&th);
        if (!ret && err)
                ret = err;
 out:
@@ -2380,7 +2363,7 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
                err = journal_begin(&th, sb, 1);
                if (err)
                        goto out;
-               err = journal_end_sync(&th, sb, 1);
+               err = journal_end_sync(&th);
                if (err)
                        goto out;
        }
@@ -2487,7 +2470,7 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
                unlock_buffer(bh);
                reiserfs_write_lock(sb);
                reiserfs_prepare_for_journal(sb, bh, 1);
-               journal_mark_dirty(current->journal_info, sb, bh);
+               journal_mark_dirty(current->journal_info, bh);
                if (!journal_quota)
                        reiserfs_add_ordered_list(inode, bh);
                reiserfs_write_unlock(sb);