Skip to content

Commit 67a841f

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: clean up buffer allocation in xlog_do_recovery_pass
Merge the initial xlog_alloc_buffer calls, and pass the variable designating the length that is initialized to 1 above instead of passing the open coded 1 directly. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 45cf976 commit 67a841f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

fs/xfs/xfs_log_recover.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,6 +3010,10 @@ xlog_do_recovery_pass(
30103010
for (i = 0; i < XLOG_RHASH_SIZE; i++)
30113011
INIT_HLIST_HEAD(&rhash[i]);
30123012

3013+
hbp = xlog_alloc_buffer(log, hblks);
3014+
if (!hbp)
3015+
return -ENOMEM;
3016+
30133017
/*
30143018
* Read the header of the tail block and get the iclog buffer size from
30153019
* h_size. Use this to tell how many sectors make up the log header.
@@ -3020,10 +3024,6 @@ xlog_do_recovery_pass(
30203024
* iclog header and extract the header size from it. Get a
30213025
* new hbp that is the correct size.
30223026
*/
3023-
hbp = xlog_alloc_buffer(log, 1);
3024-
if (!hbp)
3025-
return -ENOMEM;
3026-
30273027
error = xlog_bread(log, tail_blk, 1, hbp, &offset);
30283028
if (error)
30293029
goto bread_err1;
@@ -3067,16 +3067,15 @@ xlog_do_recovery_pass(
30673067
if (hblks > 1) {
30683068
kvfree(hbp);
30693069
hbp = xlog_alloc_buffer(log, hblks);
3070+
if (!hbp)
3071+
return -ENOMEM;
30703072
}
30713073
}
30723074
} else {
30733075
ASSERT(log->l_sectBBsize == 1);
3074-
hbp = xlog_alloc_buffer(log, 1);
30753076
h_size = XLOG_BIG_RECORD_BSIZE;
30763077
}
30773078

3078-
if (!hbp)
3079-
return -ENOMEM;
30803079
dbp = xlog_alloc_buffer(log, BTOBB(h_size));
30813080
if (!dbp) {
30823081
kvfree(hbp);

0 commit comments

Comments
 (0)