add pre-io callback to struct xfs_buf
PATCH 1/4 add pre-io callback to struct xfs_buf
From: Dave Chinner <[email protected]>
Enable a buffer "pre-io" callback to allow the contents of a buffer to be checked or modified just before writeback occurs. This is how we'll calculate CRCS on metadata buffers.
Signed-off-by Dave Chinner <[email protected]>
fs/xfs/linux-2.6/xfs_buf.c +8 -0
@@ -1179,6 +1179,14 @@ _xfs_buf_ioapply( (bp->b_flags &XBF_READ_AHEAD ) ?READA :READ ; } +/* +* call out to buffer specific pre-write I/O functions. Used for +* validation of buffers and CRC calculations prior to I/O issue. +*/ +if (bp->b_io_callback && (bp->b_flags &XBF_WRITE )) + bp->b_io_callback (bp); + +/* Special code path for reading a sub page size buffer in -- * we populate up the whole page, and hence the other metadata * in the same page. This optimization is only valid when the
fs/xfs/linux-2.6/xfs_buf.h +12 -0
@@ -166,6 +166,8 @@ typedef struct xfs_buf {unsigned int b_offset;/* page offset in first page */ struct page **b_pages;/* array of page pointers */ struct page *b_page_array[XB_PAGES ];/* inline pages */ +void (*b_io_callback)(struct xfs_buf *); +/* pre-write I/O callback */ #ifdef XFS_BUF_LOCK_TRACKING int b_last_holder;#endif
@@ -228,6 +230,16 @@ static inline int xfs_buf_geterror(xfs_b/* Buffer Utility Routines */ extern xfs_caddr_t xfs_buf_offset (xfs_buf_t *,size_t ); +/* +* Set the function that should be called immediately prior +* to a write I/O being issued on this buffer. +*/ +static inline void +xfs_buf_set_io_callback (xfs_buf_t *bp,void (*func)(xfs_buf_t *)) +{ + bp->b_io_callback = func; +} +/* Pinning Buffer Storage in Memory */ extern void xfs_buf_pin (xfs_buf_t *);extern void xfs_buf_unpin (xfs_buf_t *);