Loading fs/xfs/libxfs/xfs_attr.c +23 −118 Original line number Original line Diff line number Diff line Loading @@ -207,7 +207,7 @@ xfs_attr_set( struct xfs_trans_res tres; struct xfs_trans_res tres; xfs_fsblock_t firstblock; xfs_fsblock_t firstblock; int rsvd = (flags & ATTR_ROOT) != 0; int rsvd = (flags & ATTR_ROOT) != 0; int error, err2, committed, local; int error, err2, local; XFS_STATS_INC(mp, xs_attr_set); XFS_STATS_INC(mp, xs_attr_set); Loading Loading @@ -334,24 +334,14 @@ xfs_attr_set( */ */ xfs_bmap_init(args.flist, args.firstblock); xfs_bmap_init(args.flist, args.firstblock); error = xfs_attr_shortform_to_leaf(&args); error = xfs_attr_shortform_to_leaf(&args); if (!error) { if (!error) error = xfs_bmap_finish(&args.trans, args.flist, error = xfs_bmap_finish(&args.trans, args.flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args.trans = NULL; args.trans = NULL; xfs_bmap_cancel(&flist); xfs_bmap_cancel(&flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args.trans, dp, 0); /* /* * Commit the leaf transformation. We'll need another (linked) * Commit the leaf transformation. We'll need another (linked) * transaction to add the new attribute to the leaf. * transaction to add the new attribute to the leaf. Loading Loading @@ -568,7 +558,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) { { xfs_inode_t *dp; xfs_inode_t *dp; struct xfs_buf *bp; struct xfs_buf *bp; int retval, error, committed, forkoff; int retval, error, forkoff; trace_xfs_attr_leaf_addname(args); trace_xfs_attr_leaf_addname(args); Loading Loading @@ -628,24 +618,14 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) */ */ xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_node(args); error = xfs_attr3_leaf_to_node(args); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); /* /* * Commit the current trans (including the inode) and start * Commit the current trans (including the inode) and start * a new one. * a new one. Loading Loading @@ -729,25 +709,14 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */ if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans, args->flist, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans * and started a new one. We need the inode to be * in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } } /* /* Loading Loading @@ -775,7 +744,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) { { xfs_inode_t *dp; xfs_inode_t *dp; struct xfs_buf *bp; struct xfs_buf *bp; int error, committed, forkoff; int error, forkoff; trace_xfs_attr_leaf_removename(args); trace_xfs_attr_leaf_removename(args); Loading Loading @@ -803,23 +772,13 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */ if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } } return 0; return 0; } } Loading Loading @@ -877,7 +836,7 @@ xfs_attr_node_addname(xfs_da_args_t *args) xfs_da_state_blk_t *blk; xfs_da_state_blk_t *blk; xfs_inode_t *dp; xfs_inode_t *dp; xfs_mount_t *mp; xfs_mount_t *mp; int committed, retval, error; int retval, error; trace_xfs_attr_node_addname(args); trace_xfs_attr_node_addname(args); Loading Loading @@ -938,26 +897,15 @@ xfs_attr_node_addname(xfs_da_args_t *args) state = NULL; state = NULL; xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_node(args); error = xfs_attr3_leaf_to_node(args); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans, args->flist, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans * and started a new one. We need the inode to be * in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); /* /* * Commit the node conversion and start the next * Commit the node conversion and start the next * trans in the chain. * trans in the chain. Loading @@ -977,23 +925,13 @@ xfs_attr_node_addname(xfs_da_args_t *args) */ */ xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_da3_split(state); error = xfs_da3_split(state); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } else { } else { /* /* * Addition succeeded, update Btree hashvals. * Addition succeeded, update Btree hashvals. Loading Loading @@ -1086,25 +1024,14 @@ xfs_attr_node_addname(xfs_da_args_t *args) if (retval && (state->path.active > 1)) { if (retval && (state->path.active > 1)) { xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_da3_join(state); error = xfs_da3_join(state); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans, args->flist, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans * and started a new one. We need the inode to be * in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } } /* /* Loading Loading @@ -1146,7 +1073,7 @@ xfs_attr_node_removename(xfs_da_args_t *args) xfs_da_state_blk_t *blk; xfs_da_state_blk_t *blk; xfs_inode_t *dp; xfs_inode_t *dp; struct xfs_buf *bp; struct xfs_buf *bp; int retval, error, committed, forkoff; int retval, error, forkoff; trace_xfs_attr_node_removename(args); trace_xfs_attr_node_removename(args); Loading Loading @@ -1220,24 +1147,13 @@ xfs_attr_node_removename(xfs_da_args_t *args) if (retval && (state->path.active > 1)) { if (retval && (state->path.active > 1)) { xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_da3_join(state); error = xfs_da3_join(state); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); /* /* * Commit the Btree join operation and start a new trans. * Commit the Btree join operation and start a new trans. */ */ Loading Loading @@ -1265,25 +1181,14 @@ xfs_attr_node_removename(xfs_da_args_t *args) xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */ if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans, args->flist, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans * and started a new one. We need the inode to be * in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } else } else xfs_trans_brelse(args->trans, bp); xfs_trans_brelse(args->trans, bp); } } Loading fs/xfs/libxfs/xfs_attr_remote.c +4 −27 Original line number Original line Diff line number Diff line Loading @@ -448,8 +448,6 @@ xfs_attr_rmtval_set( * Roll through the "value", allocating blocks on disk as required. * Roll through the "value", allocating blocks on disk as required. */ */ while (blkcnt > 0) { while (blkcnt > 0) { int committed; /* /* * Allocate a single extent, up to the size of the value. * Allocate a single extent, up to the size of the value. * * Loading @@ -467,24 +465,14 @@ xfs_attr_rmtval_set( error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock, blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock, args->total, &map, &nmap, args->flist); args->total, &map, &nmap, args->flist); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); ASSERT(nmap == 1); ASSERT(nmap == 1); ASSERT((map.br_startblock != DELAYSTARTBLOCK) && ASSERT((map.br_startblock != DELAYSTARTBLOCK) && (map.br_startblock != HOLESTARTBLOCK)); (map.br_startblock != HOLESTARTBLOCK)); Loading Loading @@ -615,30 +603,19 @@ xfs_attr_rmtval_remove( blkcnt = args->rmtblkcnt; blkcnt = args->rmtblkcnt; done = 0; done = 0; while (!done) { while (!done) { int committed; xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, XFS_BMAPI_ATTRFORK, 1, args->firstblock, XFS_BMAPI_ATTRFORK, 1, args->firstblock, args->flist, &done); args->flist, &done); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, &committed); args->dp); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, args->dp, 0); /* /* * Close out trans and start the next one in the chain. * Close out trans and start the next one in the chain. */ */ Loading fs/xfs/libxfs/xfs_bmap.c +10 −6 Original line number Original line Diff line number Diff line Loading @@ -325,9 +325,11 @@ xfs_check_block( /* /* * Check that the extents for the inode ip are in the right order in all * Check that the extents for the inode ip are in the right order in all * btree leaves. * btree leaves. THis becomes prohibitively expensive for large extent count * files, so don't bother with inodes that have more than 10,000 extents in * them. The btree record ordering checks will still be done, so for such large * bmapbt constructs that is going to catch most corruptions. */ */ STATIC void STATIC void xfs_bmap_check_leaf_extents( xfs_bmap_check_leaf_extents( xfs_btree_cur_t *cur, /* btree cursor or null */ xfs_btree_cur_t *cur, /* btree cursor or null */ Loading @@ -352,6 +354,10 @@ xfs_bmap_check_leaf_extents( return; return; } } /* skip large extent count inodes */ if (ip->i_d.di_nextents > 10000) return; bno = NULLFSBLOCK; bno = NULLFSBLOCK; mp = ip->i_mount; mp = ip->i_mount; ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork); Loading Loading @@ -1111,7 +1117,6 @@ xfs_bmap_add_attrfork( xfs_trans_t *tp; /* transaction pointer */ xfs_trans_t *tp; /* transaction pointer */ int blks; /* space reservation */ int blks; /* space reservation */ int version = 1; /* superblock attr version */ int version = 1; /* superblock attr version */ int committed; /* xaction was committed */ int logflags; /* logging flags */ int logflags; /* logging flags */ int error; /* error return value */ int error; /* error return value */ Loading Loading @@ -1214,7 +1219,7 @@ xfs_bmap_add_attrfork( xfs_log_sb(tp); xfs_log_sb(tp); } } error = xfs_bmap_finish(&tp, &flist, &committed); error = xfs_bmap_finish(&tp, &flist, NULL); if (error) if (error) goto bmap_cancel; goto bmap_cancel; error = xfs_trans_commit(tp); error = xfs_trans_commit(tp); Loading Loading @@ -5951,7 +5956,6 @@ xfs_bmap_split_extent( struct xfs_trans *tp; struct xfs_trans *tp; struct xfs_bmap_free free_list; struct xfs_bmap_free free_list; xfs_fsblock_t firstfsb; xfs_fsblock_t firstfsb; int committed; int error; int error; tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); Loading @@ -5972,7 +5976,7 @@ xfs_bmap_split_extent( if (error) if (error) goto out; goto out; error = xfs_bmap_finish(&tp, &free_list, &committed); error = xfs_bmap_finish(&tp, &free_list, NULL); if (error) if (error) goto out; goto out; Loading fs/xfs/libxfs/xfs_bmap.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -195,7 +195,7 @@ void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, struct xfs_bmap_free *flist, struct xfs_mount *mp); struct xfs_bmap_free *flist, struct xfs_mount *mp); void xfs_bmap_cancel(struct xfs_bmap_free *flist); void xfs_bmap_cancel(struct xfs_bmap_free *flist); int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, int *committed); struct xfs_inode *ip); void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); Loading fs/xfs/libxfs/xfs_dquot_buf.c +30 −6 Original line number Original line Diff line number Diff line Loading @@ -54,7 +54,7 @@ xfs_dqcheck( xfs_dqid_t id, xfs_dqid_t id, uint type, /* used only when IO_dorepair is true */ uint type, /* used only when IO_dorepair is true */ uint flags, uint flags, char *str) const char *str) { { xfs_dqblk_t *d = (xfs_dqblk_t *)ddq; xfs_dqblk_t *d = (xfs_dqblk_t *)ddq; int errs = 0; int errs = 0; Loading Loading @@ -207,7 +207,8 @@ xfs_dquot_buf_verify_crc( STATIC bool STATIC bool xfs_dquot_buf_verify( xfs_dquot_buf_verify( struct xfs_mount *mp, struct xfs_mount *mp, struct xfs_buf *bp) struct xfs_buf *bp, int warn) { { struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr; struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr; xfs_dqid_t id = 0; xfs_dqid_t id = 0; Loading Loading @@ -240,8 +241,7 @@ xfs_dquot_buf_verify( if (i == 0) if (i == 0) id = be32_to_cpu(ddq->d_id); id = be32_to_cpu(ddq->d_id); error = xfs_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN, error = xfs_dqcheck(mp, ddq, id + i, 0, warn, __func__); "xfs_dquot_buf_verify"); if (error) if (error) return false; return false; } } Loading @@ -256,13 +256,32 @@ xfs_dquot_buf_read_verify( if (!xfs_dquot_buf_verify_crc(mp, bp)) if (!xfs_dquot_buf_verify_crc(mp, bp)) xfs_buf_ioerror(bp, -EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC); else if (!xfs_dquot_buf_verify(mp, bp)) else if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED); if (bp->b_error) if (bp->b_error) xfs_verifier_error(bp); xfs_verifier_error(bp); } } /* * readahead errors are silent and simply leave the buffer as !done so a real * read will then be run with the xfs_dquot_buf_ops verifier. See * xfs_inode_buf_verify() for why we use EIO and ~XBF_DONE here rather than * reporting the failure. */ static void xfs_dquot_buf_readahead_verify( struct xfs_buf *bp) { struct xfs_mount *mp = bp->b_target->bt_mount; if (!xfs_dquot_buf_verify_crc(mp, bp) || !xfs_dquot_buf_verify(mp, bp, 0)) { xfs_buf_ioerror(bp, -EIO); bp->b_flags &= ~XBF_DONE; } } /* /* * we don't calculate the CRC here as that is done when the dquot is flushed to * we don't calculate the CRC here as that is done when the dquot is flushed to * the buffer after the update is done. This ensures that the dquot in the * the buffer after the update is done. This ensures that the dquot in the Loading @@ -274,7 +293,7 @@ xfs_dquot_buf_write_verify( { { struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount; if (!xfs_dquot_buf_verify(mp, bp)) { if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) { xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp); xfs_verifier_error(bp); return; return; Loading @@ -287,3 +306,8 @@ const struct xfs_buf_ops xfs_dquot_buf_ops = { .verify_write = xfs_dquot_buf_write_verify, .verify_write = xfs_dquot_buf_write_verify, }; }; const struct xfs_buf_ops xfs_dquot_buf_ra_ops = { .name = "xfs_dquot_ra", .verify_read = xfs_dquot_buf_readahead_verify, .verify_write = xfs_dquot_buf_write_verify, }; Loading
fs/xfs/libxfs/xfs_attr.c +23 −118 Original line number Original line Diff line number Diff line Loading @@ -207,7 +207,7 @@ xfs_attr_set( struct xfs_trans_res tres; struct xfs_trans_res tres; xfs_fsblock_t firstblock; xfs_fsblock_t firstblock; int rsvd = (flags & ATTR_ROOT) != 0; int rsvd = (flags & ATTR_ROOT) != 0; int error, err2, committed, local; int error, err2, local; XFS_STATS_INC(mp, xs_attr_set); XFS_STATS_INC(mp, xs_attr_set); Loading Loading @@ -334,24 +334,14 @@ xfs_attr_set( */ */ xfs_bmap_init(args.flist, args.firstblock); xfs_bmap_init(args.flist, args.firstblock); error = xfs_attr_shortform_to_leaf(&args); error = xfs_attr_shortform_to_leaf(&args); if (!error) { if (!error) error = xfs_bmap_finish(&args.trans, args.flist, error = xfs_bmap_finish(&args.trans, args.flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args.trans = NULL; args.trans = NULL; xfs_bmap_cancel(&flist); xfs_bmap_cancel(&flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args.trans, dp, 0); /* /* * Commit the leaf transformation. We'll need another (linked) * Commit the leaf transformation. We'll need another (linked) * transaction to add the new attribute to the leaf. * transaction to add the new attribute to the leaf. Loading Loading @@ -568,7 +558,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) { { xfs_inode_t *dp; xfs_inode_t *dp; struct xfs_buf *bp; struct xfs_buf *bp; int retval, error, committed, forkoff; int retval, error, forkoff; trace_xfs_attr_leaf_addname(args); trace_xfs_attr_leaf_addname(args); Loading Loading @@ -628,24 +618,14 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) */ */ xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_node(args); error = xfs_attr3_leaf_to_node(args); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); /* /* * Commit the current trans (including the inode) and start * Commit the current trans (including the inode) and start * a new one. * a new one. Loading Loading @@ -729,25 +709,14 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */ if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans, args->flist, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans * and started a new one. We need the inode to be * in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } } /* /* Loading Loading @@ -775,7 +744,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) { { xfs_inode_t *dp; xfs_inode_t *dp; struct xfs_buf *bp; struct xfs_buf *bp; int error, committed, forkoff; int error, forkoff; trace_xfs_attr_leaf_removename(args); trace_xfs_attr_leaf_removename(args); Loading Loading @@ -803,23 +772,13 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */ if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } } return 0; return 0; } } Loading Loading @@ -877,7 +836,7 @@ xfs_attr_node_addname(xfs_da_args_t *args) xfs_da_state_blk_t *blk; xfs_da_state_blk_t *blk; xfs_inode_t *dp; xfs_inode_t *dp; xfs_mount_t *mp; xfs_mount_t *mp; int committed, retval, error; int retval, error; trace_xfs_attr_node_addname(args); trace_xfs_attr_node_addname(args); Loading Loading @@ -938,26 +897,15 @@ xfs_attr_node_addname(xfs_da_args_t *args) state = NULL; state = NULL; xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_node(args); error = xfs_attr3_leaf_to_node(args); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans, args->flist, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans * and started a new one. We need the inode to be * in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); /* /* * Commit the node conversion and start the next * Commit the node conversion and start the next * trans in the chain. * trans in the chain. Loading @@ -977,23 +925,13 @@ xfs_attr_node_addname(xfs_da_args_t *args) */ */ xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_da3_split(state); error = xfs_da3_split(state); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } else { } else { /* /* * Addition succeeded, update Btree hashvals. * Addition succeeded, update Btree hashvals. Loading Loading @@ -1086,25 +1024,14 @@ xfs_attr_node_addname(xfs_da_args_t *args) if (retval && (state->path.active > 1)) { if (retval && (state->path.active > 1)) { xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_da3_join(state); error = xfs_da3_join(state); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans, args->flist, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans * and started a new one. We need the inode to be * in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } } /* /* Loading Loading @@ -1146,7 +1073,7 @@ xfs_attr_node_removename(xfs_da_args_t *args) xfs_da_state_blk_t *blk; xfs_da_state_blk_t *blk; xfs_inode_t *dp; xfs_inode_t *dp; struct xfs_buf *bp; struct xfs_buf *bp; int retval, error, committed, forkoff; int retval, error, forkoff; trace_xfs_attr_node_removename(args); trace_xfs_attr_node_removename(args); Loading Loading @@ -1220,24 +1147,13 @@ xfs_attr_node_removename(xfs_da_args_t *args) if (retval && (state->path.active > 1)) { if (retval && (state->path.active > 1)) { xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_da3_join(state); error = xfs_da3_join(state); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); /* /* * Commit the Btree join operation and start a new trans. * Commit the Btree join operation and start a new trans. */ */ Loading Loading @@ -1265,25 +1181,14 @@ xfs_attr_node_removename(xfs_da_args_t *args) xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); /* bp is gone due to xfs_da_shrink_inode */ /* bp is gone due to xfs_da_shrink_inode */ if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, error = xfs_bmap_finish(&args->trans, args->flist, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); goto out; goto out; } } /* * bmap_finish() may have committed the last trans * and started a new one. We need the inode to be * in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); } else } else xfs_trans_brelse(args->trans, bp); xfs_trans_brelse(args->trans, bp); } } Loading
fs/xfs/libxfs/xfs_attr_remote.c +4 −27 Original line number Original line Diff line number Diff line Loading @@ -448,8 +448,6 @@ xfs_attr_rmtval_set( * Roll through the "value", allocating blocks on disk as required. * Roll through the "value", allocating blocks on disk as required. */ */ while (blkcnt > 0) { while (blkcnt > 0) { int committed; /* /* * Allocate a single extent, up to the size of the value. * Allocate a single extent, up to the size of the value. * * Loading @@ -467,24 +465,14 @@ xfs_attr_rmtval_set( error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno, blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock, blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock, args->total, &map, &nmap, args->flist); args->total, &map, &nmap, args->flist); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, dp); &committed); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, dp, 0); ASSERT(nmap == 1); ASSERT(nmap == 1); ASSERT((map.br_startblock != DELAYSTARTBLOCK) && ASSERT((map.br_startblock != DELAYSTARTBLOCK) && (map.br_startblock != HOLESTARTBLOCK)); (map.br_startblock != HOLESTARTBLOCK)); Loading Loading @@ -615,30 +603,19 @@ xfs_attr_rmtval_remove( blkcnt = args->rmtblkcnt; blkcnt = args->rmtblkcnt; done = 0; done = 0; while (!done) { while (!done) { int committed; xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock); error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt, XFS_BMAPI_ATTRFORK, 1, args->firstblock, XFS_BMAPI_ATTRFORK, 1, args->firstblock, args->flist, &done); args->flist, &done); if (!error) { if (!error) error = xfs_bmap_finish(&args->trans, args->flist, error = xfs_bmap_finish(&args->trans, args->flist, &committed); args->dp); } if (error) { if (error) { ASSERT(committed); args->trans = NULL; args->trans = NULL; xfs_bmap_cancel(args->flist); xfs_bmap_cancel(args->flist); return error; return error; } } /* * bmap_finish() may have committed the last trans and started * a new one. We need the inode to be in all transactions. */ if (committed) xfs_trans_ijoin(args->trans, args->dp, 0); /* /* * Close out trans and start the next one in the chain. * Close out trans and start the next one in the chain. */ */ Loading
fs/xfs/libxfs/xfs_bmap.c +10 −6 Original line number Original line Diff line number Diff line Loading @@ -325,9 +325,11 @@ xfs_check_block( /* /* * Check that the extents for the inode ip are in the right order in all * Check that the extents for the inode ip are in the right order in all * btree leaves. * btree leaves. THis becomes prohibitively expensive for large extent count * files, so don't bother with inodes that have more than 10,000 extents in * them. The btree record ordering checks will still be done, so for such large * bmapbt constructs that is going to catch most corruptions. */ */ STATIC void STATIC void xfs_bmap_check_leaf_extents( xfs_bmap_check_leaf_extents( xfs_btree_cur_t *cur, /* btree cursor or null */ xfs_btree_cur_t *cur, /* btree cursor or null */ Loading @@ -352,6 +354,10 @@ xfs_bmap_check_leaf_extents( return; return; } } /* skip large extent count inodes */ if (ip->i_d.di_nextents > 10000) return; bno = NULLFSBLOCK; bno = NULLFSBLOCK; mp = ip->i_mount; mp = ip->i_mount; ifp = XFS_IFORK_PTR(ip, whichfork); ifp = XFS_IFORK_PTR(ip, whichfork); Loading Loading @@ -1111,7 +1117,6 @@ xfs_bmap_add_attrfork( xfs_trans_t *tp; /* transaction pointer */ xfs_trans_t *tp; /* transaction pointer */ int blks; /* space reservation */ int blks; /* space reservation */ int version = 1; /* superblock attr version */ int version = 1; /* superblock attr version */ int committed; /* xaction was committed */ int logflags; /* logging flags */ int logflags; /* logging flags */ int error; /* error return value */ int error; /* error return value */ Loading Loading @@ -1214,7 +1219,7 @@ xfs_bmap_add_attrfork( xfs_log_sb(tp); xfs_log_sb(tp); } } error = xfs_bmap_finish(&tp, &flist, &committed); error = xfs_bmap_finish(&tp, &flist, NULL); if (error) if (error) goto bmap_cancel; goto bmap_cancel; error = xfs_trans_commit(tp); error = xfs_trans_commit(tp); Loading Loading @@ -5951,7 +5956,6 @@ xfs_bmap_split_extent( struct xfs_trans *tp; struct xfs_trans *tp; struct xfs_bmap_free free_list; struct xfs_bmap_free free_list; xfs_fsblock_t firstfsb; xfs_fsblock_t firstfsb; int committed; int error; int error; tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); Loading @@ -5972,7 +5976,7 @@ xfs_bmap_split_extent( if (error) if (error) goto out; goto out; error = xfs_bmap_finish(&tp, &free_list, &committed); error = xfs_bmap_finish(&tp, &free_list, NULL); if (error) if (error) goto out; goto out; Loading
fs/xfs/libxfs/xfs_bmap.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -195,7 +195,7 @@ void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, struct xfs_bmap_free *flist, struct xfs_mount *mp); struct xfs_bmap_free *flist, struct xfs_mount *mp); void xfs_bmap_cancel(struct xfs_bmap_free *flist); void xfs_bmap_cancel(struct xfs_bmap_free *flist); int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, int *committed); struct xfs_inode *ip); void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); Loading
fs/xfs/libxfs/xfs_dquot_buf.c +30 −6 Original line number Original line Diff line number Diff line Loading @@ -54,7 +54,7 @@ xfs_dqcheck( xfs_dqid_t id, xfs_dqid_t id, uint type, /* used only when IO_dorepair is true */ uint type, /* used only when IO_dorepair is true */ uint flags, uint flags, char *str) const char *str) { { xfs_dqblk_t *d = (xfs_dqblk_t *)ddq; xfs_dqblk_t *d = (xfs_dqblk_t *)ddq; int errs = 0; int errs = 0; Loading Loading @@ -207,7 +207,8 @@ xfs_dquot_buf_verify_crc( STATIC bool STATIC bool xfs_dquot_buf_verify( xfs_dquot_buf_verify( struct xfs_mount *mp, struct xfs_mount *mp, struct xfs_buf *bp) struct xfs_buf *bp, int warn) { { struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr; struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr; xfs_dqid_t id = 0; xfs_dqid_t id = 0; Loading Loading @@ -240,8 +241,7 @@ xfs_dquot_buf_verify( if (i == 0) if (i == 0) id = be32_to_cpu(ddq->d_id); id = be32_to_cpu(ddq->d_id); error = xfs_dqcheck(mp, ddq, id + i, 0, XFS_QMOPT_DOWARN, error = xfs_dqcheck(mp, ddq, id + i, 0, warn, __func__); "xfs_dquot_buf_verify"); if (error) if (error) return false; return false; } } Loading @@ -256,13 +256,32 @@ xfs_dquot_buf_read_verify( if (!xfs_dquot_buf_verify_crc(mp, bp)) if (!xfs_dquot_buf_verify_crc(mp, bp)) xfs_buf_ioerror(bp, -EFSBADCRC); xfs_buf_ioerror(bp, -EFSBADCRC); else if (!xfs_dquot_buf_verify(mp, bp)) else if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED); if (bp->b_error) if (bp->b_error) xfs_verifier_error(bp); xfs_verifier_error(bp); } } /* * readahead errors are silent and simply leave the buffer as !done so a real * read will then be run with the xfs_dquot_buf_ops verifier. See * xfs_inode_buf_verify() for why we use EIO and ~XBF_DONE here rather than * reporting the failure. */ static void xfs_dquot_buf_readahead_verify( struct xfs_buf *bp) { struct xfs_mount *mp = bp->b_target->bt_mount; if (!xfs_dquot_buf_verify_crc(mp, bp) || !xfs_dquot_buf_verify(mp, bp, 0)) { xfs_buf_ioerror(bp, -EIO); bp->b_flags &= ~XBF_DONE; } } /* /* * we don't calculate the CRC here as that is done when the dquot is flushed to * we don't calculate the CRC here as that is done when the dquot is flushed to * the buffer after the update is done. This ensures that the dquot in the * the buffer after the update is done. This ensures that the dquot in the Loading @@ -274,7 +293,7 @@ xfs_dquot_buf_write_verify( { { struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount; if (!xfs_dquot_buf_verify(mp, bp)) { if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) { xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp); xfs_verifier_error(bp); return; return; Loading @@ -287,3 +306,8 @@ const struct xfs_buf_ops xfs_dquot_buf_ops = { .verify_write = xfs_dquot_buf_write_verify, .verify_write = xfs_dquot_buf_write_verify, }; }; const struct xfs_buf_ops xfs_dquot_buf_ra_ops = { .name = "xfs_dquot_ra", .verify_read = xfs_dquot_buf_readahead_verify, .verify_write = xfs_dquot_buf_write_verify, };