xfs: use ->t_firstblock in xattr ops

Similar to the dirops code, the xattr code uses an on-stack
firstblock variable for the various operations. This code rolls the
underlying transaction in various places, however, which means we
cannot simply replace the local firstblock vars with ->t_firstblock.
Doing so (without further changes) would invalidate the memory
pointed to by xfs_da_args.firstblock as soon as the first
transaction rolls.

To avoid this problem, remove xfs_da_args.firstblock and replace all
such accesses with ->t_firstblock at the same time. This ensures
that accesses to the current firstblock always occur through the
current transaction rather than a potentially invalid xfs_da_args
pointer.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
Brian Foster
2018-07-11 22:26:22 -07:00
committed by Darrick J. Wong
parent 825d75cd8c
commit 766139032f
7 changed files with 33 additions and 38 deletions

View File

@@ -480,11 +480,13 @@ xfs_attr_rmtval_set(
* extent and then crash then the block may not contain the
* correct metadata after log recovery occurs.
*/
xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
xfs_defer_init(args->trans, args->trans->t_dfops,
&args->trans->t_firstblock);
nmap = 1;
error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
blkcnt, XFS_BMAPI_ATTRFORK, args->firstblock,
args->total, &map, &nmap);
blkcnt, XFS_BMAPI_ATTRFORK,
&args->trans->t_firstblock, args->total, &map,
&nmap);
if (error)
goto out_defer_cancel;
xfs_defer_ijoin(args->trans->t_dfops, dp);
@@ -522,7 +524,8 @@ xfs_attr_rmtval_set(
ASSERT(blkcnt > 0);
xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
xfs_defer_init(args->trans, args->trans->t_dfops,
&args->trans->t_firstblock);
nmap = 1;
error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
blkcnt, &map, &nmap,
@@ -626,10 +629,11 @@ xfs_attr_rmtval_remove(
blkcnt = args->rmtblkcnt;
done = 0;
while (!done) {
xfs_defer_init(NULL, args->trans->t_dfops, args->firstblock);
xfs_defer_init(args->trans, args->trans->t_dfops,
&args->trans->t_firstblock);
error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
XFS_BMAPI_ATTRFORK, 1, args->firstblock,
&done);
XFS_BMAPI_ATTRFORK, 1,
&args->trans->t_firstblock, &done);
if (error)
goto out_defer_cancel;
xfs_defer_ijoin(args->trans->t_dfops, args->dp);