From 34174e0dabd92a4db6f3ef028af837ebf2f161dd Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Tue, 13 Apr 2010 15:22:29 +1000 Subject: [PATCH] --- yaml --- r: 195793 b: refs/heads/master c: 6881a229f66f74e4e0a73504389695213987955b h: refs/heads/master i: 195791: 6632f96174178eb6b51b2e22c670355a3796d6f6 v: v3 --- [refs] | 2 +- trunk/fs/xfs/xfs_log_recover.c | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 04b9d7ef36d4..4b8209ccc1d3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a0e856b0b4d182c4c52b568bd04bd96a172247a7 +refs/heads/master: 6881a229f66f74e4e0a73504389695213987955b diff --git a/trunk/fs/xfs/xfs_log_recover.c b/trunk/fs/xfs/xfs_log_recover.c index f21eb8ad2d97..0d81a9092552 100644 --- a/trunk/fs/xfs/xfs_log_recover.c +++ b/trunk/fs/xfs/xfs_log_recover.c @@ -66,6 +66,9 @@ STATIC void xlog_recover_check_summary(xlog_t *); ((bbs + (log)->l_sectbb_mask + 1) & ~(log)->l_sectbb_mask) : (bbs) ) #define XLOG_SECTOR_ROUNDDOWN_BLKNO(log, bno) ((bno) & ~(log)->l_sectbb_mask) +/* Number of basic blocks in a log sector */ +#define xlog_sectbb(log) (1 << (log)->l_sectbb_log) + STATIC xfs_buf_t * xlog_get_bp( xlog_t *log, @@ -376,12 +379,16 @@ xlog_find_verify_cycle( xfs_caddr_t buf = NULL; int error = 0; + /* + * Greedily allocate a buffer big enough to handle the full + * range of basic blocks we'll be examining. If that fails, + * try a smaller size. We need to be able to read at least + * a log sector, or we're out of luck. + */ bufblks = 1 << ffs(nbblks); - while (!(bp = xlog_get_bp(log, bufblks))) { - /* can't get enough memory to do everything in one big buffer */ bufblks >>= 1; - if (bufblks <= log->l_sectbb_log) + if (bufblks < xlog_sectbb(log)) return ENOMEM; } @@ -1158,10 +1165,16 @@ xlog_write_log_records( int error = 0; int i, j = 0; + /* + * Greedily allocate a buffer big enough to handle the full + * range of basic blocks to be written. If that fails, try + * a smaller size. We need to be able to write at least a + * log sector, or we're out of luck. + */ bufblks = 1 << ffs(blocks); while (!(bp = xlog_get_bp(log, bufblks))) { bufblks >>= 1; - if (bufblks <= log->l_sectbb_log) + if (bufblks < xlog_sectbb(log)) return ENOMEM; }