Skip to content

Commit 68db60b

Browse files
author
Darrick J. Wong
committed
xfs: create a helper to compute leftovers of realtime extents
Create a helper to compute the misalignment between a file extent (xfs_extlen_t) and a realtime extent. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent fa5a387 commit 68db60b

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,7 @@ xfs_bmap_extsize_align(
29892989
* If realtime, and the result isn't a multiple of the realtime
29902990
* extent size we need to remove blocks until it is.
29912991
*/
2992-
if (rt && (temp = (align_alen % mp->m_sb.sb_rextsize))) {
2992+
if (rt && (temp = xfs_extlen_to_rtxmod(mp, align_alen))) {
29932993
/*
29942994
* We're not covering the original request, or
29952995
* we won't be able to once we fix the length.
@@ -3016,7 +3016,7 @@ xfs_bmap_extsize_align(
30163016
else {
30173017
align_alen -= orig_off - align_off;
30183018
align_off = orig_off;
3019-
align_alen -= align_alen % mp->m_sb.sb_rextsize;
3019+
align_alen -= xfs_extlen_to_rtxmod(mp, align_alen);
30203020
}
30213021
/*
30223022
* Result doesn't cover the request, fail it.

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ xfs_rtxlen_to_extlen(
2222
return rtxlen * mp->m_sb.sb_rextsize;
2323
}
2424

25+
/* Compute the misalignment between an extent length and a realtime extent .*/
26+
static inline unsigned int
27+
xfs_extlen_to_rtxmod(
28+
struct xfs_mount *mp,
29+
xfs_extlen_t len)
30+
{
31+
return len % mp->m_sb.sb_rextsize;
32+
}
33+
2534
/*
2635
* Functions for walking free space rtextents in the realtime bitmap.
2736
*/

fs/xfs/scrub/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "xfs_reflink.h"
2121
#include "xfs_rmap.h"
2222
#include "xfs_bmap_util.h"
23+
#include "xfs_rtbitmap.h"
2324
#include "scrub/scrub.h"
2425
#include "scrub/common.h"
2526
#include "scrub/btree.h"
@@ -225,7 +226,7 @@ xchk_inode_extsize(
225226
*/
226227
if ((flags & XFS_DIFLAG_RTINHERIT) &&
227228
(flags & XFS_DIFLAG_EXTSZINHERIT) &&
228-
value % sc->mp->m_sb.sb_rextsize > 0)
229+
xfs_extlen_to_rtxmod(sc->mp, value) > 0)
229230
xchk_ino_set_warning(sc, ino);
230231
}
231232

fs/xfs/xfs_bmap_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ xfs_bmap_rtalloc(
9797
if (error)
9898
return error;
9999
ASSERT(ap->length);
100-
ASSERT(ap->length % mp->m_sb.sb_rextsize == 0);
100+
ASSERT(xfs_extlen_to_rtxmod(mp, ap->length) == 0);
101101

102102
/*
103103
* If we shifted the file offset downward to satisfy an extent size

fs/xfs/xfs_inode_item.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "xfs_log.h"
2020
#include "xfs_log_priv.h"
2121
#include "xfs_error.h"
22+
#include "xfs_rtbitmap.h"
2223

2324
#include <linux/iversion.h>
2425

@@ -107,7 +108,7 @@ xfs_inode_item_precommit(
107108
*/
108109
if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
109110
(ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) &&
110-
(ip->i_extsize % ip->i_mount->m_sb.sb_rextsize) > 0) {
111+
xfs_extlen_to_rtxmod(ip->i_mount, ip->i_extsize) > 0) {
111112
ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE |
112113
XFS_DIFLAG_EXTSZINHERIT);
113114
ip->i_extsize = 0;

fs/xfs/xfs_ioctl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "xfs_reflink.h"
3939
#include "xfs_ioctl.h"
4040
#include "xfs_xattr.h"
41+
#include "xfs_rtbitmap.h"
4142

4243
#include <linux/mount.h>
4344
#include <linux/namei.h>
@@ -1004,7 +1005,7 @@ xfs_fill_fsxattr(
10041005
* later.
10051006
*/
10061007
if ((ip->i_diflags & XFS_DIFLAG_RTINHERIT) &&
1007-
ip->i_extsize % mp->m_sb.sb_rextsize > 0) {
1008+
xfs_extlen_to_rtxmod(mp, ip->i_extsize) > 0) {
10081009
fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE |
10091010
FS_XFLAG_EXTSZINHERIT);
10101011
fa->fsx_extsize = 0;
@@ -1130,7 +1131,7 @@ xfs_ioctl_setattr_xflags(
11301131
/* If realtime flag is set then must have realtime device */
11311132
if (fa->fsx_xflags & FS_XFLAG_REALTIME) {
11321133
if (mp->m_sb.sb_rblocks == 0 || mp->m_sb.sb_rextsize == 0 ||
1133-
(ip->i_extsize % mp->m_sb.sb_rextsize))
1134+
xfs_extlen_to_rtxmod(mp, ip->i_extsize))
11341135
return -EINVAL;
11351136
}
11361137

0 commit comments

Comments
 (0)