Merge remote-tracking branches 'regulator/topic/88pm800', 'regulator/topic/ab8500...
[firefly-linux-kernel-4.4.55.git] / fs / reiserfs / journal.c
index 5b4ccd5f642eefc0eba19fa687e431fba486ed85..e8870de4627e6d49cbbab6ed42ea5bd49709a236 100644 (file)
@@ -90,7 +90,7 @@ static int flush_commit_list(struct super_block *s,
                             struct reiserfs_journal_list *jl, int flushall);
 static int can_dirty(struct reiserfs_journal_cnode *cn);
 static int journal_join(struct reiserfs_transaction_handle *th,
-                       struct super_block *sb, unsigned long nblocks);
+                       struct super_block *sb);
 static void release_journal_dev(struct super_block *super,
                               struct reiserfs_journal *journal);
 static int dirty_one_transaction(struct super_block *s,
@@ -160,7 +160,7 @@ static struct reiserfs_bitmap_node *get_bitmap_node(struct super_block *sb)
        struct list_head *entry = journal->j_bitmap_nodes.next;
 
        journal->j_used_bitmap_nodes++;
-      repeat:
+repeat:
 
        if (entry != &journal->j_bitmap_nodes) {
                bn = list_entry(entry, struct reiserfs_bitmap_node, list);
@@ -757,7 +757,7 @@ static inline int __add_jh(struct reiserfs_journal *j, struct buffer_head *bh,
                jh = bh->b_private;
                list_del_init(&jh->list);
        } else {
-             no_jh:
+no_jh:
                get_bh(bh);
                jh = alloc_jh();
                spin_lock(&j->j_dirty_buffers_lock);
@@ -836,7 +836,7 @@ static int write_ordered_buffers(spinlock_t * lock,
                        reiserfs_free_jh(bh);
                        unlock_buffer(bh);
                }
-             loop_next:
+loop_next:
                put_bh(bh);
                cond_resched_lock(lock);
        }
@@ -891,7 +891,7 @@ static int flush_older_commits(struct super_block *s,
        unsigned int other_trans_id;
        unsigned int first_trans_id;
 
-      find_first:
+find_first:
        /*
         * first we walk backwards to find the oldest uncommitted transation
         */
@@ -1016,9 +1016,9 @@ static int flush_commit_list(struct super_block *s,
        BUG_ON(jl->j_trans_id == 0);
 
        /* this commit is done, exit */
-       if (atomic_read(&(jl->j_commit_left)) <= 0) {
+       if (atomic_read(&jl->j_commit_left) <= 0) {
                if (flushall) {
-                       atomic_set(&(jl->j_older_commits_done), 1);
+                       atomic_set(&jl->j_older_commits_done, 1);
                }
                mutex_unlock(&jl->j_commit_mutex);
                goto put_jl;
@@ -1094,10 +1094,10 @@ static int flush_commit_list(struct super_block *s,
                put_bh(tbh);
                /* once due to original getblk in do_journal_end */
                put_bh(tbh);
-               atomic_dec(&(jl->j_commit_left));
+               atomic_dec(&jl->j_commit_left);
        }
 
-       BUG_ON(atomic_read(&(jl->j_commit_left)) != 1);
+       BUG_ON(atomic_read(&jl->j_commit_left) != 1);
 
        /*
         * If there was a write error in the journal - we can't commit
@@ -1147,13 +1147,13 @@ static int flush_commit_list(struct super_block *s,
        /* mark the metadata dirty */
        if (!retval)
                dirty_one_transaction(s, jl);
-       atomic_dec(&(jl->j_commit_left));
+       atomic_dec(&jl->j_commit_left);
 
        if (flushall) {
-               atomic_set(&(jl->j_older_commits_done), 1);
+               atomic_set(&jl->j_older_commits_done, 1);
        }
        mutex_unlock(&jl->j_commit_mutex);
-      put_jl:
+put_jl:
        put_journal_list(s, jl);
 
        if (retval)
@@ -1306,7 +1306,7 @@ static int flush_older_journal_lists(struct super_block *sb,
         * we know we are the only ones flushing things, no extra race
         * protection is required.
         */
-      restart:
+restart:
        entry = journal->j_journal_list.next;
        /* Did we wrap? */
        if (entry == &journal->j_journal_list)
@@ -1379,8 +1379,8 @@ static int flush_journal_list(struct super_block *s,
        }
 
        /* if all the work is already done, get out of here */
-       if (atomic_read(&(jl->j_nonzerolen)) <= 0 &&
-           atomic_read(&(jl->j_commit_left)) <= 0) {
+       if (atomic_read(&jl->j_nonzerolen) <= 0 &&
+           atomic_read(&jl->j_commit_left) <= 0) {
                goto flush_older_and_return;
        }
 
@@ -1395,8 +1395,8 @@ static int flush_journal_list(struct super_block *s,
                BUG();
 
        /* are we done now? */
-       if (atomic_read(&(jl->j_nonzerolen)) <= 0 &&
-           atomic_read(&(jl->j_commit_left)) <= 0) {
+       if (atomic_read(&jl->j_nonzerolen) <= 0 &&
+           atomic_read(&jl->j_commit_left) <= 0) {
                goto flush_older_and_return;
        }
 
@@ -1404,7 +1404,7 @@ static int flush_journal_list(struct super_block *s,
         * loop through each cnode, see if we need to write it,
         * or wait on a more recent transaction, or just ignore it
         */
-       if (atomic_read(&(journal->j_wcount)) != 0) {
+       if (atomic_read(&journal->j_wcount) != 0) {
                reiserfs_panic(s, "journal-844", "journal list is flushing, "
                               "wcount is not 0");
        }
@@ -1504,7 +1504,7 @@ static int flush_journal_list(struct super_block *s,
                                         (unsigned long long)saved_bh->
                                         b_blocknr, __func__);
                }
-             free_cnode:
+free_cnode:
                last = cn;
                cn = cn->next;
                if (saved_bh) {
@@ -1513,7 +1513,7 @@ static int flush_journal_list(struct super_block *s,
                         * taking the buffer head away
                         */
                        put_bh(saved_bh);
-                       if (atomic_read(&(saved_bh->b_count)) < 0) {
+                       if (atomic_read(&saved_bh->b_count) < 0) {
                                reiserfs_warning(s, "journal-945",
                                                 "saved_bh->b_count < 0");
                        }
@@ -1564,7 +1564,7 @@ static int flush_journal_list(struct super_block *s,
                reiserfs_abort(s, -EIO,
                               "Write error while pushing transaction to disk in %s",
                               __func__);
-      flush_older_and_return:
+flush_older_and_return:
 
        /*
         * before we can update the journal header block, we _must_ flush all
@@ -1614,7 +1614,7 @@ static int flush_journal_list(struct super_block *s,
         * help find code using dead lists later on
         */
        jl->j_len = 0;
-       atomic_set(&(jl->j_nonzerolen), 0);
+       atomic_set(&jl->j_nonzerolen, 0);
        jl->j_start = 0;
        jl->j_realblock = NULL;
        jl->j_commit_bh = NULL;
@@ -1670,7 +1670,7 @@ static int write_one_transaction(struct super_block *s,
                        }
                        put_bh(tmp_bh);
                }
-             next:
+next:
                cn = cn->next;
                cond_resched();
        }
@@ -1770,7 +1770,7 @@ static int kupdate_transactions(struct super_block *s,
                write_chunk(&chunk);
        }
 
-      done:
+done:
        mutex_unlock(&journal->j_flush_mutex);
        return ret;
 }
@@ -1873,7 +1873,7 @@ void remove_journal_hash(struct super_block *sb,
                         * dec the nonzerolen
                         */
                        if (cur->bh && cur->jlist)
-                               atomic_dec(&(cur->jlist->j_nonzerolen));
+                               atomic_dec(&cur->jlist->j_nonzerolen);
                        cur->bh = NULL;
                        cur->jlist = NULL;
                }
@@ -1925,12 +1925,11 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
                 * make sure something gets logged to force
                 * our way into the flush code
                 */
-               if (!journal_join(&myth, sb, 1)) {
+               if (!journal_join(&myth, sb)) {
                        reiserfs_prepare_for_journal(sb,
                                                     SB_BUFFER_WITH_SB(sb),
                                                     1);
-                       journal_mark_dirty(&myth, sb,
-                                          SB_BUFFER_WITH_SB(sb));
+                       journal_mark_dirty(&myth, SB_BUFFER_WITH_SB(sb));
                        do_journal_end(&myth, FLUSH_ALL);
                        flushed = 1;
                }
@@ -1939,12 +1938,11 @@ static int do_journal_release(struct reiserfs_transaction_handle *th,
        /* this also catches errors during the do_journal_end above */
        if (!error && reiserfs_is_journal_aborted(journal)) {
                memset(&myth, 0, sizeof(myth));
-               if (!journal_join_abort(&myth, sb, 1)) {
+               if (!journal_join_abort(&myth, sb)) {
                        reiserfs_prepare_for_journal(sb,
                                                     SB_BUFFER_WITH_SB(sb),
                                                     1);
-                       journal_mark_dirty(&myth, sb,
-                                          SB_BUFFER_WITH_SB(sb));
+                       journal_mark_dirty(&myth, SB_BUFFER_WITH_SB(sb));
                        do_journal_end(&myth, FLUSH_ALL);
                }
        }
@@ -2231,7 +2229,7 @@ static int journal_read_transaction(struct super_block *sb,
                        reiserfs_warning(sb, "journal-1204",
                                         "REPLAY FAILURE fsck required! "
                                         "Trying to replay onto a log block");
-                     abort_replay:
+abort_replay:
                        brelse_array(log_blocks, i);
                        brelse_array(real_blocks, i);
                        brelse(c_bh);
@@ -2493,7 +2491,7 @@ static int journal_read(struct super_block *sb)
                brelse(d_bh);
        }
 
-      start_log_replay:
+start_log_replay:
        cur_dblock = oldest_start;
        if (oldest_trans_id) {
                reiserfs_debug(sb, REISERFS_DEBUG_CODE,
@@ -2838,20 +2836,20 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
        journal->j_start = 0;
        journal->j_len = 0;
        journal->j_len_alloc = 0;
-       atomic_set(&(journal->j_wcount), 0);
-       atomic_set(&(journal->j_async_throttle), 0);
+       atomic_set(&journal->j_wcount, 0);
+       atomic_set(&journal->j_async_throttle, 0);
        journal->j_bcount = 0;
        journal->j_trans_start_time = 0;
        journal->j_last = NULL;
        journal->j_first = NULL;
-       init_waitqueue_head(&(journal->j_join_wait));
+       init_waitqueue_head(&journal->j_join_wait);
        mutex_init(&journal->j_mutex);
        mutex_init(&journal->j_flush_mutex);
 
        journal->j_trans_id = 10;
        journal->j_mount_id = 10;
        journal->j_state = 0;
-       atomic_set(&(journal->j_jlock), 0);
+       atomic_set(&journal->j_jlock, 0);
        journal->j_cnode_free_list = allocate_cnodes(num_cnodes);
        journal->j_cnode_free_orig = journal->j_cnode_free_list;
        journal->j_cnode_free = journal->j_cnode_free_list ? num_cnodes : 0;
@@ -2894,7 +2892,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
        INIT_DELAYED_WORK(&journal->j_work, flush_async_commits);
        journal->j_work_sb = sb;
        return 0;
-      free_and_return:
+free_and_return:
        free_journal_ram(sb);
        return 1;
 }
@@ -2915,7 +2913,7 @@ int journal_transaction_should_end(struct reiserfs_transaction_handle *th,
                return 0;
        if (journal->j_must_wait > 0 ||
            (journal->j_len_alloc + new_alloc) >= journal->j_max_batch ||
-           atomic_read(&(journal->j_jlock)) ||
+           atomic_read(&journal->j_jlock) ||
            (now - journal->j_trans_start_time) > journal->j_max_trans_age ||
            journal->j_cnode_free < (journal->j_trans_max * 3)) {
                return 1;
@@ -3033,7 +3031,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
        th->t_refcount = 1;
        th->t_super = sb;
 
-      relock:
+relock:
        lock_journal(sb);
        if (join != JBEGIN_ABORT && reiserfs_is_journal_aborted(journal)) {
                unlock_journal(sb);
@@ -3094,7 +3092,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
                        }
                        goto relock;
                }
-               retval = journal_join(&myth, sb, 1);
+               retval = journal_join(&myth, sb);
                if (retval)
                        goto out_fail;
 
@@ -3115,7 +3113,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
        if (journal->j_trans_start_time == 0) {
                journal->j_trans_start_time = get_seconds();
        }
-       atomic_inc(&(journal->j_wcount));
+       atomic_inc(&journal->j_wcount);
        journal->j_len_alloc += nblocks;
        th->t_blocks_logged = 0;
        th->t_blocks_allocated = nblocks;
@@ -3124,7 +3122,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
        INIT_LIST_HEAD(&th->t_list);
        return 0;
 
-      out_fail:
+out_fail:
        memset(th, 0, sizeof(*th));
        /*
         * Re-set th->t_super, so we can properly keep track of how many
@@ -3183,7 +3181,7 @@ int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *th)
 }
 
 static int journal_join(struct reiserfs_transaction_handle *th,
-                       struct super_block *sb, unsigned long nblocks)
+                       struct super_block *sb)
 {
        struct reiserfs_transaction_handle *cur_th = current->journal_info;
 
@@ -3193,11 +3191,11 @@ static int journal_join(struct reiserfs_transaction_handle *th,
         */
        th->t_handle_save = cur_th;
        BUG_ON(cur_th && cur_th->t_refcount > 1);
-       return do_journal_begin_r(th, sb, nblocks, JBEGIN_JOIN);
+       return do_journal_begin_r(th, sb, 1, JBEGIN_JOIN);
 }
 
 int journal_join_abort(struct reiserfs_transaction_handle *th,
-                      struct super_block *sb, unsigned long nblocks)
+                      struct super_block *sb)
 {
        struct reiserfs_transaction_handle *cur_th = current->journal_info;
 
@@ -3207,7 +3205,7 @@ int journal_join_abort(struct reiserfs_transaction_handle *th,
         */
        th->t_handle_save = cur_th;
        BUG_ON(cur_th && cur_th->t_refcount > 1);
-       return do_journal_begin_r(th, sb, nblocks, JBEGIN_ABORT);
+       return do_journal_begin_r(th, sb, 1, JBEGIN_ABORT);
 }
 
 int journal_begin(struct reiserfs_transaction_handle *th,
@@ -3268,8 +3266,9 @@ int journal_begin(struct reiserfs_transaction_handle *th,
  * if j_len, is bigger than j_len_alloc, it pushes j_len_alloc to 10 + j_len.
  */
 int journal_mark_dirty(struct reiserfs_transaction_handle *th,
-                      struct super_block *sb, struct buffer_head *bh)
+                      struct buffer_head *bh)
 {
+       struct super_block *sb = th->t_super;
        struct reiserfs_journal *journal = SB_JOURNAL(sb);
        struct reiserfs_journal_cnode *cn = NULL;
        int count_already_incd = 0;
@@ -3307,10 +3306,10 @@ int journal_mark_dirty(struct reiserfs_transaction_handle *th,
                                 buffer_journal_dirty(bh) ? ' ' : '!');
        }
 
-       if (atomic_read(&(journal->j_wcount)) <= 0) {
+       if (atomic_read(&journal->j_wcount) <= 0) {
                reiserfs_warning(sb, "journal-1409",
                                 "returning because j_wcount was %d",
-                                atomic_read(&(journal->j_wcount)));
+                                atomic_read(&journal->j_wcount));
                return 1;
        }
        /*
@@ -3449,7 +3448,7 @@ static int remove_from_transaction(struct super_block *sb,
                clear_buffer_dirty(bh);
                clear_buffer_journal_test(bh);
                put_bh(bh);
-               if (atomic_read(&(bh->b_count)) < 0) {
+               if (atomic_read(&bh->b_count) < 0) {
                        reiserfs_warning(sb, "journal-1752",
                                         "b_count < 0");
                }
@@ -3498,7 +3497,7 @@ static int can_dirty(struct reiserfs_journal_cnode *cn)
        cur = cn->hnext;
        while (cur && can_dirty) {
                if (cur->jlist && cur->jlist->j_len > 0 &&
-                   atomic_read(&(cur->jlist->j_commit_left)) > 0 && cur->bh &&
+                   atomic_read(&cur->jlist->j_commit_left) > 0 && cur->bh &&
                    cur->blocknr && cur->sb == sb && cur->blocknr == blocknr) {
                        can_dirty = 0;
                }
@@ -3522,7 +3521,7 @@ int journal_end_sync(struct reiserfs_transaction_handle *th)
        if (journal->j_len == 0) {
                reiserfs_prepare_for_journal(sb, SB_BUFFER_WITH_SB(sb),
                                             1);
-               journal_mark_dirty(th, sb, SB_BUFFER_WITH_SB(sb));
+               journal_mark_dirty(th, SB_BUFFER_WITH_SB(sb));
        }
        return do_journal_end(th, COMMIT_NOW | WAIT);
 }
@@ -3572,12 +3571,11 @@ void reiserfs_flush_old_commits(struct super_block *sb)
            journal->j_trans_start_time > 0 &&
            journal->j_len > 0 &&
            (now - journal->j_trans_start_time) > journal->j_max_trans_age) {
-               if (!journal_join(&th, sb, 1)) {
+               if (!journal_join(&th, sb)) {
                        reiserfs_prepare_for_journal(sb,
                                                     SB_BUFFER_WITH_SB(sb),
                                                     1);
-                       journal_mark_dirty(&th, sb,
-                                          SB_BUFFER_WITH_SB(sb));
+                       journal_mark_dirty(&th, SB_BUFFER_WITH_SB(sb));
 
                        /*
                         * we're only being called from kreiserfsd, it makes
@@ -3625,8 +3623,8 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, int flags)
 
        journal->j_len_alloc -= (th->t_blocks_allocated - th->t_blocks_logged);
        /* <= 0 is allowed.  unmounting might not call begin */
-       if (atomic_read(&(journal->j_wcount)) > 0)
-               atomic_dec(&(journal->j_wcount));
+       if (atomic_read(&journal->j_wcount) > 0)
+               atomic_dec(&journal->j_wcount);
 
        /*
         * BUG, deal with case where j_len is 0, but people previously
@@ -3644,7 +3642,7 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, int flags)
         * because the rest of journal end was already done for this
         * transaction.
         */
-       if (atomic_read(&(journal->j_wcount)) > 0) {
+       if (atomic_read(&journal->j_wcount) > 0) {
                if (flush || commit_now) {
                        unsigned trans_id;
 
@@ -3652,7 +3650,7 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, int flags)
                        trans_id = jl->j_trans_id;
                        if (wait_on_commit)
                                jl->j_state |= LIST_COMMIT_PENDING;
-                       atomic_set(&(journal->j_jlock), 1);
+                       atomic_set(&journal->j_jlock, 1);
                        if (flush) {
                                journal->j_next_full_flush = 1;
                        }
@@ -3668,7 +3666,7 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, int flags)
                                } else {
                                        lock_journal(sb);
                                        if (journal->j_trans_id == trans_id) {
-                                               atomic_set(&(journal->j_jlock),
+                                               atomic_set(&journal->j_jlock,
                                                           1);
                                        }
                                        unlock_journal(sb);
@@ -3695,7 +3693,7 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, int flags)
        }
        /* don't batch when someone is waiting on j_join_wait */
        /* don't batch when syncing the commit or flushing the whole trans */
-       if (!(journal->j_must_wait > 0) && !(atomic_read(&(journal->j_jlock)))
+       if (!(journal->j_must_wait > 0) && !(atomic_read(&journal->j_jlock))
            && !flush && !commit_now && (journal->j_len < journal->j_max_batch)
            && journal->j_len_alloc < journal->j_max_batch
            && journal->j_cnode_free > (journal->j_trans_max * 3)) {
@@ -3794,7 +3792,7 @@ int journal_mark_freed(struct reiserfs_transaction_handle *th,
                                                cleaned = 1;
                                                put_bh(cn->bh);
                                                if (atomic_read
-                                                   (&(cn->bh->b_count)) < 0) {
+                                                   (&cn->bh->b_count) < 0) {
                                                        reiserfs_warning(sb,
                                                                 "journal-2138",
                                                                 "cn->bh->b_count < 0");
@@ -3805,9 +3803,8 @@ int journal_mark_freed(struct reiserfs_transaction_handle *th,
                                         * we MUST dec nonzerolen
                                         */
                                        if (cn->jlist) {
-                                               atomic_dec(&
-                                                          (cn->jlist->
-                                                           j_nonzerolen));
+                                               atomic_dec(&cn->jlist->
+                                                          j_nonzerolen);
                                        }
                                        cn->bh = NULL;
                                }
@@ -3863,7 +3860,7 @@ static int __commit_trans_jl(struct inode *inode, unsigned long id,
                if (journal->j_trans_id != id) {
                        reiserfs_prepare_for_journal(sb, SB_BUFFER_WITH_SB(sb),
                                                     1);
-                       journal_mark_dirty(&th, sb, SB_BUFFER_WITH_SB(sb));
+                       journal_mark_dirty(&th, SB_BUFFER_WITH_SB(sb));
                        ret = journal_end(&th);
                        goto flush_commit_only;
                }
@@ -3878,7 +3875,7 @@ static int __commit_trans_jl(struct inode *inode, unsigned long id,
                 * the inode still exists.  We know the list is still around
                 * if we've got a larger transaction id than the oldest list
                 */
-             flush_commit_only:
+flush_commit_only:
                if (journal_list_still_alive(inode->i_sb, id)) {
                        /*
                         * we only set ret to 1 when we know for sure
@@ -4014,7 +4011,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, int flags)
        if (journal->j_len == 0) {
                reiserfs_prepare_for_journal(sb, SB_BUFFER_WITH_SB(sb),
                                             1);
-               journal_mark_dirty(th, sb, SB_BUFFER_WITH_SB(sb));
+               journal_mark_dirty(th, SB_BUFFER_WITH_SB(sb));
        }
 
        lock_journal(sb);
@@ -4246,7 +4243,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, int flags)
        journal->j_start =
            (journal->j_start + journal->j_len +
             2) % SB_ONDISK_JOURNAL_SIZE(sb);
-       atomic_set(&(journal->j_wcount), 0);
+       atomic_set(&journal->j_wcount, 0);
        journal->j_bcount = 0;
        journal->j_last = NULL;
        journal->j_first = NULL;
@@ -4304,7 +4301,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, int flags)
         * transactions that might get overwritten.  If any journal lists
         * are very old flush them as well.
         */
-      first_jl:
+first_jl:
        list_for_each_safe(entry, safe, &journal->j_journal_list) {
                temp_jl = JOURNAL_LIST_ENTRY(entry);
                if (journal->j_start <= temp_jl->j_start) {
@@ -4351,17 +4348,17 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, int flags)
                               "could not get a list bitmap");
        }
 
-       atomic_set(&(journal->j_jlock), 0);
+       atomic_set(&journal->j_jlock, 0);
        unlock_journal(sb);
        /* wake up any body waiting to join. */
        clear_bit(J_WRITERS_QUEUED, &journal->j_state);
-       wake_up(&(journal->j_join_wait));
+       wake_up(&journal->j_join_wait);
 
        if (!flush && wait_on_commit &&
            journal_list_still_alive(sb, commit_trans_id)) {
                flush_commit_list(sb, jl, 1);
        }
-      out:
+out:
        reiserfs_check_lock_depth(sb, "journal end2");
 
        memset(th, 0, sizeof(*th));