提交 c38a5168 编写于 作者: J Jan Kara 提交者: Yang Yingliang

jbd2: Rename h_buffer_credits to h_total_credits

mainline inclusion
from mainline-5.5-rc1
commit 933f1c1e0b75bbc29730eef07c9e196c6dfd37e5
category: bugfix
bugzilla: 25031
CVE: NA
---------------------------

The credit counter now contains both buffer and revoke descriptor block
credits. Rename to counter to h_total_credits to reflect that. No
functional change.
Reviewed-by: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: NJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191105164437.32602-21-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>

Conflict:
  fs/jbd2/transaction.c
Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: NYang Erkun <yangerkun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 38d8c053
...@@ -288,12 +288,12 @@ static int start_this_handle(journal_t *journal, handle_t *handle, ...@@ -288,12 +288,12 @@ static int start_this_handle(journal_t *journal, handle_t *handle,
gfp_t gfp_mask) gfp_t gfp_mask)
{ {
transaction_t *transaction, *new_transaction = NULL; transaction_t *transaction, *new_transaction = NULL;
int blocks = handle->h_buffer_credits; int blocks = handle->h_total_credits;
int rsv_blocks = 0; int rsv_blocks = 0;
unsigned long ts = jiffies; unsigned long ts = jiffies;
if (handle->h_rsv_handle) if (handle->h_rsv_handle)
rsv_blocks = handle->h_rsv_handle->h_buffer_credits; rsv_blocks = handle->h_rsv_handle->h_total_credits;
/* /*
* Limit the number of reserved credits to 1/2 of maximum transaction * Limit the number of reserved credits to 1/2 of maximum transaction
...@@ -415,7 +415,7 @@ static handle_t *new_handle(int nblocks) ...@@ -415,7 +415,7 @@ static handle_t *new_handle(int nblocks)
handle_t *handle = jbd2_alloc_handle(GFP_NOFS); handle_t *handle = jbd2_alloc_handle(GFP_NOFS);
if (!handle) if (!handle)
return NULL; return NULL;
handle->h_buffer_credits = nblocks; handle->h_total_credits = nblocks;
handle->h_ref = 1; handle->h_ref = 1;
return handle; return handle;
...@@ -504,7 +504,7 @@ static void __jbd2_journal_unreserve_handle(handle_t *handle) ...@@ -504,7 +504,7 @@ static void __jbd2_journal_unreserve_handle(handle_t *handle)
journal_t *journal = handle->h_journal; journal_t *journal = handle->h_journal;
WARN_ON(!handle->h_reserved); WARN_ON(!handle->h_reserved);
sub_reserved_credits(journal, handle->h_buffer_credits); sub_reserved_credits(journal, handle->h_total_credits);
} }
void jbd2_journal_free_reserved(handle_t *handle) void jbd2_journal_free_reserved(handle_t *handle)
...@@ -628,10 +628,10 @@ int jbd2_journal_extend(handle_t *handle, int nblocks, int revoke_records) ...@@ -628,10 +628,10 @@ int jbd2_journal_extend(handle_t *handle, int nblocks, int revoke_records)
trace_jbd2_handle_extend(journal->j_fs_dev->bd_dev, trace_jbd2_handle_extend(journal->j_fs_dev->bd_dev,
transaction->t_tid, transaction->t_tid,
handle->h_type, handle->h_line_no, handle->h_type, handle->h_line_no,
handle->h_buffer_credits, handle->h_total_credits,
nblocks); nblocks);
handle->h_buffer_credits += nblocks; handle->h_total_credits += nblocks;
handle->h_requested_credits += nblocks; handle->h_requested_credits += nblocks;
handle->h_revoke_credits += revoke_records; handle->h_revoke_credits += revoke_records;
handle->h_revoke_credits_requested += revoke_records; handle->h_revoke_credits_requested += revoke_records;
...@@ -666,15 +666,15 @@ static void stop_this_handle(handle_t *handle) ...@@ -666,15 +666,15 @@ static void stop_this_handle(handle_t *handle)
int rr_per_blk = journal->j_revoke_records_per_block; int rr_per_blk = journal->j_revoke_records_per_block;
WARN_ON_ONCE(DIV_ROUND_UP(revokes, rr_per_blk) WARN_ON_ONCE(DIV_ROUND_UP(revokes, rr_per_blk)
> handle->h_buffer_credits); > handle->h_total_credits);
t_revokes = atomic_add_return(revokes, t_revokes = atomic_add_return(revokes,
&transaction->t_outstanding_revokes); &transaction->t_outstanding_revokes);
revoke_descriptors = revoke_descriptors =
DIV_ROUND_UP(t_revokes, rr_per_blk) - DIV_ROUND_UP(t_revokes, rr_per_blk) -
DIV_ROUND_UP(t_revokes - revokes, rr_per_blk); DIV_ROUND_UP(t_revokes - revokes, rr_per_blk);
handle->h_buffer_credits -= revoke_descriptors; handle->h_total_credits -= revoke_descriptors;
} }
atomic_sub(handle->h_buffer_credits, atomic_sub(handle->h_total_credits,
&transaction->t_outstanding_credits); &transaction->t_outstanding_credits);
if (handle->h_rsv_handle) if (handle->h_rsv_handle)
__jbd2_journal_unreserve_handle(handle->h_rsv_handle); __jbd2_journal_unreserve_handle(handle->h_rsv_handle);
...@@ -738,7 +738,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, int revoke_records, ...@@ -738,7 +738,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, int revoke_records,
read_unlock(&journal->j_state_lock); read_unlock(&journal->j_state_lock);
if (need_to_start) if (need_to_start)
jbd2_log_start_commit(journal, tid); jbd2_log_start_commit(journal, tid);
handle->h_buffer_credits = nblocks + handle->h_total_credits = nblocks +
DIV_ROUND_UP(revoke_records, DIV_ROUND_UP(revoke_records,
journal->j_revoke_records_per_block); journal->j_revoke_records_per_block);
handle->h_revoke_credits = revoke_records; handle->h_revoke_credits = revoke_records;
...@@ -1443,12 +1443,12 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) ...@@ -1443,12 +1443,12 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
* of the transaction. This needs to be done * of the transaction. This needs to be done
* once a transaction -bzzz * once a transaction -bzzz
*/ */
if (handle->h_buffer_credits <= 0) { if (handle->h_total_credits <= 0) {
ret = -ENOSPC; ret = -ENOSPC;
goto out_unlock_bh; goto out_unlock_bh;
} }
jh->b_modified = 1; jh->b_modified = 1;
handle->h_buffer_credits--; handle->h_total_credits--;
} }
/* /*
...@@ -1692,7 +1692,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh) ...@@ -1692,7 +1692,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
drop: drop:
if (drop_reserve) { if (drop_reserve) {
/* no need to reserve log space for this block -bzzz */ /* no need to reserve log space for this block -bzzz */
handle->h_buffer_credits++; handle->h_total_credits++;
} }
return err; return err;
...@@ -1753,7 +1753,7 @@ int jbd2_journal_stop(handle_t *handle) ...@@ -1753,7 +1753,7 @@ int jbd2_journal_stop(handle_t *handle)
jiffies - handle->h_start_jiffies, jiffies - handle->h_start_jiffies,
handle->h_sync, handle->h_requested_credits, handle->h_sync, handle->h_requested_credits,
(handle->h_requested_credits - (handle->h_requested_credits -
handle->h_buffer_credits)); handle->h_total_credits));
/* /*
* Implement synchronous transaction batching. If the handle * Implement synchronous transaction batching. If the handle
......
...@@ -480,7 +480,8 @@ struct jbd2_revoke_table_s; ...@@ -480,7 +480,8 @@ struct jbd2_revoke_table_s;
* @h_transaction: Which compound transaction is this update a part of? * @h_transaction: Which compound transaction is this update a part of?
* @h_journal: Which journal handle belongs to - used iff h_reserved set. * @h_journal: Which journal handle belongs to - used iff h_reserved set.
* @h_rsv_handle: Handle reserved for finishing the logical operation. * @h_rsv_handle: Handle reserved for finishing the logical operation.
* @h_buffer_credits: Number of remaining buffers we are allowed to dirty. * @h_total_credits: Number of remaining buffers we are allowed to add to
journal. These are dirty buffers and revoke descriptor blocks.
* @h_revoke_credits: Number of remaining revoke records available for handle * @h_revoke_credits: Number of remaining revoke records available for handle
* @h_ref: Reference count on this handle. * @h_ref: Reference count on this handle.
* @h_err: Field for caller's use to track errors through large fs operations. * @h_err: Field for caller's use to track errors through large fs operations.
...@@ -491,7 +492,7 @@ struct jbd2_revoke_table_s; ...@@ -491,7 +492,7 @@ struct jbd2_revoke_table_s;
* @h_type: For handle statistics. * @h_type: For handle statistics.
* @h_line_no: For handle statistics. * @h_line_no: For handle statistics.
* @h_start_jiffies: Handle Start time. * @h_start_jiffies: Handle Start time.
* @h_requested_credits: Holds @h_buffer_credits after handle is started. * @h_requested_credits: Holds @h_total_credits after handle is started.
* @h_revoke_credits_requested: Holds @h_revoke_credits after handle is started. * @h_revoke_credits_requested: Holds @h_revoke_credits after handle is started.
* @saved_alloc_context: Saved context while transaction is open. * @saved_alloc_context: Saved context while transaction is open.
**/ **/
...@@ -509,7 +510,7 @@ struct jbd2_journal_handle ...@@ -509,7 +510,7 @@ struct jbd2_journal_handle
}; };
handle_t *h_rsv_handle; handle_t *h_rsv_handle;
int h_buffer_credits; int h_total_credits;
int h_revoke_credits; int h_revoke_credits;
int h_revoke_credits_requested; int h_revoke_credits_requested;
int h_ref; int h_ref;
...@@ -1658,7 +1659,7 @@ static inline int jbd2_handle_buffer_credits(handle_t *handle) ...@@ -1658,7 +1659,7 @@ static inline int jbd2_handle_buffer_credits(handle_t *handle)
{ {
journal_t *journal = handle->h_transaction->t_journal; journal_t *journal = handle->h_transaction->t_journal;
return handle->h_buffer_credits - return handle->h_total_credits -
DIV_ROUND_UP(handle->h_revoke_credits_requested, DIV_ROUND_UP(handle->h_revoke_credits_requested,
journal->j_revoke_records_per_block); journal->j_revoke_records_per_block);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册