Skip to content

Commit d0e85e7

Browse files
author
Chandan Babu R
committed
Merge tag 'realtime-fixes-6.7_2023-10-19' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.7-mergeA
xfs: minor bugfixes for rt stuff [v1.1] This is a preparatory patchset that fixes a few miscellaneous bugs before we start in on larger cleanups of realtime units usage. v1.1: various cleanups suggested by hch With a bit of luck, this should all go splendidly. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org> * tag 'realtime-fixes-6.7_2023-10-19' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux: xfs: rt stubs should return negative errnos when rt disabled xfs: prevent rt growfs when quota is enabled xfs: hoist freeing of rt data fork extent mappings xfs: bump max fsgeom struct version
2 parents 05d3ef8 + c2988eb commit d0e85e7

File tree

5 files changed

+54
-29
lines changed

5 files changed

+54
-29
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5057,33 +5057,20 @@ xfs_bmap_del_extent_real(
50575057

50585058
flags = XFS_ILOG_CORE;
50595059
if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) {
5060-
xfs_filblks_t len;
5061-
xfs_extlen_t mod;
5062-
5063-
len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize,
5064-
&mod);
5065-
ASSERT(mod == 0);
5066-
50675060
if (!(bflags & XFS_BMAPI_REMAP)) {
5068-
xfs_fsblock_t bno;
5069-
5070-
bno = div_u64_rem(del->br_startblock,
5071-
mp->m_sb.sb_rextsize, &mod);
5072-
ASSERT(mod == 0);
5073-
5074-
error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len);
5061+
error = xfs_rtfree_blocks(tp, del->br_startblock,
5062+
del->br_blockcount);
50755063
if (error)
50765064
goto done;
50775065
}
50785066

50795067
do_fx = 0;
5080-
nblks = len * mp->m_sb.sb_rextsize;
50815068
qfield = XFS_TRANS_DQ_RTBCOUNT;
50825069
} else {
50835070
do_fx = 1;
5084-
nblks = del->br_blockcount;
50855071
qfield = XFS_TRANS_DQ_BCOUNT;
50865072
}
5073+
nblks = del->br_blockcount;
50875074

