Skip to content

Commit 34f7632

Browse files
committed
Merge tag 'xfs-6.7-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs updates from Chandan Babu: - Realtime device subsystem: - Cleanup usage of xfs_rtblock_t and xfs_fsblock_t data types - Replace open coded conversions between rt blocks and rt extents with calls to static inline helpers - Replace open coded realtime geometry compuation and macros with helper functions - CPU usage optimizations for realtime allocator - Misc bug fixes associated with Realtime device - Allow read operations to execute while an FICLONE ioctl is being serviced - Misc bug fixes: - Alert user when xfs_droplink() encounters an inode with a link count of zero - Handle the case where the allocator could return zero extents when servicing an fallocate request * tag 'xfs-6.7-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (40 commits) xfs: allow read IO and FICLONE to run concurrently xfs: handle nimaps=0 from xfs_bmapi_write in xfs_alloc_file_space xfs: introduce protection for drop nlink xfs: don't look for end of extent further than necessary in xfs_rtallocate_extent_near() xfs: don't try redundant allocations in xfs_rtallocate_extent_near() xfs: limit maxlen based on available space in xfs_rtallocate_extent_near() xfs: return maximum free size from xfs_rtany_summary() xfs: invert the realtime summary cache xfs: simplify rt bitmap/summary block accessor functions xfs: simplify xfs_rtbuf_get calling conventions xfs: cache last bitmap block in realtime allocator xfs: use accessor functions for summary info words xfs: consolidate realtime allocation arguments xfs: create helpers for rtsummary block/wordcount computations xfs: use accessor functions for bitmap words xfs: create helpers for rtbitmap block/wordcount computations xfs: create a helper to handle logging parts of rt bitmap/summary blocks xfs: convert rt summary macros to helpers xfs: convert open-coded xfs_rtword_t pointer accesses to helper xfs: remove XFS_BLOCKWSIZE and XFS_BLOCKWMASK macros ...
2 parents 6d795e2 + 14a5379 commit 34f7632

31 files changed

