Skip to content

Commit 910bbdf

Browse files
Darrick J. Wongdchinner
authored andcommitted
xfs: convert buf_cancel_table allocation to kmalloc_array
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: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
1 parent 8db074b commit 910bbdf

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

fs/xfs/libxfs/xfs_log_recover.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int xlog_recover_iget(struct xfs_mount *mp, xfs_ino_t ino,
122122
struct xfs_inode **ipp);
123123
void xlog_recover_release_intent(struct xlog *log, unsigned short intent_type,
124124
uint64_t intent_id);
125-
void xlog_alloc_buf_cancel_table(struct xlog *log);
125+
int xlog_alloc_buf_cancel_table(struct xlog *log);
126126
void xlog_free_buf_cancel_table(struct xlog *log);
127127

128128
#ifdef DEBUG

fs/xfs/xfs_buf_item_recover.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,19 +1015,25 @@ xlog_check_buf_cancel_table(
10151015
}
10161016
#endif
10171017

1018-
void
1018+
int
10191019
xlog_alloc_buf_cancel_table(
10201020
struct xlog *log)
10211021
{
1022+
void *p;
10221023
int i;
10231024

10241025
ASSERT(log->l_buf_cancel_table == NULL);
10251026

1026-
log->l_buf_cancel_table = kmem_zalloc(XLOG_BC_TABLE_SIZE *
1027-
sizeof(struct list_head),
1028-
0);
1027+
p = kmalloc_array(XLOG_BC_TABLE_SIZE, sizeof(struct list_head),
1028+
GFP_KERNEL);
1029+
if (!p)
1030+
return -ENOMEM;
1031+
1032+
log->l_buf_cancel_table = p;
10291033
for (i = 0; i < XLOG_BC_TABLE_SIZE; i++)
10301034
INIT_LIST_HEAD(&log->l_buf_cancel_table[i]);
1035+
1036+
return 0;
10311037
}
10321038

10331039
void

fs/xfs/xfs_log_recover.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,9 @@ xlog_do_log_recovery(
32313231
* First do a pass to find all of the cancelled buf log items.
32323232
* Store them in the buf_cancel_table for use in the second pass.
32333233
*/
3234-
xlog_alloc_buf_cancel_table(log);
3234+
error = xlog_alloc_buf_cancel_table(log);
3235+
if (error)
3236+
return error;
32353237

32363238
error = xlog_do_recovery_pass(log, head_blk, tail_blk,
32373239
XLOG_RECOVER_PASS1, NULL);

0 commit comments

Comments
 (0)