diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2018-01-25 16:58:13 -0500 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2018-01-29 10:27:23 -0500 |
commit | 751f3767c245f9adf4f0a4f8f04aae9ae1d675a0 (patch) | |
tree | 7ea95df6396a361c58182ee632ed22055c2d5a47 | |
parent | 22431bf3dfbf44d7356933776eb486a6a01dea6f (diff) |
xfs: refactor accounting updates out of xfs_bmap_btalloc
Move all the inode and quota accounting updates out of xfs_bmap_btalloc
in preparation for fixing some quota accounting problems with copy on
write.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
-rw-r--r-- | fs/xfs/libxfs/xfs_bmap.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 0c9c9cdd532a..4582f5547ae3 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
@@ -3337,6 +3337,22 @@ xfs_bmap_btalloc_filestreams( | |||
3337 | return 0; | 3337 | return 0; |
3338 | } | 3338 | } |
3339 | 3339 | ||
3340 | /* Update all inode and quota accounting for the allocation we just did. */ | ||
3341 | static void | ||
3342 | xfs_bmap_btalloc_accounting( | ||
3343 | struct xfs_bmalloca *ap, | ||
3344 | struct xfs_alloc_arg *args) | ||
3345 | { | ||
3346 | if (!(ap->flags & XFS_BMAPI_COWFORK)) | ||
3347 | ap->ip->i_d.di_nblocks += args->len; | ||
3348 | xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); | ||
3349 | if (ap->wasdel) | ||
3350 | ap->ip->i_delayed_blks -= args->len; | ||
3351 | xfs_trans_mod_dquot_byino(ap->tp, ap->ip, | ||
3352 | ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : XFS_TRANS_DQ_BCOUNT, | ||
3353 | args->len); | ||
3354 | } | ||
3355 | |||
3340 | STATIC int | 3356 | STATIC int |
3341 | xfs_bmap_btalloc( | 3357 | xfs_bmap_btalloc( |
3342 | struct xfs_bmalloca *ap) /* bmap alloc argument struct */ | 3358 | struct xfs_bmalloca *ap) /* bmap alloc argument struct */ |
@@ -3571,19 +3587,7 @@ xfs_bmap_btalloc( | |||
3571 | *ap->firstblock = args.fsbno; | 3587 | *ap->firstblock = args.fsbno; |
3572 | ASSERT(nullfb || fb_agno <= args.agno); | 3588 | ASSERT(nullfb || fb_agno <= args.agno); |
3573 | ap->length = args.len; | 3589 | ap->length = args.len; |
3574 | if (!(ap->flags & XFS_BMAPI_COWFORK)) | 3590 | xfs_bmap_btalloc_accounting(ap, &args); |
3575 | ap->ip->i_d.di_nblocks += args.len; | ||
3576 | xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE); | ||
3577 | if (ap->wasdel) | ||
3578 | ap->ip->i_delayed_blks -= args.len; | ||
3579 | /* | ||
3580 | * Adjust the disk quota also. This was reserved | ||
3581 | * earlier. | ||
3582 | */ | ||
3583 | xfs_trans_mod_dquot_byino(ap->tp, ap->ip, | ||
3584 | ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT : | ||
3585 | XFS_TRANS_DQ_BCOUNT, | ||
3586 | (long) args.len); | ||
3587 | } else { | 3591 | } else { |
3588 | ap->blkno = NULLFSBLOCK; | 3592 | ap->blkno = NULLFSBLOCK; |
3589 | ap->length = 0; | 3593 | ap->length = 0; |