+1433
-950
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "xfs_bmap.h"
2222
#include "xfs_bmap_util.h"
2323
#include "xfs_bmap_btree.h"
24-
#include "xfs_rtalloc.h"
24+
#include "xfs_rtbitmap.h"
2525
#include "xfs_errortag.h"
2626
#include "xfs_error.h"
2727
#include "xfs_quota.h"
@@ -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.
@@ -4826,12 +4826,8 @@ xfs_bmap_del_extent_delay(
48264826
ASSERT(got->br_startoff <= del->br_startoff);
48274827
ASSERT(got_endoff >= del_endoff);
48284828

4829-
if (isrt) {
4830-
uint64_t rtexts = XFS_FSB_TO_B(mp, del->br_blockcount);
4831-
4832-
do_div(rtexts, mp->m_sb.sb_rextsize);
4833-
xfs_mod_frextents(mp, rtexts);
4834-
}
4829+
if (isrt)
4830+
xfs_mod_frextents(mp, xfs_rtb_to_rtx(mp, del->br_blockcount));
48354831

48364832
/*
48374833
* Update the inode delalloc counter now and wait to update the
@@ -5057,33 +5053,20 @@ xfs_bmap_del_extent_real(
50575053

50585054
flags = XFS_ILOG_CORE;
50595055
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-
50675056
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);
5057+
error = xfs_rtfree_blocks(tp, del->br_startblock,
5058+
del->br_blockcount);
50755059
if (error)
50765060
goto done;
50775061
}
50785062

50795063
do_fx = 0;
5080-
nblks = len * mp->m_sb.sb_rextsize;
50815064
qfield = XFS_TRANS_DQ_RTBCOUNT;
50825065
} else {
50835066
do_fx = 1;
5084-
nblks = del->br_blockcount;
50855067
qfield = XFS_TRANS_DQ_BCOUNT;
50865068
}
5069+
nblks = del->br_blockcount;
50875070

50885071
del_endblock = del->br_startblock + del->br_blockcount;
50895072
if (cur) {
@@ -5289,7 +5272,6 @@ __xfs_bunmapi(
52895272
int tmp_logflags; /* partial logging flags */
52905273
int wasdel; /* was a delayed alloc extent */
52915274
int whichfork; /* data or attribute fork */
5292-
xfs_fsblock_t sum;
52935275
xfs_filblks_t len = *rlen; /* length to unmap in file */
52945276
xfs_fileoff_t end;
52955277
struct xfs_iext_cursor icur;
@@ -5384,8 +5366,8 @@ __xfs_bunmapi(
53845366
if (!isrt)
53855367
goto delete;
53865368

5387-
sum = del.br_startblock + del.br_blockcount;
5388-
div_u64_rem(sum, mp->m_sb.sb_rextsize, &mod);
5369+
mod = xfs_rtb_to_rtxoff(mp,
5370+
del.br_startblock + del.br_blockcount);
53895371
if (mod) {
53905372
/*
53915373
* Realtime extent not lined up at the end.
@@ -5432,7 +5414,8 @@ __xfs_bunmapi(
54325414
goto error0;
54335415
goto nodelete;
54345416
}
5435-
div_u64_rem(del.br_startblock, mp->m_sb.sb_rextsize, &mod);
5417+
5418+
mod = xfs_rtb_to_rtxoff(mp, del.br_startblock);
54365419
if (mod) {
54375420
xfs_extlen_t off = mp->m_sb.sb_rextsize - mod;
54385421

@@ -6209,8 +6192,8 @@ xfs_bmap_validate_extent(
62096192
return __this_address;
62106193

62116194
if (XFS_IS_REALTIME_INODE(ip) && whichfork == XFS_DATA_FORK) {
6212-
if (!xfs_verify_rtext(mp, irec->br_startblock,
6213-
irec->br_blockcount))
6195+
if (!xfs_verify_rtbext(mp, irec->br_startblock,
6196+
irec->br_blockcount))
62146197
return __this_address;
62156198
} else {
62166199
if (!xfs_verify_fsbext(mp, irec->br_startblock,

fs/xfs/libxfs/xfs_format.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ typedef struct xfs_sb {
9898
uint32_t sb_blocksize; /* logical block size, bytes */
9999
xfs_rfsblock_t sb_dblocks; /* number of data blocks */
100100
xfs_rfsblock_t sb_rblocks; /* number of realtime blocks */
101-
xfs_rtblock_t sb_rextents; /* number of realtime extents */
101+
xfs_rtbxlen_t sb_rextents; /* number of realtime extents */
102102
uuid_t sb_uuid; /* user-visible file system unique id */
103103
xfs_fsblock_t sb_logstart; /* starting block of log if internal */
104104
xfs_ino_t sb_rootino; /* root inode number */
@@ -690,6 +690,22 @@ struct xfs_agfl {
690690
ASSERT(xfs_daddr_to_agno(mp, d) == \
691691
xfs_daddr_to_agno(mp, (d) + (len) - 1)))
692692

693+
/*
694+
* Realtime bitmap information is accessed by the word, which is currently
695+
* stored in host-endian format.
696+
*/
697+
union xfs_rtword_raw {
698+
__u32 old;
699+
};
700+
701+
/*
702+
* Realtime summary counts are accessed by the word, which is currently
703+
* stored in host-endian format.
704+
*/
705+
union xfs_suminfo_raw {
706+
__u32 old;
707+
};
708+
693709
/*
694710
* XFS Timestamps
695711
* ==============
@@ -1142,24 +1158,10 @@ static inline bool xfs_dinode_has_large_extent_counts(
11421158

11431159
#define XFS_BLOCKSIZE(mp) ((mp)->m_sb.sb_blocksize)
11441160
#define XFS_BLOCKMASK(mp) ((mp)->m_blockmask)
1145-
#define XFS_BLOCKWSIZE(mp) ((mp)->m_blockwsize)
1146-
#define XFS_BLOCKWMASK(mp) ((mp)->m_blockwmask)
11471161

11481162
/*
1149-
* RT Summary and bit manipulation macros.
1163+
* RT bit manipulation macros.
11501164
*/
1151-
#define XFS_SUMOFFS(mp,ls,bb) ((int)((ls) * (mp)->m_sb.sb_rbmblocks + (bb)))
1152-
#define XFS_SUMOFFSTOBLOCK(mp,s) \
1153-
(((s) * (uint)sizeof(xfs_suminfo_t)) >> (mp)->m_sb.sb_blocklog)
1154-
#define XFS_SUMPTR(mp,bp,so) \
1155-
((xfs_suminfo_t *)((bp)->b_addr + \
1156-
(((so) * (uint)sizeof(xfs_suminfo_t)) & XFS_BLOCKMASK(mp))))
1157-
1158-
#define XFS_BITTOBLOCK(mp,bi) ((bi) >> (mp)->m_blkbit_log)
1159-
#define XFS_BLOCKTOBIT(mp,bb) ((bb) << (mp)->m_blkbit_log)
1160-
#define XFS_BITTOWORD(mp,bi) \
1161-
((int)(((bi) >> XFS_NBWORDLOG) & XFS_BLOCKWMASK(mp)))
1162-
11631165
#define XFS_RTMIN(a,b) ((a) < (b) ? (a) : (b))
11641166
#define XFS_RTMAX(a,b) ((a) > (b) ? (a) : (b))
11651167

0 commit comments

Comments
 (0)