diff options
Diffstat (limited to 'fs/ocfs2/buffer_head_io.c')
-rw-r--r-- | fs/ocfs2/buffer_head_io.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c index 3a178ec48d7c..15c8e6deee2e 100644 --- a/fs/ocfs2/buffer_head_io.c +++ b/fs/ocfs2/buffer_head_io.c | |||
@@ -39,6 +39,18 @@ | |||
39 | 39 | ||
40 | #include "buffer_head_io.h" | 40 | #include "buffer_head_io.h" |
41 | 41 | ||
42 | /* | ||
43 | * Bits on bh->b_state used by ocfs2. | ||
44 | * | ||
45 | * These MUST be after the JBD2 bits. Hence, we use BH_JBDPrivateStart. | ||
46 | */ | ||
47 | enum ocfs2_state_bits { | ||
48 | BH_NeedsValidate = BH_JBDPrivateStart, | ||
49 | }; | ||
50 | |||
51 | /* Expand the magic b_state functions */ | ||
52 | BUFFER_FNS(NeedsValidate, needs_validate); | ||
53 | |||
42 | int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | 54 | int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, |
43 | struct inode *inode) | 55 | struct inode *inode) |
44 | { | 56 | { |
@@ -166,7 +178,9 @@ bail: | |||
166 | } | 178 | } |
167 | 179 | ||
168 | int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | 180 | int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, |
169 | struct buffer_head *bhs[], int flags) | 181 | struct buffer_head *bhs[], int flags, |
182 | int (*validate)(struct super_block *sb, | ||
183 | struct buffer_head *bh)) | ||
170 | { | 184 | { |
171 | int status = 0; | 185 | int status = 0; |
172 | int i, ignore_cache = 0; | 186 | int i, ignore_cache = 0; |
@@ -298,6 +312,8 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
298 | 312 | ||
299 | clear_buffer_uptodate(bh); | 313 | clear_buffer_uptodate(bh); |
300 | get_bh(bh); /* for end_buffer_read_sync() */ | 314 | get_bh(bh); /* for end_buffer_read_sync() */ |
315 | if (validate) | ||
316 | set_buffer_needs_validate(bh); | ||
301 | bh->b_end_io = end_buffer_read_sync; | 317 | bh->b_end_io = end_buffer_read_sync; |
302 | submit_bh(READ, bh); | 318 | submit_bh(READ, bh); |
303 | continue; | 319 | continue; |
@@ -328,6 +344,20 @@ int ocfs2_read_blocks(struct inode *inode, u64 block, int nr, | |||
328 | bhs[i] = NULL; | 344 | bhs[i] = NULL; |
329 | continue; | 345 | continue; |
330 | } | 346 | } |
347 | |||
348 | if (buffer_needs_validate(bh)) { | ||
349 | /* We never set NeedsValidate if the | ||
350 | * buffer was held by the journal, so | ||
351 | * that better not have changed */ | ||
352 | BUG_ON(buffer_jbd(bh)); | ||
353 | clear_buffer_needs_validate(bh); | ||
354 | status = validate(inode->i_sb, bh); | ||
355 | if (status) { | ||
356 | put_bh(bh); | ||
357 | bhs[i] = NULL; | ||
358 | continue; | ||
359 | } | ||
360 | } | ||
331 | } | 361 | } |
332 | 362 | ||
333 | /* Always set the buffer in the cache, even if it was | 363 | /* Always set the buffer in the cache, even if it was |