50885075
del_endblock = del->br_startblock + del->br_blockcount;
50895076
if (cur) {

fs/xfs/libxfs/xfs_rtbitmap.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,39 @@ xfs_rtfree_extent(
10051005
return 0;
10061006
}
10071007

1008+
/*
1009+
* Free some blocks in the realtime subvolume. rtbno and rtlen are in units of
1010+
* rt blocks, not rt extents; must be aligned to the rt extent size; and rtlen
1011+
* cannot exceed XFS_MAX_BMBT_EXTLEN.
1012+
*/
1013+
int
1014+
xfs_rtfree_blocks(
1015+
struct xfs_trans *tp,
1016+
xfs_fsblock_t rtbno,
1017+
xfs_filblks_t rtlen)
1018+
{
1019+
struct xfs_mount *mp = tp->t_mountp;
1020+
xfs_rtblock_t bno;
1021+
xfs_filblks_t len;
1022+
xfs_extlen_t mod;
1023+
1024+
ASSERT(rtlen <= XFS_MAX_BMBT_EXTLEN);
1025+
1026+
len = div_u64_rem(rtlen, mp->m_sb.sb_rextsize, &mod);
1027+
if (mod) {
1028+
ASSERT(mod == 0);
1029+
return -EIO;
1030+
}
1031+
1032+
bno = div_u64_rem(rtbno, mp->m_sb.sb_rextsize, &mod);
1033+
if (mod) {
1034+
ASSERT(mod == 0);
1035+
return -EIO;
1036+
}
1037+
1038+
return xfs_rtfree_extent(tp, bno, len);
1039+
}
1040+
10081041
/* Find all the free records within a given range. */
10091042
int
10101043
xfs_rtalloc_query_range(

fs/xfs/libxfs/xfs_sb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern uint64_t xfs_sb_version_to_features(struct xfs_sb *sbp);
2525

2626
extern int xfs_update_secondary_sbs(struct xfs_mount *mp);
2727

28-
#define XFS_FS_GEOM_MAX_STRUCT_VER (4)
28+
#define XFS_FS_GEOM_MAX_STRUCT_VER (5)
2929
extern void xfs_fs_geometry(struct xfs_mount *mp, struct xfs_fsop_geom *geo,
3030
int struct_version);
3131
extern int xfs_sb_read_secondary(struct xfs_mount *mp,

fs/xfs/xfs_rtalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ xfs_growfs_rt(
954954
return -EINVAL;
955955

956956
/* Unsupported realtime features. */
957-
if (xfs_has_rmapbt(mp) || xfs_has_reflink(mp))
957+
if (xfs_has_rmapbt(mp) || xfs_has_reflink(mp) || xfs_has_quota(mp))
958958
return -EOPNOTSUPP;
959959

960960
nrblocks = in->newblocks;

fs/xfs/xfs_rtalloc.h

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ xfs_rtfree_extent(
5858
xfs_rtblock_t bno, /* starting block number to free */
5959
xfs_extlen_t len); /* length of extent freed */
6060

61+
/* Same as above, but in units of rt blocks. */
62+
int xfs_rtfree_blocks(struct xfs_trans *tp, xfs_fsblock_t rtbno,
63+
xfs_filblks_t rtlen);
64+
6165
/*
6266
* Initialize realtime fields in the mount structure.
6367
*/
@@ -137,16 +141,17 @@ int xfs_rtalloc_extent_is_free(struct xfs_mount *mp, struct xfs_trans *tp,
137141
bool *is_free);
138142
int xfs_rtalloc_reinit_frextents(struct xfs_mount *mp);
139143
#else
140-
# define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (ENOSYS)
141-
# define xfs_rtfree_extent(t,b,l) (ENOSYS)
142-
# define xfs_rtpick_extent(m,t,l,rb) (ENOSYS)
143-
# define xfs_growfs_rt(mp,in) (ENOSYS)
144-
# define xfs_rtalloc_query_range(t,l,h,f,p) (ENOSYS)
145-
# define xfs_rtalloc_query_all(m,t,f,p) (ENOSYS)
146-
# define xfs_rtbuf_get(m,t,b,i,p) (ENOSYS)
147-
# define xfs_verify_rtbno(m, r) (false)
148-
# define xfs_rtalloc_extent_is_free(m,t,s,l,i) (ENOSYS)
149-
# define xfs_rtalloc_reinit_frextents(m) (0)
144+
# define xfs_rtallocate_extent(t,b,min,max,l,f,p,rb) (-ENOSYS)
145+
# define xfs_rtfree_extent(t,b,l) (-ENOSYS)
146+
# define xfs_rtfree_blocks(t,rb,rl) (-ENOSYS)
147+
# define xfs_rtpick_extent(m,t,l,rb) (-ENOSYS)
148+
# define xfs_growfs_rt(mp,in) (-ENOSYS)
149+
# define xfs_rtalloc_query_range(m,t,l,h,f,p) (-ENOSYS)
150+
# define xfs_rtalloc_query_all(m,t,f,p) (-ENOSYS)
151+
# define xfs_rtbuf_get(m,t,b,i,p) (-ENOSYS)
152+
# define xfs_verify_rtbno(m, r) (false)
153+
# define xfs_rtalloc_extent_is_free(m,t,s,l,i) (-ENOSYS)
154+
# define xfs_rtalloc_reinit_frextents(m) (0)
150155
static inline int /* error */
151156
xfs_rtmount_init(
152157
xfs_mount_t *mp) /* file system mount structure */
@@ -157,7 +162,7 @@ xfs_rtmount_init(
157162
xfs_warn(mp, "Not built with CONFIG_XFS_RT");
158163
return -ENOSYS;
159164
}
160-
# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
165+
# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (-ENOSYS))
161166
# define xfs_rtunmount_inodes(m)
162167
#endif /* CONFIG_XFS_RT */
163168

0 commit comments

Comments
 (0)