Skip to content

Commit 6b3582a

Browse files
committed
Merge tag 'incore-rtgroups-6.13_2024-11-05' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into staging-merge
xfs: create incore rt allocation groups [v5.5 04/10] Add in-memory data structures for sharding the realtime volume into independent allocation groups. For existing filesystems, the entire rt volume is modelled as having a single large group, with (potentially) a number of rt extents exceeding 2^32 blocks, though these are not likely to exist because the codebase has been a bit broken for decades. The next series fills in the ondisk format and other supporting structures. With a bit of luck, this should all go splendidly. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2 parents d7a5b69 + f220f6d commit 6b3582a

36 files changed

+2010
-700
lines changed

fs/xfs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ xfs-y += $(addprefix libxfs/, \
6161
# xfs_rtbitmap is shared with libxfs
6262
xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \
6363
xfs_rtbitmap.o \
64+
xfs_rtgroup.o \
6465
)
6566

6667
# highlevel code

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4094,7 +4094,7 @@ xfs_bmapi_reserve_delalloc(
40944094

40954095
fdblocks = indlen;
40964096
if (XFS_IS_REALTIME_INODE(ip)) {
4097-
error = xfs_dec_frextents(mp, xfs_rtb_to_rtx(mp, alen));
4097+
error = xfs_dec_frextents(mp, xfs_blen_to_rtbxlen(mp, alen));
40984098
if (error)
40994099
goto out_unreserve_quota;
41004100
} else {
@@ -4129,7 +4129,7 @@ xfs_bmapi_reserve_delalloc(
41294129

41304130
out_unreserve_frextents:
41314131
if (XFS_IS_REALTIME_INODE(ip))
4132-
xfs_add_frextents(mp, xfs_rtb_to_rtx(mp, alen));
4132+
xfs_add_frextents(mp, xfs_blen_to_rtbxlen(mp, alen));
41334133
out_unreserve_quota:
41344134
if (XFS_IS_QUOTA_ON(mp))
41354135
xfs_quota_unreserve_blkres(ip, alen);
@@ -5037,7 +5037,7 @@ xfs_bmap_del_extent_delay(
50375037
fdblocks = da_diff;
50385038

50395039
if (isrt)
5040-
xfs_add_frextents(mp, xfs_rtb_to_rtx(mp, del->br_blockcount));
5040+
xfs_add_frextents(mp, xfs_blen_to_rtbxlen(mp, del->br_blockcount));
50415041
else
50425042
fdblocks += del->br_blockcount;
50435043

@@ -5116,6 +5116,34 @@ xfs_bmap_del_extent_cow(
51165116
ip->i_delayed_blks -= del->br_blockcount;
51175117
}
51185118

5119+
static int
5120+
xfs_bmap_free_rtblocks(
5121+
struct xfs_trans *tp,
5122+
struct xfs_bmbt_irec *del)
5123+
{
5124+
struct xfs_rtgroup *rtg;
5125+
int error;
5126+
5127+
rtg = xfs_rtgroup_grab(tp->t_mountp, 0);
5128+
if (!rtg)
5129+
return -EIO;
5130+
5131+
/*
5132+
* Ensure the bitmap and summary inodes are locked and joined to the
5133+
* transaction before modifying them.
5134+
*/
5135+
if (!(tp->t_flags & XFS_TRANS_RTBITMAP_LOCKED)) {
5136+
tp->t_flags |= XFS_TRANS_RTBITMAP_LOCKED;
5137+
xfs_rtgroup_lock(rtg, XFS_RTGLOCK_BITMAP);
5138+
xfs_rtgroup_trans_join(tp, rtg, XFS_RTGLOCK_BITMAP);
5139+
}
5140+
5141+
error = xfs_rtfree_blocks(tp, rtg, del->br_startblock,
5142+
del->br_blockcount);
5143+
xfs_rtgroup_rele(rtg);
5144+
return error;
5145+
}
5146+
51195147
/*
51205148
* Called by xfs_bmapi to update file extent records and the btree
51215149
* after removing space.
@@ -5331,17 +5359,7 @@ xfs_bmap_del_extent_real(
53315359
if (xfs_is_reflink_inode(ip) && whichfork == XFS_DATA_FORK) {
53325360
xfs_refcount_decrease_extent(tp, del);
53335361
} else if (xfs_ifork_is_realtime(ip, whichfork)) {
5334-
/*
5335-
* Ensure the bitmap and summary inodes are locked
5336-
* and joined to the transaction before modifying them.
5337-
*/
5338-
if (!(tp->t_flags & XFS_TRANS_RTBITMAP_LOCKED)) {
5339-
tp->t_flags |= XFS_TRANS_RTBITMAP_LOCKED;
5340-
xfs_rtbitmap_lock(mp);
5341-
xfs_rtbitmap_trans_join(tp);
5342-
}
5343-
error = xfs_rtfree_blocks(tp, del->br_startblock,
5344-
del->br_blockcount);
5362+
error = xfs_bmap_free_rtblocks(tp, del);
53455363
} else {
53465364
unsigned int efi_flags = 0;
53475365

fs/xfs/libxfs/xfs_format.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ typedef struct xfs_sb {
176176

177177
xfs_ino_t sb_metadirino; /* metadata directory tree root */
178178

179+
xfs_rgnumber_t sb_rgcount; /* number of realtime groups */
180+
xfs_rtxlen_t sb_rgextents; /* size of a realtime group in rtx */
181+
179182
/* must be padded to 64 bit alignment */
180183
} xfs_sb_t;
181184

0 commit comments

Comments
 (0)