Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195796
b: refs/heads/master
c: ff30a62
h: refs/heads/master
v: v3
  • Loading branch information
Alex Elder committed May 19, 2010
1 parent 085c5ea commit e3cddd9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 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: 5c17f5339f9dfdee8ad9661e97f8030d75b6bff7
refs/heads/master: ff30a6221d95b609a37410a425937b11a55d465e
38 changes: 26 additions & 12 deletions trunk/fs/xfs/xfs_log_recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,29 @@ STATIC void xlog_recover_check_summary(xlog_t *);
/* Number of basic blocks in a log sector */
#define xlog_sectbb(log) (1 << (log)->l_sectbb_log)

/*
* Verify the given count of basic blocks is valid number of blocks
* to specify for an operation involving the given XFS log buffer.
* Returns nonzero if the count is valid, 0 otherwise.
*/

static inline int
xlog_buf_bbcount_valid(
xlog_t *log,
int bbcount)
{
return bbcount > 0 && bbcount <= log->l_logBBsize;
}

STATIC xfs_buf_t *
xlog_get_bp(
xlog_t *log,
int nbblks)
{
if (nbblks <= 0 || nbblks > log->l_logBBsize) {
xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
XFS_ERROR_REPORT("xlog_get_bp(1)",
XFS_ERRLEVEL_HIGH, log->l_mp);
if (!xlog_buf_bbcount_valid(log, nbblks)) {
xlog_warn("XFS: Invalid block length (0x%x) given for buffer",
nbblks);
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
return NULL;
}

Expand Down Expand Up @@ -121,10 +135,10 @@ xlog_bread_noalign(
{
int error;

if (nbblks <= 0 || nbblks > log->l_logBBsize) {
xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
XFS_ERROR_REPORT("xlog_bread(1)",
XFS_ERRLEVEL_HIGH, log->l_mp);
if (!xlog_buf_bbcount_valid(log, nbblks)) {
xlog_warn("XFS: Invalid block length (0x%x) given for buffer",
nbblks);
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
return EFSCORRUPTED;
}

Expand Down Expand Up @@ -183,10 +197,10 @@ xlog_bwrite(
{
int error;

if (nbblks <= 0 || nbblks > log->l_logBBsize) {
xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks);
XFS_ERROR_REPORT("xlog_bwrite(1)",
XFS_ERRLEVEL_HIGH, log->l_mp);
if (!xlog_buf_bbcount_valid(log, nbblks)) {
xlog_warn("XFS: Invalid block length (0x%x) given for buffer",
nbblks);
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
return EFSCORRUPTED;
}

Expand Down

0 comments on commit e3cddd9

Please sign in to comment.