summaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iomap.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-01-27 02:20:42 +0100
committerDarrick J. Wong <djwong@kernel.org>2021-02-03 18:18:49 +0100
commit02b7ee4eb613240d2bb3f6a67723f94ceda19eb6 (patch)
treec56da9d29420041929a4eb00d817b48fa7dea482 /fs/xfs/xfs_iomap.c
parentxfs: fix up build warnings when quotas are disabled (diff)
downloadlinux-02b7ee4eb613240d2bb3f6a67723f94ceda19eb6.tar.xz
linux-02b7ee4eb613240d2bb3f6a67723f94ceda19eb6.zip
xfs: reserve data and rt quota at the same time
Modify xfs_trans_reserve_quota_nblks so that we can reserve data and realtime blocks from the dquot at the same time. This change has the theoretical side effect that for allocations to realtime files we will reserve from the dquot both the number of rtblocks being allocated and the number of bmbt blocks that might be needed to add the mapping. However, since the mount code disables quota if it finds a realtime device, this should not result in any behavior changes. Now that we've moved the inode creation callers away from using the _nblks function, we can repurpose the (now unused) ninos argument for realtime blocks, so make that change. This also replaces the flags argument with a boolean parameter to force the reservation since we don't need to distinguish between data and rt quota reservations any more, and the only flag being passed in was FORCE_RES. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r--fs/xfs/xfs_iomap.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index b046eadd3b21..fba7303d8ed6 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -194,25 +194,25 @@ xfs_iomap_write_direct(
struct xfs_trans *tp;
xfs_filblks_t resaligned;
int nimaps;
- int quota_flag;
- uint qblocks, resblks;
+ unsigned int dblocks, rblocks;
unsigned int resrtextents = 0;
int error;
int bmapi_flags = XFS_BMAPI_PREALLOC;
- uint tflags = 0;
+ int tflags = 0;
+ bool force = false;
ASSERT(count_fsb > 0);
resaligned = xfs_aligned_fsb_count(offset_fsb, count_fsb,
xfs_get_extsz_hint(ip));
if (unlikely(XFS_IS_REALTIME_INODE(ip))) {
- resrtextents = qblocks = resaligned;
+ resrtextents = resaligned;
resrtextents /= mp->m_sb.sb_rextsize;
- resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
- quota_flag = XFS_QMOPT_RES_RTBLKS;
+ dblocks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
+ rblocks = resaligned;
} else {
- resblks = qblocks = XFS_DIOSTRAT_SPACE_RES(mp, resaligned);
- quota_flag = XFS_QMOPT_RES_REGBLKS;
+ dblocks = XFS_DIOSTRAT_SPACE_RES(mp, resaligned);
+ rblocks = 0;
}
error = xfs_qm_dqattach(ip);
@@ -235,18 +235,19 @@ xfs_iomap_write_direct(
if (IS_DAX(VFS_I(ip))) {
bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO;
if (imap->br_state == XFS_EXT_UNWRITTEN) {
+ force = true;
tflags |= XFS_TRANS_RESERVE;
- resblks = qblocks = XFS_DIOSTRAT_SPACE_RES(mp, 0) << 1;
+ dblocks = XFS_DIOSTRAT_SPACE_RES(mp, 0) << 1;
}
}
- error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, resrtextents,
+ error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, dblocks, resrtextents,
tflags, &tp);
if (error)
return error;
xfs_ilock(ip, XFS_ILOCK_EXCL);
- error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks, 0, quota_flag);
+ error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, force);
if (error)
goto out_trans_cancel;
@@ -559,8 +560,7 @@ xfs_iomap_write_unwritten(
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0);
- error = xfs_trans_reserve_quota_nblks(tp, ip, resblks, 0,
- XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES);
+ error = xfs_trans_reserve_quota_nblks(tp, ip, resblks, 0, true);
if (error)
goto error_on_bmapi_transaction;