diff options
author | Dave Chinner <dchinner@redhat.com> | 2012-11-12 06:54:19 -0500 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-11-15 22:35:00 -0500 |
commit | cfb02852226aa449fe27075caffe88726507668c (patch) | |
tree | 796ede500b5fe4d3b0a7e7ec4621f85347741d79 /fs/xfs/xfs_buf.c | |
parent | da6958c873ecd846d71fafbfe0f6168bb9c2c99e (diff) |
xfs: add buffer pre-write callback
Add a callback to the buffer write path to enable verification of
the buffer and CRC calculation prior to issuing the write to the
underlying storage.
If the callback function detects some kind of failure or error
condition, it must mark the buffer with an error so that the caller
can take appropriate action. In the case of xfs_buf_ioapply(), a
corrupt metadta buffer willt rigger a shutdown of the filesystem,
because something is clearly wrong and we can't allow corrupt
metadata to be written to disk.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Phil White <pwhite@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_buf.c')
-rw-r--r-- | fs/xfs/xfs_buf.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index fbc965fc075a..bd1a948ee39c 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -569,7 +569,9 @@ found: | |||
569 | */ | 569 | */ |
570 | if (bp->b_flags & XBF_STALE) { | 570 | if (bp->b_flags & XBF_STALE) { |
571 | ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0); | 571 | ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0); |
572 | ASSERT(bp->b_iodone == NULL); | ||
572 | bp->b_flags &= _XBF_KMEM | _XBF_PAGES; | 573 | bp->b_flags &= _XBF_KMEM | _XBF_PAGES; |
574 | bp->b_pre_io = NULL; | ||
573 | } | 575 | } |
574 | 576 | ||
575 | trace_xfs_buf_find(bp, flags, _RET_IP_); | 577 | trace_xfs_buf_find(bp, flags, _RET_IP_); |
@@ -1324,6 +1326,20 @@ _xfs_buf_ioapply( | |||
1324 | rw |= REQ_META; | 1326 | rw |= REQ_META; |
1325 | 1327 | ||
1326 | /* | 1328 | /* |
1329 | * run the pre-io callback function if it exists. If this function | ||
1330 | * fails it will mark the buffer with an error and the IO should | ||
1331 | * not be dispatched. | ||
1332 | */ | ||
1333 | if (bp->b_pre_io) { | ||
1334 | bp->b_pre_io(bp); | ||
1335 | if (bp->b_error) { | ||
1336 | xfs_force_shutdown(bp->b_target->bt_mount, | ||
1337 | SHUTDOWN_CORRUPT_INCORE); | ||
1338 | return; | ||
1339 | } | ||
1340 | } | ||
1341 | |||
1342 | /* | ||
1327 | * Walk all the vectors issuing IO on them. Set up the initial offset | 1343 | * Walk all the vectors issuing IO on them. Set up the initial offset |
1328 | * into the buffer and the desired IO size before we start - | 1344 | * into the buffer and the desired IO size before we start - |
1329 | * _xfs_buf_ioapply_vec() will modify them appropriately for each | 1345 | * _xfs_buf_ioapply_vec() will modify them appropriately for each |