aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <aelder@sgi.com>2010-04-13 01:22:58 -0400
committerAlex Elder <aelder@sgi.com>2010-05-19 10:58:12 -0400
commitff30a6221d95b609a37410a425937b11a55d465e (patch)
tree548b8949adc08b8d96c73953f28b3ba7fc2afe31
parent5c17f5339f9dfdee8ad9661e97f8030d75b6bff7 (diff)
xfs: encapsulate bbcount validity checking
Define a function that encapsulates checking the validity of a log block count. (Updated from previous version--no longer includes error reporting in the encapsulated validation function.) Signed-off-by: Alex Elder <aelder@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <dchinner@redhat.com>
-rw-r--r--fs/xfs/xfs_log_recover.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 0e51bdd910a7..b5eab63eb12d 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -63,15 +63,29 @@ STATIC void xlog_recover_check_summary(xlog_t *);
63/* Number of basic blocks in a log sector */ 63/* Number of basic blocks in a log sector */
64#define xlog_sectbb(log) (1 << (log)->l_sectbb_log) 64#define xlog_sectbb(log) (1 << (log)->l_sectbb_log)
65 65
66/*
67 * Verify the given count of basic blocks is valid number of blocks
68 * to specify for an operation involving the given XFS log buffer.
69 * Returns nonzero if the count is valid, 0 otherwise.
70 */
71
72static inline int
73xlog_buf_bbcount_valid(
74 xlog_t *log,
75 int bbcount)
76{
77 return bbcount > 0 && bbcount <= log->l_logBBsize;
78}
79
66STATIC xfs_buf_t * 80STATIC xfs_buf_t *
67xlog_get_bp( 81xlog_get_bp(
68 xlog_t *log, 82 xlog_t *log,
69 int nbblks) 83 int nbblks)
70{ 84{
71 if (nbblks <= 0 || nbblks > log->l_logBBsize) { 85 if (!xlog_buf_bbcount_valid(log, nbblks)) {
72 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks); 86 xlog_warn("XFS: Invalid block length (0x%x) given for buffer",
73 XFS_ERROR_REPORT("xlog_get_bp(1)", 87 nbblks);
74 XFS_ERRLEVEL_HIGH, log->l_mp); 88 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
75 return NULL; 89 return NULL;
76 } 90 }
77 91
@@ -121,10 +135,10 @@ xlog_bread_noalign(
121{ 135{
122 int error; 136 int error;
123 137
124 if (nbblks <= 0 || nbblks > log->l_logBBsize) { 138 if (!xlog_buf_bbcount_valid(log, nbblks)) {
125 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks); 139 xlog_warn("XFS: Invalid block length (0x%x) given for buffer",
126 XFS_ERROR_REPORT("xlog_bread(1)", 140 nbblks);
127 XFS_ERRLEVEL_HIGH, log->l_mp); 141 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
128 return EFSCORRUPTED; 142 return EFSCORRUPTED;
129 } 143 }
130 144
@@ -183,10 +197,10 @@ xlog_bwrite(
183{ 197{
184 int error; 198 int error;
185 199
186 if (nbblks <= 0 || nbblks > log->l_logBBsize) { 200 if (!xlog_buf_bbcount_valid(log, nbblks)) {
187 xlog_warn("XFS: Invalid block length (0x%x) given for buffer", nbblks); 201 xlog_warn("XFS: Invalid block length (0x%x) given for buffer",
188 XFS_ERROR_REPORT("xlog_bwrite(1)", 202 nbblks);
189 XFS_ERRLEVEL_HIGH, log->l_mp); 203 XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_HIGH, log->l_mp);
190 return EFSCORRUPTED; 204 return EFSCORRUPTED;
191 } 205 }
192 206