diff options
author | Alex Elder <aelder@sgi.com> | 2010-04-13 01:21:13 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-05-19 10:58:12 -0400 |
commit | 36adecff50b69df0369cc2022650c6087aeb255f (patch) | |
tree | 88341430b367a7b106c8eddcaaa90f1ffd2812db | |
parent | ff30a6221d95b609a37410a425937b11a55d465e (diff) |
xfs: nothing special about 1-block log sector
There are a number of places where a log sector size of 1 uses
special case code. The round_up() and round_down() macros
produce the correct result even when the log sector size is 1, and
this eliminates the need for treating this as a special case.
Signed-off-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index b5eab63eb12d..629e88b38bd1 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -77,6 +77,11 @@ xlog_buf_bbcount_valid( | |||
77 | return bbcount > 0 && bbcount <= log->l_logBBsize; | 77 | return bbcount > 0 && bbcount <= log->l_logBBsize; |
78 | } | 78 | } |
79 | 79 | ||
80 | /* | ||
81 | * Allocate a buffer to hold log data. The buffer needs to be able | ||
82 | * to map to a range of nbblks basic blocks at any valid (basic | ||
83 | * block) offset within the log. | ||
84 | */ | ||
80 | STATIC xfs_buf_t * | 85 | STATIC xfs_buf_t * |
81 | xlog_get_bp( | 86 | xlog_get_bp( |
82 | xlog_t *log, | 87 | xlog_t *log, |
@@ -89,11 +94,26 @@ xlog_get_bp( | |||
89 | return NULL; | 94 | return NULL; |
90 | } | 95 | } |
91 | 96 | ||
92 | if (log->l_sectbb_log) { | 97 | /* |
93 | if (nbblks > 1) | 98 | * We do log I/O in units of log sectors (a power-of-2 |
94 | nbblks += xlog_sectbb(log); | 99 | * multiple of the basic block size), so we round up the |
95 | nbblks = round_up(nbblks, xlog_sectbb(log)); | 100 | * requested size to acommodate the basic blocks required |
96 | } | 101 | * for complete log sectors. |
102 | * | ||
103 | * In addition, the buffer may be used for a non-sector- | ||
104 | * aligned block offset, in which case an I/O of the | ||
105 | * requested size could extend beyond the end of the | ||
106 | * buffer. If the requested size is only 1 basic block it | ||
107 | * will never straddle a sector boundary, so this won't be | ||
108 | * an issue. Nor will this be a problem if the log I/O is | ||
109 | * done in basic blocks (sector size 1). But otherwise we | ||
110 | * extend the buffer by one extra log sector to ensure | ||
111 | * there's space to accomodate this possiblility. | ||
112 | */ | ||
113 | if (nbblks > 1 && log->l_sectbb_log) | ||
114 | nbblks += xlog_sectbb(log); | ||
115 | nbblks = round_up(nbblks, xlog_sectbb(log)); | ||
116 | |||
97 | return xfs_buf_get_noaddr(BBTOB(nbblks), log->l_mp->m_logdev_targp); | 117 | return xfs_buf_get_noaddr(BBTOB(nbblks), log->l_mp->m_logdev_targp); |
98 | } | 118 | } |
99 | 119 | ||
@@ -142,10 +162,8 @@ xlog_bread_noalign( | |||
142 | return EFSCORRUPTED; | 162 | return EFSCORRUPTED; |
143 | } | 163 | } |
144 | 164 | ||
145 | if (log->l_sectbb_log) { | 165 | blk_no = round_down(blk_no, xlog_sectbb(log)); |
146 | blk_no = round_down(blk_no, xlog_sectbb(log)); | 166 | nbblks = round_up(nbblks, xlog_sectbb(log)); |
147 | nbblks = round_up(nbblks, xlog_sectbb(log)); | ||
148 | } | ||
149 | 167 | ||
150 | ASSERT(nbblks > 0); | 168 | ASSERT(nbblks > 0); |
151 | ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); | 169 | ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); |
@@ -204,10 +222,8 @@ xlog_bwrite( | |||
204 | return EFSCORRUPTED; | 222 | return EFSCORRUPTED; |
205 | } | 223 | } |
206 | 224 | ||
207 | if (log->l_sectbb_log) { | 225 | blk_no = round_down(blk_no, xlog_sectbb(log)); |
208 | blk_no = round_down(blk_no, xlog_sectbb(log)); | 226 | nbblks = round_up(nbblks, xlog_sectbb(log)); |
209 | nbblks = round_up(nbblks, xlog_sectbb(log)); | ||
210 | } | ||
211 | 227 | ||
212 | ASSERT(nbblks > 0); | 228 | ASSERT(nbblks > 0); |
213 | ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); | 229 | ASSERT(BBTOB(nbblks) <= XFS_BUF_SIZE(bp)); |