diff options
author | Christoph Hellwig <hch@lst.de> | 2023-12-18 05:57:35 +0100 |
---|---|---|
committer | Chandan Babu R <chandanbabu@kernel.org> | 2023-12-22 06:48:15 +0100 |
commit | 26e5eed7802299a666714ee511da58d906e8770c (patch) | |
tree | 6662bd15fef4842e3cd2df5770b7285e83bc6157 /fs/xfs | |
parent | xfs: remove XFS_RTMIN/XFS_RTMAX (diff) | |
download | linux-26e5eed7802299a666714ee511da58d906e8770c.tar.xz linux-26e5eed7802299a666714ee511da58d906e8770c.zip |
xfs: reorder the minlen and prod calculations in xfs_bmap_rtalloc
xfs_bmap_rtalloc is a bit of a mess in terms of calculating the locally
need variables. Reorder them a bit so that related code is located
next to each other - the raminlen calculation moves up next to where
the maximum len is calculated, and all the prod calculation is move
into a single place and rearranged so that the real prod calculation
only happens when it actually is needed.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 4b8fc8e510ac..ff2d7b237ef6 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1375,7 +1375,6 @@ xfs_bmap_rtalloc( align = xfs_get_extsz_hint(ap->ip); retry: - prod = xfs_extlen_to_rtxlen(mp, align); error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 1, ap->eof, 0, ap->conv, &ap->offset, &ap->length); @@ -1394,13 +1393,6 @@ retry: minlen += orig_offset - ap->offset; /* - * If the offset & length are not perfectly aligned - * then kill prod, it will just get us in trouble. - */ - div_u64_rem(ap->offset, align, &mod); - if (mod || ap->length % align) - prod = 1; - /* * Set ralen to be the actual requested length in rtextents. * * If the old value was close enough to XFS_BMBT_MAX_EXTLEN that @@ -1410,6 +1402,7 @@ retry: * adjust the starting point to match it. */ ralen = xfs_extlen_to_rtxlen(mp, min(ap->length, XFS_MAX_BMBT_EXTLEN)); + raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen)); /* * Lock out modifications to both the RT bitmap and summary inodes @@ -1438,7 +1431,16 @@ retry: start = 0; } - raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen)); + /* + * Only bother calculating a real prod factor if offset & length are + * perfectly aligned, otherwise it will just get us in trouble. + */ + div_u64_rem(ap->offset, align, &mod); + if (mod || ap->length % align) + prod = 1; + else + prod = xfs_extlen_to_rtxlen(mp, align); + error = xfs_rtallocate_extent(ap->tp, start, raminlen, ralen, &ralen, ap->wasdel, prod, &rtx); if (error == -ENOSPC) { |