Commit 1813dd64 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers

xfs: convert buffer verifiers to an ops structure.

To separate the verifiers from iodone functions and associate read
and write verifiers at the same time, introduce a buffer verifier
operations structure to the xfs_buf.

This avoids the need for assigning the write verifier, clearing the
iodone function and re-running ioend processing in the read
verifier, and gets rid of the nasty "b_pre_io" name for the write
verifier function pointer. If we ever need to, it will also be
easier to add further content specific callbacks to a buffer with an
ops structure in place.

We also avoid needing to export verifier functions, instead we
can simply export the ops structures for those that are needed
outside the function they are defined in.

This patch also fixes a directory block readahead verifier issue
it exposed.

This patch also adds ops callbacks to the inode/alloc btree blocks
initialised by growfs. These will need more work before they will
work with CRCs.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarPhil White <pwhite@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent b0f539de
......@@ -108,6 +108,8 @@ typedef struct xfs_agf {
extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);
extern const struct xfs_buf_ops xfs_agf_buf_ops;
/*
* Size of the unlinked inode hash table in the agi.
*/
......@@ -161,6 +163,8 @@ typedef struct xfs_agi {
extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, struct xfs_buf **bpp);
extern const struct xfs_buf_ops xfs_agi_buf_ops;
/*
* The third a.g. block contains the a.g. freelist, an array
* of block pointers to blocks owned by the allocation btree code.
......
......@@ -465,7 +465,7 @@ xfs_agfl_verify(
#endif
}
void
static void
xfs_agfl_write_verify(
struct xfs_buf *bp)
{
......@@ -477,11 +477,13 @@ xfs_agfl_read_verify(
struct xfs_buf *bp)
{
xfs_agfl_verify(bp);
bp->b_pre_io = xfs_agfl_write_verify;
bp->b_iodone = NULL;
xfs_buf_ioend(bp, 0);
}
const struct xfs_buf_ops xfs_agfl_buf_ops = {
.verify_read = xfs_agfl_read_verify,
.verify_write = xfs_agfl_write_verify,
};
/*
* Read in the allocation group free block array.
*/
......@@ -499,7 +501,7 @@ xfs_alloc_read_agfl(
error = xfs_trans_read_buf(
mp, tp, mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0, &bp, xfs_agfl_read_verify);
XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops);
if (error)
return error;
ASSERT(!xfs_buf_geterror(bp));
......@@ -2181,23 +2183,25 @@ xfs_agf_verify(
}
}
void
xfs_agf_write_verify(
static void
xfs_agf_read_verify(
struct xfs_buf *bp)
{
xfs_agf_verify(bp);
}
static void
xfs_agf_read_verify(
xfs_agf_write_verify(
struct xfs_buf *bp)
{
xfs_agf_verify(bp);
bp->b_pre_io = xfs_agf_write_verify;
bp->b_iodone = NULL;
xfs_buf_ioend(bp, 0);
}
const struct xfs_buf_ops xfs_agf_buf_ops = {
.verify_read = xfs_agf_read_verify,
.verify_write = xfs_agf_write_verify,
};
/*
* Read in the allocation group header (free/alloc section).
*/
......@@ -2215,7 +2219,7 @@ xfs_read_agf(
error = xfs_trans_read_buf(
mp, tp, mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), flags, bpp, xfs_agf_read_verify);
XFS_FSS_TO_BB(mp, 1), flags, bpp, &xfs_agf_buf_ops);
if (error)
return error;
if (!*bpp)
......
......@@ -231,7 +231,7 @@ xfs_alloc_get_rec(
xfs_extlen_t *len, /* output: length of extent */
int *stat); /* output: success/failure */
void xfs_agf_write_verify(struct xfs_buf *bp);
void xfs_agfl_write_verify(struct xfs_buf *bp);
extern const struct xfs_buf_ops xfs_agf_buf_ops;
extern const struct xfs_buf_ops xfs_agfl_buf_ops;
#endif /* __XFS_ALLOC_H__ */
......@@ -329,22 +329,25 @@ xfs_allocbt_verify(
}
static void
xfs_allocbt_write_verify(
xfs_allocbt_read_verify(
struct xfs_buf *bp)
{
xfs_allocbt_verify(bp);
}
void
xfs_allocbt_read_verify(
static void
xfs_allocbt_write_verify(
struct xfs_buf *bp)
{
xfs_allocbt_verify(bp);
bp->b_pre_io = xfs_allocbt_write_verify;
bp->b_iodone = NULL;
xfs_buf_ioend(bp, 0);
}
const struct xfs_buf_ops xfs_allocbt_buf_ops = {
.verify_read = xfs_allocbt_read_verify,
.verify_write = xfs_allocbt_write_verify,
};
#ifdef DEBUG
STATIC int
xfs_allocbt_keys_inorder(
......@@ -400,8 +403,7 @@ static const struct xfs_btree_ops xfs_allocbt_ops = {
.init_rec_from_cur = xfs_allocbt_init_rec_from_cur,
.init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur,
.key_diff = xfs_allocbt_key_diff,
.read_verify = xfs_allocbt_read_verify,
.write_verify = xfs_allocbt_write_verify,
.buf_ops = &xfs_allocbt_buf_ops,
#ifdef DEBUG
.keys_inorder = xfs_allocbt_keys_inorder,
.recs_inorder = xfs_allocbt_recs_inorder,
......
......@@ -93,4 +93,6 @@ extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
xfs_agnumber_t, xfs_btnum_t);
extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);
extern const struct xfs_buf_ops xfs_allocbt_buf_ops;
#endif /* __XFS_ALLOC_BTREE_H__ */
......@@ -104,22 +104,23 @@ xfs_attr_leaf_verify(
}
static void
xfs_attr_leaf_write_verify(
xfs_attr_leaf_read_verify(
struct xfs_buf *bp)
{
xfs_attr_leaf_verify(bp);
}
void
xfs_attr_leaf_read_verify(
static void
xfs_attr_leaf_write_verify(
struct xfs_buf *bp)
{
xfs_attr_leaf_verify(bp);
bp->b_pre_io = xfs_attr_leaf_write_verify;
bp->b_iodone = NULL;
xfs_buf_ioend(bp, 0);
}
const struct xfs_buf_ops xfs_attr_leaf_buf_ops = {
.verify_read = xfs_attr_leaf_read_verify,
.verify_write = xfs_attr_leaf_write_verify,
};
int
xfs_attr_leaf_read(
......@@ -130,7 +131,7 @@ xfs_attr_leaf_read(
struct xfs_buf **bpp)
{
return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
XFS_ATTR_FORK, xfs_attr_leaf_read_verify);
XFS_ATTR_FORK, &xfs_attr_leaf_buf_ops);
}
/*========================================================================
......@@ -924,7 +925,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
XFS_ATTR_FORK);
if (error)
goto out;
bp2->b_pre_io = bp1->b_pre_io;
bp2->b_ops = bp1->b_ops;
memcpy(bp2->b_addr, bp1->b_addr, XFS_LBSIZE(dp->i_mount));
bp1 = NULL;
xfs_trans_log_buf(args->trans, bp2, 0, XFS_LBSIZE(dp->i_mount) - 1);
......@@ -978,7 +979,7 @@ xfs_attr_leaf_create(
XFS_ATTR_FORK);
if (error)
return(error);
bp->b_pre_io = xfs_attr_leaf_write_verify;
bp->b_ops = &xfs_attr_leaf_buf_ops;
leaf = bp->b_addr;
memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
hdr = &leaf->hdr;
......
......@@ -264,6 +264,7 @@ int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
int xfs_attr_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
xfs_dablk_t bno, xfs_daddr_t mappedbno,
struct xfs_buf **bpp);
void xfs_attr_leaf_read_verify(struct xfs_buf *bp);
extern const struct xfs_buf_ops xfs_attr_leaf_buf_ops;
#endif /* __XFS_ATTR_LEAF_H__ */
......@@ -2663,7 +2663,7 @@ xfs_bmap_btree_to_extents(
return error;
#endif
error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, XFS_BMAP_BTREE_REF,
xfs_bmbt_read_verify);
&xfs_bmbt_buf_ops);
if (error)
return error;
cblock = XFS_BUF_TO_BLOCK(cbp);
......@@ -3124,7 +3124,7 @@ xfs_bmap_extents_to_btree(
/*
* Fill in the child block.
*/
abp->b_pre_io = xfs_bmbt_write_verify;
abp->b_ops = &xfs_bmbt_buf_ops;
ablock = XFS_BUF_TO_BLOCK(abp);
ablock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC);
ablock->bb_level = 0;
......@@ -3271,7 +3271,7 @@ xfs_bmap_local_to_extents(
ASSERT(args.len == 1);
*firstblock = args.fsbno;
bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0);
bp->b_pre_io = xfs_bmbt_write_verify;
bp->b_ops = &xfs_bmbt_buf_ops;
memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes);
xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1);
xfs_bmap_forkoff_reset(args.mp, ip, whichfork);
......@@ -4082,7 +4082,7 @@ xfs_bmap_read_extents(
*/
while (level-- > 0) {
error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp,
XFS_BMAP_BTREE_REF, xfs_bmbt_read_verify);
XFS_BMAP_BTREE_REF, &xfs_bmbt_buf_ops);
if (error)
return error;
block = XFS_BUF_TO_BLOCK(bp);
......@@ -4129,7 +4129,7 @@ xfs_bmap_read_extents(
nextbno = be64_to_cpu(block->bb_u.l.bb_rightsib);
if (nextbno != NULLFSBLOCK)
xfs_btree_reada_bufl(mp, nextbno, 1,
xfs_bmbt_read_verify);
&xfs_bmbt_buf_ops);
/*
* Copy records into the extent records.
*/
......@@ -4162,7 +4162,7 @@ xfs_bmap_read_extents(
if (bno == NULLFSBLOCK)
break;
error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp,
XFS_BMAP_BTREE_REF, xfs_bmbt_read_verify);
XFS_BMAP_BTREE_REF, &xfs_bmbt_buf_ops);
if (error)
return error;
block = XFS_BUF_TO_BLOCK(bp);
......@@ -5880,7 +5880,7 @@ xfs_bmap_check_leaf_extents(
bp_release = 1;
error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp,
XFS_BMAP_BTREE_REF,
xfs_bmbt_read_verify);
&xfs_bmbt_buf_ops);
if (error)
goto error_norelse;
}
......@@ -5966,7 +5966,7 @@ xfs_bmap_check_leaf_extents(
bp_release = 1;
error = xfs_btree_read_bufl(mp, NULL, bno, 0, &bp,
XFS_BMAP_BTREE_REF,
xfs_bmbt_read_verify);
&xfs_bmbt_buf_ops);
if (error)
goto error_norelse;
}
......@@ -6061,7 +6061,7 @@ xfs_bmap_count_tree(
int numrecs;
error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF,
xfs_bmbt_read_verify);
&xfs_bmbt_buf_ops);
if (error)
return error;
*count += 1;
......@@ -6073,7 +6073,7 @@ xfs_bmap_count_tree(
while (nextbno != NULLFSBLOCK) {
error = xfs_btree_read_bufl(mp, tp, nextbno, 0, &nbp,
XFS_BMAP_BTREE_REF,
xfs_bmbt_read_verify);
&xfs_bmbt_buf_ops);
if (error)
return error;
*count += 1;
......@@ -6105,7 +6105,7 @@ xfs_bmap_count_tree(
bno = nextbno;
error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp,
XFS_BMAP_BTREE_REF,
xfs_bmbt_read_verify);
&xfs_bmbt_buf_ops);
if (error)
return error;
*count += 1;
......
......@@ -749,23 +749,26 @@ xfs_bmbt_verify(
}
}
void
xfs_bmbt_write_verify(
static void
xfs_bmbt_read_verify(
struct xfs_buf *bp)
{
xfs_bmbt_verify(bp);
}
void
xfs_bmbt_read_verify(
static void
xfs_bmbt_write_verify(
struct xfs_buf *bp)
{
xfs_bmbt_verify(bp);
bp->b_pre_io = xfs_bmbt_write_verify;
bp->b_iodone = NULL;
xfs_buf_ioend(bp, 0);
}
const struct xfs_buf_ops xfs_bmbt_buf_ops = {
.verify_read = xfs_bmbt_read_verify,
.verify_write = xfs_bmbt_write_verify,
};
#ifdef DEBUG
STATIC int
xfs_bmbt_keys_inorder(
......@@ -805,8 +808,7 @@ static const struct xfs_btree_ops xfs_bmbt_ops = {
.init_rec_from_cur = xfs_bmbt_init_rec_from_cur,
.init_ptr_from_cur = xfs_bmbt_init_ptr_from_cur,
.key_diff = xfs_bmbt_key_diff,
.read_verify = xfs_bmbt_read_verify,
.write_verify = xfs_bmbt_write_verify,
.buf_ops = &xfs_bmbt_buf_ops,
#ifdef DEBUG
.keys_inorder = xfs_bmbt_keys_inorder,
.recs_inorder = xfs_bmbt_recs_inorder,
......
......@@ -232,11 +232,10 @@ extern void xfs_bmbt_to_bmdr(struct xfs_mount *, struct xfs_btree_block *, int,
extern int xfs_bmbt_get_maxrecs(struct xfs_btree_cur *, int level);
extern int xfs_bmdr_maxrecs(struct xfs_mount *, int blocklen, int leaf);
extern int xfs_bmbt_maxrecs(struct xfs_mount *, int blocklen, int leaf);
extern void xfs_bmbt_read_verify(struct xfs_buf *bp);
extern void xfs_bmbt_write_verify(struct xfs_buf *bp);
extern struct xfs_btree_cur *xfs_bmbt_init_cursor(struct xfs_mount *,
struct xfs_trans *, struct xfs_inode *, int);
extern const struct xfs_buf_ops xfs_bmbt_buf_ops;
#endif /* __XFS_BMAP_BTREE_H__ */
......@@ -271,7 +271,7 @@ xfs_btree_dup_cursor(
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
XFS_BUF_ADDR(bp), mp->m_bsize,
0, &bp,
cur->bc_ops->read_verify);
cur->bc_ops->buf_ops);
if (error) {
xfs_btree_del_cursor(new, error);
*ncur = NULL;
......@@ -621,7 +621,7 @@ xfs_btree_read_bufl(
uint lock, /* lock flags for read_buf */
struct xfs_buf **bpp, /* buffer for fsbno */
int refval, /* ref count value for buffer */
xfs_buf_iodone_t verify)
const struct xfs_buf_ops *ops)
{
struct xfs_buf *bp; /* return value */
xfs_daddr_t d; /* real disk block address */
......@@ -630,7 +630,7 @@ xfs_btree_read_bufl(
ASSERT(fsbno != NULLFSBLOCK);
d = XFS_FSB_TO_DADDR(mp, fsbno);
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d,
mp->m_bsize, lock, &bp, verify);
mp->m_bsize, lock, &bp, ops);
if (error)
return error;
ASSERT(!xfs_buf_geterror(bp));
......@@ -650,13 +650,13 @@ xfs_btree_reada_bufl(
struct xfs_mount *mp, /* file system mount point */
xfs_fsblock_t fsbno, /* file system block number */
xfs_extlen_t count, /* count of filesystem blocks */
xfs_buf_iodone_t verify)
const struct xfs_buf_ops *ops)
{
xfs_daddr_t d;
ASSERT(fsbno != NULLFSBLOCK);
d = XFS_FSB_TO_DADDR(mp, fsbno);
xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, verify);
xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, ops);
}
/*
......@@ -670,14 +670,14 @@ xfs_btree_reada_bufs(
xfs_agnumber_t agno, /* allocation group number */
xfs_agblock_t agbno, /* allocation group block number */
xfs_extlen_t count, /* count of filesystem blocks */
xfs_buf_iodone_t verify)
const struct xfs_buf_ops *ops)
{
xfs_daddr_t d;
ASSERT(agno != NULLAGNUMBER);
ASSERT(agbno != NULLAGBLOCK);
d = XFS_AGB_TO_DADDR(mp, agno, agbno);
xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, verify);
xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, ops);
}
STATIC int
......@@ -692,13 +692,13 @@ xfs_btree_readahead_lblock(
if ((lr & XFS_BTCUR_LEFTRA) && left != NULLDFSBNO) {
xfs_btree_reada_bufl(cur->bc_mp, left, 1,
cur->bc_ops->read_verify);
cur->bc_ops->buf_ops);
rval++;
}
if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLDFSBNO) {
xfs_btree_reada_bufl(cur->bc_mp, right, 1,
cur->bc_ops->read_verify);
cur->bc_ops->buf_ops);
rval++;
}
......@@ -718,13 +718,13 @@ xfs_btree_readahead_sblock(
if ((lr & XFS_BTCUR_LEFTRA) && left != NULLAGBLOCK) {
xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
left, 1, cur->bc_ops->read_verify);
left, 1, cur->bc_ops->buf_ops);
rval++;
}
if ((lr & XFS_BTCUR_RIGHTRA) && right != NULLAGBLOCK) {
xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
right, 1, cur->bc_ops->read_verify);
right, 1, cur->bc_ops->buf_ops);
rval++;
}
......@@ -996,7 +996,7 @@ xfs_btree_get_buf_block(
if (!*bpp)
return ENOMEM;
(*bpp)->b_pre_io = cur->bc_ops->write_verify;
(*bpp)->b_ops = cur->bc_ops->buf_ops;
*block = XFS_BUF_TO_BLOCK(*bpp);
return 0;
}
......@@ -1024,7 +1024,7 @@ xfs_btree_read_buf_block(
d = xfs_btree_ptr_to_daddr(cur, ptr);
error = xfs_trans_read_buf(mp, cur->bc_tp, mp->m_ddev_targp, d,
mp->m_bsize, flags, bpp,
cur->bc_ops->read_verify);
cur->bc_ops->buf_ops);
if (error)
return error;
......
......@@ -188,8 +188,7 @@ struct xfs_btree_ops {
__int64_t (*key_diff)(struct xfs_btree_cur *cur,
union xfs_btree_key *key);
void (*read_verify)(struct xfs_buf *bp);
void (*write_verify)(struct xfs_buf *bp);
const struct xfs_buf_ops *buf_ops;
#ifdef DEBUG
/* check that k1 is lower than k2 */
......@@ -359,7 +358,7 @@ xfs_btree_read_bufl(
uint lock, /* lock flags for read_buf */
struct xfs_buf **bpp, /* buffer for fsbno */
int refval, /* ref count value for buffer */
xfs_buf_iodone_t verify);
const struct xfs_buf_ops *ops);
/*
* Read-ahead the block, don't wait for it, don't return a buffer.
......@@ -370,7 +369,7 @@ xfs_btree_reada_bufl(
struct xfs_mount *mp, /* file system mount point */
xfs_fsblock_t fsbno, /* file system block number */
xfs_extlen_t count, /* count of filesystem blocks */
xfs_buf_iodone_t verify);
const struct xfs_buf_ops *ops);
/*
* Read-ahead the block, don't wait for it, don't return a buffer.
......@@ -382,7 +381,7 @@ xfs_btree_reada_bufs(
xfs_agnumber_t agno, /* allocation group number */
xfs_agblock_t agbno, /* allocation group block number */
xfs_extlen_t count, /* count of filesystem blocks */
xfs_buf_iodone_t verify);
const struct xfs_buf_ops *ops);
/*
* Initialise a new btree block header
......
......@@ -571,7 +571,7 @@ _xfs_buf_find(
ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0);
ASSERT(bp->b_iodone == NULL);
bp->b_flags &= _XBF_KMEM | _XBF_PAGES;
bp->b_pre_io = NULL;
bp->b_ops = NULL;
}
trace_xfs_buf_find(bp, flags, _RET_IP_);
......@@ -657,7 +657,7 @@ xfs_buf_read_map(
struct xfs_buf_map *map,
int nmaps,
xfs_buf_flags_t flags,
xfs_buf_iodone_t verify)
const struct xfs_buf_ops *ops)
{
struct xfs_buf *bp;
......@@ -669,7 +669,7 @@ xfs_buf_read_map(
if (!XFS_BUF_ISDONE(bp)) {
XFS_STATS_INC(xb_get_read);
bp->b_iodone = verify;
bp->b_ops = ops;
_xfs_buf_read(bp, flags);
} else if (flags & XBF_ASYNC) {
/*
......@@ -696,13 +696,13 @@ xfs_buf_readahead_map(
struct xfs_buftarg *target,
struct xfs_buf_map *map,
int nmaps,
xfs_buf_iodone_t verify)
const struct xfs_buf_ops *ops)
{
if (bdi_read_congested(target->bt_bdi))
return;
xfs_buf_read_map(target, map, nmaps,
XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD, verify);
XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD, ops);
}
/*
......@@ -715,7 +715,7 @@ xfs_buf_read_uncached(
xfs_daddr_t daddr,
size_t numblks,
int flags,
xfs_buf_iodone_t verify)
const struct xfs_buf_ops *ops)
{
struct xfs_buf *bp;
......@@ -728,7 +728,7 @@ xfs_buf_read_uncached(
bp->b_bn = daddr;
bp->b_maps[0].bm_bn = daddr;
bp->b_flags |= XBF_READ;
bp->b_iodone = verify;
bp->b_ops = ops;
xfsbdstrat(target->bt_mount, bp);
xfs_buf_iowait(bp);
......@@ -1001,27 +1001,37 @@ STATIC void
xfs_buf_iodone_work(
struct work_struct *work)
{
xfs_buf_t *bp =
struct xfs_buf *bp =
container_of(work, xfs_buf_t, b_iodone_work);
bool read = !!(bp->b_flags & XBF_READ);
bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD);
if (read && bp->b_ops)
bp->b_ops->verify_read(bp);
if (bp->b_iodone)
(*(bp->b_iodone))(bp);
else if (bp->b_flags & XBF_ASYNC)
xfs_buf_relse(bp);
else {
ASSERT(read && bp->b_ops);
complete(&bp->b_iowait);
}
}
void
xfs_buf_ioend(
xfs_buf_t *bp,
int schedule)
struct xfs_buf *bp,
int schedule)
{
bool read = !!(bp->b_flags & XBF_READ);
trace_xfs_buf_iodone(bp, _RET_IP_);
bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD);
if (bp->b_error == 0)
bp->b_flags |= XBF_DONE;
if ((bp->b_iodone) || (bp->b_flags & XBF_ASYNC)) {
if (bp->b_iodone || (read && bp->b_ops) || (bp->b_flags & XBF_ASYNC)) {
if (schedule) {
INIT_WORK(&bp->b_iodone_work, xfs_buf_iodone_work);
queue_work(xfslogd_workqueue, &bp->b_iodone_work);
......@@ -1029,6 +1039,7 @@ xfs_buf_ioend(
xfs_buf_iodone_work(&bp->b_iodone_work);
}
} else {
bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD);
complete(&bp->b_iowait);
}
}
......@@ -1316,6 +1327,20 @@ _xfs_buf_ioapply(
rw |= REQ_FUA;
if (bp->b_flags & XBF_FLUSH)
rw |= REQ_FLUSH;
/*
* Run the write verifier callback function if it exists. If
* this function fails it will mark the buffer with an error and
* the IO should not be dispatched.
*/
if (bp->b_ops) {
bp->b_ops->verify_write(bp);
if (bp->b_error) {
xfs_force_shutdown(bp->b_target->bt_mount,
SHUTDOWN_CORRUPT_INCORE);
return;
}
}
} else if (bp->b_flags & XBF_READ_AHEAD) {
rw = READA;
} else {
......@@ -1325,20 +1350,6 @@ _xfs_buf_ioapply(
/* we only use the buffer cache for meta-data */
rw |= REQ_META;
/*