提交 cb02d6fe 编写于 作者: D Darrick J. Wong 提交者: Jialin Zhang

xfs: convert buf_cancel_table allocation to kmalloc_array

mainline inclusion
from mainline-v5.19-rc1
commit 910bbdf2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
CVE: NA

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

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

While we're messing around with how recovery allocates and frees the
buffer cancellation table, convert the allocation to use kmalloc_array
instead of the old kmem_alloc APIs, and make it handle a null return,
even though that's not likely.
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDave Chinner <dchinner@redhat.com>
Signed-off-by: NDave Chinner <david@fromorbit.com>

Conflicts:
	fs/xfs/libxfs/xfs_log_recover.h
Signed-off-by: Nyangerkun <yangerkun@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
上级 245459fb
...@@ -118,7 +118,7 @@ bool xlog_is_buffer_cancelled(struct xlog *log, xfs_daddr_t blkno, uint len); ...@@ -118,7 +118,7 @@ bool xlog_is_buffer_cancelled(struct xlog *log, xfs_daddr_t blkno, uint len);
void xlog_recover_release_intent(struct xlog *log, unsigned short intent_type, void xlog_recover_release_intent(struct xlog *log, unsigned short intent_type,
uint64_t intent_id); uint64_t intent_id);
void xlog_alloc_buf_cancel_table(struct xlog *log); int xlog_alloc_buf_cancel_table(struct xlog *log);
void xlog_free_buf_cancel_table(struct xlog *log); void xlog_free_buf_cancel_table(struct xlog *log);
#ifdef DEBUG #ifdef DEBUG
......
...@@ -1015,19 +1015,25 @@ xlog_check_buf_cancel_table( ...@@ -1015,19 +1015,25 @@ xlog_check_buf_cancel_table(
} }
#endif #endif
void int
xlog_alloc_buf_cancel_table( xlog_alloc_buf_cancel_table(
struct xlog *log) struct xlog *log)
{ {
void *p;
int i; int i;
ASSERT(log->l_buf_cancel_table == NULL); ASSERT(log->l_buf_cancel_table == NULL);
log->l_buf_cancel_table = kmem_zalloc(XLOG_BC_TABLE_SIZE * p = kmalloc_array(XLOG_BC_TABLE_SIZE, sizeof(struct list_head),
sizeof(struct list_head), GFP_KERNEL);
0); if (!p)
return -ENOMEM;
log->l_buf_cancel_table = p;
for (i = 0; i < XLOG_BC_TABLE_SIZE; i++) for (i = 0; i < XLOG_BC_TABLE_SIZE; i++)
INIT_LIST_HEAD(&log->l_buf_cancel_table[i]); INIT_LIST_HEAD(&log->l_buf_cancel_table[i]);
return 0;
} }
void void
......
...@@ -3237,7 +3237,9 @@ xlog_do_log_recovery( ...@@ -3237,7 +3237,9 @@ xlog_do_log_recovery(
* First do a pass to find all of the cancelled buf log items. * First do a pass to find all of the cancelled buf log items.
* Store them in the buf_cancel_table for use in the second pass. * Store them in the buf_cancel_table for use in the second pass.
*/ */
xlog_alloc_buf_cancel_table(log); error = xlog_alloc_buf_cancel_table(log);
if (error)
return error;
error = xlog_do_recovery_pass(log, head_blk, tail_blk, error = xlog_do_recovery_pass(log, head_blk, tail_blk,
XLOG_RECOVER_PASS1, NULL); XLOG_RECOVER_PASS1, NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册