Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195797
b: refs/heads/master
c: 36adecf
h: refs/heads/master
i:
  195795: 085c5ea
v: v3
  • Loading branch information
Alex Elder committed May 19, 2010
1 parent e3cddd9 commit 348024a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ff30a6221d95b609a37410a425937b11a55d465e
refs/heads/master: 36adecff50b69df0369cc2022650c6087aeb255f
42 changes: 29 additions & 13 deletions trunk/fs/xfs/xfs_log_recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ xlog_buf_bbcount_valid(
return bbcount > 0 && bbcount <= log->l_logBBsize;
}

/*
* Allocate a buffer to hold log data. The buffer needs to be able
* to map to a range of nbblks basic blocks at any valid (basic
* block) offset within the log.
*/
STATIC xfs_buf_t *
xlog_get_bp(
xlog_t *log,
Expand All @@ -89,11 +94,26 @@ xlog_get_bp(
return NULL;
}

if (log->l_sectbb_log) {
if (nbblks > 1)
nbblks += xlog_sectbb(log);
nbblks = round_up(nbblks, xlog_sectbb(log));
}
/*
* We do log I/O in units of log sectors (a power-of-2
* multiple of the basic block size), so we round up the
* requested size to acommodate the basic blocks required
* for complete log sectors.
*
* In addition, the buffer may be used for a non-sector-
* aligned block offset, in which case an I/O of the
* requested size could extend beyond the end of the
* buffer. If the requested size is only 1 basic block it
* will never straddle a sector boundary, so this won't be
* an issue. Nor will this be a problem if the log I/O is
* done in basic blocks (sector size 1). But otherwise we
* extend the buffer by one extra log sector to ensure
* there's space to accomodate this possiblility.
*/
if (nbblks > 1 && log->l_sectbb_log)
nbblks += xlog_sectbb(log);
nbblks = round_up(nbblks, xlog_sectbb(log));

return xfs_buf_get_noaddr(BBTOB(nbblks), log->l_mp->m_logdev_targp);
}

Expand Down Expand Up @@ -142,10 +162,8 @@ xlog_bread_noalign(
return EFSCORRUPTED;
}

if (log->l_sectbb_log) {
blk_no = round_down(blk_no, xlog_sectbb(log));
nbblks = round_up(nbblks, xlog_sectbb(log));
}
blk_no = round_down(blk_no, xlog_sectbb(log));
nbblks = round_up(nbblks, xlog_sectbb(log));

ASSERT(nbblks > 0);
ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp));
Expand Down Expand Up @@ -204,10 +222,8 @@ xlog_bwrite(
return EFSCORRUPTED;
}

if (log->l_sectbb_log) {
blk_no = round_down(blk_no, xlog_sectbb(log));
nbblks = round_up(nbblks, xlog_sectbb(log));
}
blk_no = round_down(blk_no, xlog_sectbb(log));
nbblks = round_up(nbblks, xlog_sectbb(log));

ASSERT(nbblks > 0);
ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp));
Expand Down

0 comments on commit 348024a

Please sign in to comment.