aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/buffer_head_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/buffer_head_io.c')
-rw-r--r--fs/ocfs2/buffer_head_io.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index 718dbe5607ca..7e947c672469 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -181,7 +181,8 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
181 inode, (unsigned long long)block, nr, flags); 181 inode, (unsigned long long)block, nr, flags);
182 182
183 BUG_ON(!inode); 183 BUG_ON(!inode);
184 BUG_ON((flags & OCFS2_BH_READAHEAD) && !(flags & OCFS2_BH_CACHED)); 184 BUG_ON((flags & OCFS2_BH_READAHEAD) &&
185 (flags & OCFS2_BH_IGNORE_CACHE));
185 186
186 if (bhs == NULL) { 187 if (bhs == NULL) {
187 status = -EINVAL; 188 status = -EINVAL;
@@ -214,7 +215,7 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
214 } 215 }
215 } 216 }
216 bh = bhs[i]; 217 bh = bhs[i];
217 ignore_cache = 0; 218 ignore_cache = (flags & OCFS2_BH_IGNORE_CACHE);
218 219
219 /* There are three read-ahead cases here which we need to 220 /* There are three read-ahead cases here which we need to
220 * be concerned with. All three assume a buffer has 221 * be concerned with. All three assume a buffer has
@@ -240,26 +241,27 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
240 * before our is-it-in-flight check. 241 * before our is-it-in-flight check.
241 */ 242 */
242 243
243 if (flags & OCFS2_BH_CACHED && 244 if (!ignore_cache && !ocfs2_buffer_uptodate(inode, bh)) {
244 !ocfs2_buffer_uptodate(inode, bh)) {
245 mlog(ML_UPTODATE, 245 mlog(ML_UPTODATE,
246 "bh (%llu), inode %llu not uptodate\n", 246 "bh (%llu), inode %llu not uptodate\n",
247 (unsigned long long)bh->b_blocknr, 247 (unsigned long long)bh->b_blocknr,
248 (unsigned long long)OCFS2_I(inode)->ip_blkno); 248 (unsigned long long)OCFS2_I(inode)->ip_blkno);
249 /* We're using ignore_cache here to say
250 * "go to disk" */
249 ignore_cache = 1; 251 ignore_cache = 1;
250 } 252 }
251 253
252 /* XXX: Can we ever get this and *not* have the cached 254 /* XXX: Can we ever get this and *not* have the cached
253 * flag set? */ 255 * flag set? */
254 if (buffer_jbd(bh)) { 256 if (buffer_jbd(bh)) {
255 if (!(flags & OCFS2_BH_CACHED) || ignore_cache) 257 if (ignore_cache)
256 mlog(ML_BH_IO, "trying to sync read a jbd " 258 mlog(ML_BH_IO, "trying to sync read a jbd "
257 "managed bh (blocknr = %llu)\n", 259 "managed bh (blocknr = %llu)\n",
258 (unsigned long long)bh->b_blocknr); 260 (unsigned long long)bh->b_blocknr);
259 continue; 261 continue;
260 } 262 }
261 263
262 if (!(flags & OCFS2_BH_CACHED) || ignore_cache) { 264 if (ignore_cache) {
263 if (buffer_dirty(bh)) { 265 if (buffer_dirty(bh)) {
264 /* This should probably be a BUG, or 266 /* This should probably be a BUG, or
265 * at least return an error. */ 267 * at least return an error. */
@@ -294,7 +296,7 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
294 * previously read-ahead buffer may have 296 * previously read-ahead buffer may have
295 * completed I/O while we were waiting for the 297 * completed I/O while we were waiting for the
296 * buffer lock. */ 298 * buffer lock. */
297 if ((flags & OCFS2_BH_CACHED) 299 if (!(flags & OCFS2_BH_IGNORE_CACHE)
298 && !(flags & OCFS2_BH_READAHEAD) 300 && !(flags & OCFS2_BH_READAHEAD)
299 && ocfs2_buffer_uptodate(inode, bh)) { 301 && ocfs2_buffer_uptodate(inode, bh)) {
300 unlock_buffer(bh); 302 unlock_buffer(bh);
@@ -344,7 +346,8 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr,
344 346
345 mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s, flags=0x%x\n", 347 mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s, flags=0x%x\n",
346 (unsigned long long)block, nr, 348 (unsigned long long)block, nr,
347 (!(flags & OCFS2_BH_CACHED) || ignore_cache) ? "no" : "yes", flags); 349 ((flags & OCFS2_BH_IGNORE_CACHE) || ignore_cache) ? "no" : "yes",
350 flags);
348 351
349bail: 352bail:
350 353