aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_log_recover.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index f21eb8ad2d97..0d81a9092552 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -66,6 +66,9 @@ STATIC void xlog_recover_check_summary(xlog_t *);
66 ((bbs + (log)->l_sectbb_mask + 1) & ~(log)->l_sectbb_mask) : (bbs) ) 66 ((bbs + (log)->l_sectbb_mask + 1) & ~(log)->l_sectbb_mask) : (bbs) )
67#define XLOG_SECTOR_ROUNDDOWN_BLKNO(log, bno) ((bno) & ~(log)->l_sectbb_mask) 67#define XLOG_SECTOR_ROUNDDOWN_BLKNO(log, bno) ((bno) & ~(log)->l_sectbb_mask)
68 68
69/* Number of basic blocks in a log sector */
70#define xlog_sectbb(log) (1 << (log)->l_sectbb_log)
71
69STATIC xfs_buf_t * 72STATIC xfs_buf_t *
70xlog_get_bp( 73xlog_get_bp(
71 xlog_t *log, 74 xlog_t *log,
@@ -376,12 +379,16 @@ xlog_find_verify_cycle(
376 xfs_caddr_t buf = NULL; 379 xfs_caddr_t buf = NULL;
377 int error = 0; 380 int error = 0;
378 381
382 /*
383 * Greedily allocate a buffer big enough to handle the full
384 * range of basic blocks we'll be examining. If that fails,
385 * try a smaller size. We need to be able to read at least
386 * a log sector, or we're out of luck.
387 */
379 bufblks = 1 << ffs(nbblks); 388 bufblks = 1 << ffs(nbblks);
380
381 while (!(bp = xlog_get_bp(log, bufblks))) { 389 while (!(bp = xlog_get_bp(log, bufblks))) {
382 /* can't get enough memory to do everything in one big buffer */
383 bufblks >>= 1; 390 bufblks >>= 1;
384 if (bufblks <= log->l_sectbb_log) 391 if (bufblks < xlog_sectbb(log))
385 return ENOMEM; 392 return ENOMEM;
386 } 393 }
387 394
@@ -1158,10 +1165,16 @@ xlog_write_log_records(
1158 int error = 0; 1165 int error = 0;
1159 int i, j = 0; 1166 int i, j = 0;
1160 1167
1168 /*
1169 * Greedily allocate a buffer big enough to handle the full
1170 * range of basic blocks to be written. If that fails, try
1171 * a smaller size. We need to be able to write at least a
1172 * log sector, or we're out of luck.
1173 */
1161 bufblks = 1 << ffs(blocks); 1174 bufblks = 1 << ffs(blocks);
1162 while (!(bp = xlog_get_bp(log, bufblks))) { 1175 while (!(bp = xlog_get_bp(log, bufblks))) {
1163 bufblks >>= 1; 1176 bufblks >>= 1;
1164 if (bufblks <= log->l_sectbb_log) 1177 if (bufblks < xlog_sectbb(log))
1165 return ENOMEM; 1178 return ENOMEM;
1166 } 1179 }
1167 1180