提交 2e5ec977 编写于 作者: D Dave Chinner 提交者: Zheng Zengkai

xfs: rework xlog_state_do_callback()

mainline-inclusion
from mainline-v5.14-rc4
commit 8bb92005
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4V7IK
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8bb92005b0e4682a6e5dad131c5f3636c7d56dc1

-------------------------------------------------

Clean it up a bit by factoring and rearranging some of the code.
Signed-off-by: NDave Chinner <dchinner@redhat.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Signed-off-by: NLihong Kou <koulihong@huawei.com>
Reviewed-by: Nguoxuenan <guoxuenan@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 da90a037
...@@ -2689,29 +2689,19 @@ xlog_state_iodone_process_iclog( ...@@ -2689,29 +2689,19 @@ xlog_state_iodone_process_iclog(
} }
} }
STATIC void /*
xlog_state_do_callback( * Loop over all the iclogs, running attached callbacks on them. Return true if
* we ran any callbacks, indicating that we dropped the icloglock.
*/
static bool
xlog_state_do_iclog_callbacks(
struct xlog *log) struct xlog *log)
__releases(&log->l_icloglock)
__acquires(&log->l_icloglock)
{ {
struct xlog_in_core *iclog; struct xlog_in_core *first_iclog = log->l_iclog;
struct xlog_in_core *first_iclog; struct xlog_in_core *iclog = first_iclog;
bool cycled_icloglock; bool ran_callback = false;
int flushcnt = 0;
int repeats = 0;
spin_lock(&log->l_icloglock);
do {
/*
* Scan all iclogs starting with the one pointed to by the
* log. Reset this starting point each time the log is
* unlocked (during callbacks).
*
* Keep looping through iclogs until one full pass is made
* without running any callbacks.
*/
cycled_icloglock = false;
first_iclog = log->l_iclog;
iclog = first_iclog;
do { do {
LIST_HEAD(cb_list); LIST_HEAD(cb_list);
...@@ -2730,7 +2720,7 @@ xlog_state_do_callback( ...@@ -2730,7 +2720,7 @@ xlog_state_do_callback(
trace_xlog_iclog_callbacks_start(iclog, _RET_IP_); trace_xlog_iclog_callbacks_start(iclog, _RET_IP_);
xlog_cil_process_committed(&cb_list); xlog_cil_process_committed(&cb_list);
trace_xlog_iclog_callbacks_done(iclog, _RET_IP_); trace_xlog_iclog_callbacks_done(iclog, _RET_IP_);
cycled_icloglock = true; ran_callback = true;
spin_lock(&log->l_icloglock); spin_lock(&log->l_icloglock);
if (xlog_is_shutdown(log)) if (xlog_is_shutdown(log))
...@@ -2740,6 +2730,26 @@ xlog_state_do_callback( ...@@ -2740,6 +2730,26 @@ xlog_state_do_callback(
iclog = iclog->ic_next; iclog = iclog->ic_next;
} while (iclog != first_iclog); } while (iclog != first_iclog);
return ran_callback;
}
/*
* Loop running iclog completion callbacks until there are no more iclogs in a
* state that can run callbacks.
*/
STATIC void
xlog_state_do_callback(
struct xlog *log)
{
int flushcnt = 0;
int repeats = 0;
spin_lock(&log->l_icloglock);
while (xlog_state_do_iclog_callbacks(log)) {
if (xlog_is_shutdown(log))
break;
if (++repeats > 5000) { if (++repeats > 5000) {
flushcnt += repeats; flushcnt += repeats;
repeats = 0; repeats = 0;
...@@ -2747,7 +2757,7 @@ xlog_state_do_callback( ...@@ -2747,7 +2757,7 @@ xlog_state_do_callback(
"%s: possible infinite loop (%d iterations)", "%s: possible infinite loop (%d iterations)",
__func__, flushcnt); __func__, flushcnt);
} }
} while (!xlog_is_shutdown(log) && cycled_icloglock); }
if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE || if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE ||
xlog_is_shutdown(log)) xlog_is_shutdown(log))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册