Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Darrick J. Wong and committed by
Dave Chinner
910bbdf2 8db074bd

+14 -6
+1 -1
fs/xfs/libxfs/xfs_log_recover.h
··· 122 122 struct xfs_inode **ipp); 123 123 void xlog_recover_release_intent(struct xlog *log, unsigned short intent_type, 124 124 uint64_t intent_id); 125 - void xlog_alloc_buf_cancel_table(struct xlog *log); 125 + int xlog_alloc_buf_cancel_table(struct xlog *log); 126 126 void xlog_free_buf_cancel_table(struct xlog *log); 127 127 128 128 #ifdef DEBUG
+10 -4
fs/xfs/xfs_buf_item_recover.c
··· 1015 1015 } 1016 1016 #endif 1017 1017 1018 - void 1018 + int 1019 1019 xlog_alloc_buf_cancel_table( 1020 1020 struct xlog *log) 1021 1021 { 1022 + void *p; 1022 1023 int i; 1023 1024 1024 1025 ASSERT(log->l_buf_cancel_table == NULL); 1025 1026 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; 1029 1033 for (i = 0; i < XLOG_BC_TABLE_SIZE; i++) 1030 1034 INIT_LIST_HEAD(&log->l_buf_cancel_table[i]); 1035 + 1036 + return 0; 1031 1037 } 1032 1038 1033 1039 void
+3 -1
fs/xfs/xfs_log_recover.c
··· 3231 3231 * First do a pass to find all of the cancelled buf log items. 3232 3232 * Store them in the buf_cancel_table for use in the second pass. 3233 3233 */ 3234 - xlog_alloc_buf_cancel_table(log); 3234 + error = xlog_alloc_buf_cancel_table(log); 3235 + if (error) 3236 + return error; 3235 3237 3236 3238 error = xlog_do_recovery_pass(log, head_blk, tail_blk, 3237 3239 XLOG_RECOVER_PASS1, NULL);