Skip to content

Commit 8751b21

Browse files
committed
Merge tag 'xfs-6.12-merge-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs updates from Chandan Babu: "New code: - Introduce new ioctls to exchange contents of two files. The first ioctl does the preparation work to exchange the contents of two files while the second ioctl performs the actual exchange if the target file has not been changed since a given sampling point. Fixes: - Fix bugs associated with calculating the maximum range of realtime extents to scan for free space. - Copy keys instead of records when resizing the incore BMBT root block. - Do not report FITRIMming more bytes than possibly exist in the filesystem. - Modify xfs_fs.h to prevent C++ compilation errors. - Do not over eagerly free post-EOF speculative preallocation. - Ensure st_blocks never goes to zero during COW writes Cleanups/refactors: - Use Xarray to hold per-AG data instead of a Radix tree. - Cleanups to: - realtime bitmap - inode allocator - quota - inode rooted btree code" * tag 'xfs-6.12-merge-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (61 commits) xfs: ensure st_blocks never goes to zero during COW writes xfs: use xas_for_each_marked in xfs_reclaim_inodes_count xfs: convert perag lookup to xarray xfs: simplify tagged perag iteration xfs: move the tagged perag lookup helpers to xfs_icache.c xfs: use kfree_rcu_mightsleep to free the perag structures xfs: use LIST_HEAD() to simplify code xfs: Remove duplicate xfs_trans_priv.h header xfs: remove unnecessary check xfs: Use xfs set and clear mp state helpers xfs: reclaim speculative preallocations for append only files xfs: simplify extent lookup in xfs_can_free_eofblocks xfs: check XFS_EOFBLOCKS_RELEASED earlier in xfs_release_eofblocks xfs: only free posteof blocks on first close xfs: don't free post-EOF blocks on read close xfs: skip all of xfs_file_release when shut down xfs: don't bother returning errors from xfs_file_release xfs: refactor f_op->release handling xfs: remove the i_mode check in xfs_release xfs: standardize the btree maxrecs function parameters ...
2 parents 4e0373f + 90fa22d commit 8751b21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1770
-1452
lines changed

fs/xfs/libxfs/xfs_ag.c

Lines changed: 9 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ xfs_perag_get(
4646
struct xfs_perag *pag;
4747

4848
rcu_read_lock();
49-
pag = radix_tree_lookup(&mp->m_perag_tree, agno);
49+
pag = xa_load(&mp->m_perags, agno);
5050
if (pag) {
5151
trace_xfs_perag_get(pag, _RET_IP_);
5252
ASSERT(atomic_read(&pag->pag_ref) >= 0);
@@ -56,31 +56,6 @@ xfs_perag_get(
5656
return pag;
5757
}
5858

59-
/*
60-
* search from @first to find the next perag with the given tag set.
61-
*/
62-
struct xfs_perag *
63-
xfs_perag_get_tag(
64-
struct xfs_mount *mp,
65-
xfs_agnumber_t first,
66-
unsigned int tag)
67-
{
68-
struct xfs_perag *pag;
69-
int found;
70-
71-
rcu_read_lock();
72-
found = radix_tree_gang_lookup_tag(&mp->m_perag_tree,
73-
(void **)&pag, first, 1, tag);
74-
if (found <= 0) {
75-
rcu_read_unlock();
76-
return NULL;
77-
}
78-
trace_xfs_perag_get_tag(pag, _RET_IP_);
79-
atomic_inc(&pag->pag_ref);
80-
rcu_read_unlock();
81-
return pag;
82-
}
83-
8459
/* Get a passive reference to the given perag. */
8560
struct xfs_perag *
8661
xfs_perag_hold(
@@ -117,7 +92,7 @@ xfs_perag_grab(
11792
struct xfs_perag *pag;
11893

11994
rcu_read_lock();
120-
pag = radix_tree_lookup(&mp->m_perag_tree, agno);
95+
pag = xa_load(&mp->m_perags, agno);
12196
if (pag) {
12297
trace_xfs_perag_grab(pag, _RET_IP_);
12398
if (!atomic_inc_not_zero(&pag->pag_active_ref))
@@ -127,32 +102,6 @@ xfs_perag_grab(
127102
return pag;
128103
}
129104

130-
/*
131-
* search from @first to find the next perag with the given tag set.
132-
*/
133-
struct xfs_perag *
134-
xfs_perag_grab_tag(
135-
struct xfs_mount *mp,
136-
xfs_agnumber_t first,
137-
int tag)
138-
{
139-
struct xfs_perag *pag;
140-
int found;
141-
142-
rcu_read_lock();
143-
found = radix_tree_gang_lookup_tag(&mp->m_perag_tree,
144-
(void **)&pag, first, 1, tag);
145-
if (found <= 0) {
146-
rcu_read_unlock();
147-
return NULL;
148-
}
149-
trace_xfs_perag_grab_tag(pag, _RET_IP_);
150-
if (!atomic_inc_not_zero(&pag->pag_active_ref))
151-
pag = NULL;
152-
rcu_read_unlock();
153-
return pag;
154-
}
155-
156105
void
157106
xfs_perag_rele(
158107
struct xfs_perag *pag)
@@ -235,16 +184,6 @@ xfs_initialize_perag_data(
235184
return error;
236185
}
237186

238-
STATIC void
239-
__xfs_free_perag(
240-
struct rcu_head *head)
241-
{
242-
struct xfs_perag *pag = container_of(head, struct xfs_perag, rcu_head);
243-
244-
ASSERT(!delayed_work_pending(&pag->pag_blockgc_work));
245-
kfree(pag);
246-
}
247-
248187
/*
249188
* Free up the per-ag resources associated with the mount structure.
250189
*/
@@ -256,9 +195,7 @@ xfs_free_perag(
256195
xfs_agnumber_t agno;
257196

258197
for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
259-
spin_lock(&mp->m_perag_lock);
260-
pag = radix_tree_delete(&mp->m_perag_tree, agno);
261-
spin_unlock(&mp->m_perag_lock);
198+
pag = xa_erase(&mp->m_perags, agno);
262199
ASSERT(pag);
263200
XFS_IS_CORRUPT(pag->pag_mount, atomic_read(&pag->pag_ref) != 0);
264201
xfs_defer_drain_free(&pag->pag_intents_drain);
@@ -270,7 +207,7 @@ xfs_free_perag(
270207
xfs_perag_rele(pag);
271208
XFS_IS_CORRUPT(pag->pag_mount,
272209
atomic_read(&pag->pag_active_ref) != 0);
273-
call_rcu(&pag->rcu_head, __xfs_free_perag);
210+
kfree_rcu_mightsleep(pag);
274211
}
275212
}
276213

@@ -347,9 +284,7 @@ xfs_free_unused_perag_range(
347284
xfs_agnumber_t index;
348285

349286
for (index = agstart; index < agend; index++) {
350-
spin_lock(&mp->m_perag_lock);
351-
pag = radix_tree_delete(&mp->m_perag_tree, index);
352-
spin_unlock(&mp->m_perag_lock);
287+
pag = xa_erase(&mp->m_perags, index);
353288
if (!pag)
354289
break;
355290
xfs_buf_cache_destroy(&pag->pag_bcache);
@@ -390,20 +325,11 @@ xfs_initialize_perag(
390325
pag->pag_agno = index;
391326
pag->pag_mount = mp;
392327

393-
error = radix_tree_preload(GFP_KERNEL | __GFP_RETRY_MAYFAIL);
394-
if (error)
395-
goto out_free_pag;
396-
397-
spin_lock(&mp->m_perag_lock);
398-
if (radix_tree_insert(&mp->m_perag_tree, index, pag)) {
399-
WARN_ON_ONCE(1);
400-
spin_unlock(&mp->m_perag_lock);
401-
radix_tree_preload_end();
402-
error = -EEXIST;
328+
error = xa_insert(&mp->m_perags, index, pag, GFP_KERNEL);
329+
if (error) {
330+
WARN_ON_ONCE(error == -EBUSY);
403331
goto out_free_pag;
404332
}
405-
spin_unlock(&mp->m_perag_lock);
406-
radix_tree_preload_end();
407333

408334
#ifdef __KERNEL__
409335
/* Place kernel structure only init below this point. */
@@ -451,9 +377,7 @@ xfs_initialize_perag(
451377

452378
out_remove_pag:
453379
xfs_defer_drain_free(&pag->pag_intents_drain);
454-
spin_lock(&mp->m_perag_lock);
455-
radix_tree_delete(&mp->m_perag_tree, index);
456-
spin_unlock(&mp->m_perag_lock);
380+
pag = xa_erase(&mp->m_perags, index);
457381
out_free_pag:
458382
kfree(pag);
459383
out_unwind_new_pags:

fs/xfs/libxfs/xfs_ag.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ struct xfs_perag {
6363
/* Blocks reserved for the reverse mapping btree. */
6464
struct xfs_ag_resv pag_rmapbt_resv;
6565

66-
/* for rcu-safe freeing */
67-
struct rcu_head rcu_head;
68-
6966
/* Precalculated geometry info */
7067
xfs_agblock_t block_count;
7168
xfs_agblock_t min_block;
@@ -156,15 +153,11 @@ void xfs_free_perag(struct xfs_mount *mp);
156153

157154
/* Passive AG references */
158155
struct xfs_perag *xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno);
159-
struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *mp, xfs_agnumber_t agno,
160-
unsigned int tag);
161156
struct xfs_perag *xfs_perag_hold(struct xfs_perag *pag);
162157
void xfs_perag_put(struct xfs_perag *pag);
163158

164159
/* Active AG references */
165160
struct xfs_perag *xfs_perag_grab(struct xfs_mount *, xfs_agnumber_t);
166-
struct xfs_perag *xfs_perag_grab_tag(struct xfs_mount *, xfs_agnumber_t,
167-
int tag);
168161
void xfs_perag_rele(struct xfs_perag *pag);
169162

170163
/*
@@ -266,13 +259,6 @@ xfs_perag_next(
266259
(agno) = 0; \
267260
for_each_perag_from((mp), (agno), (pag))
268261

269-
#define for_each_perag_tag(mp, agno, pag, tag) \
270-
for ((agno) = 0, (pag) = xfs_perag_grab_tag((mp), 0, (tag)); \
271-
(pag) != NULL; \
272-
(agno) = (pag)->pag_agno + 1, \
273-
xfs_perag_rele(pag), \
274-
(pag) = xfs_perag_grab_tag((mp), (agno), (tag)))
275-
276262
static inline struct xfs_perag *
277263
xfs_perag_next_wrap(
278264
struct xfs_perag *pag,

fs/xfs/libxfs/xfs_alloc_btree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,11 @@ xfs_allocbt_block_maxrecs(
569569
/*
570570
* Calculate number of records in an alloc btree block.
571571
*/
572-
int
572+
unsigned int
573573
xfs_allocbt_maxrecs(
574574
struct xfs_mount *mp,
575-
int blocklen,
576-
int leaf)
575+
unsigned int blocklen,
576+
bool leaf)
577577
{
578578
blocklen -= XFS_ALLOC_BLOCK_LEN(mp);
579579
return xfs_allocbt_block_maxrecs(blocklen, leaf);

fs/xfs/libxfs/xfs_alloc_btree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ struct xfs_btree_cur *xfs_bnobt_init_cursor(struct xfs_mount *mp,
5353
struct xfs_btree_cur *xfs_cntbt_init_cursor(struct xfs_mount *mp,
5454
struct xfs_trans *tp, struct xfs_buf *bp,
5555
struct xfs_perag *pag);
56-
extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);
56+
unsigned int xfs_allocbt_maxrecs(struct xfs_mount *mp, unsigned int blocklen,
57+
bool leaf);
5758
extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,
5859
unsigned long long len);
5960

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ xfs_attr_shortform_bytesfit(
686686
*/
687687
if (!dp->i_forkoff && dp->i_df.if_bytes >
688688
xfs_default_attroffset(dp))
689-
dsize = XFS_BMDR_SPACE_CALC(MINDBTPTRS);
689+
dsize = xfs_bmdr_space_calc(MINDBTPTRS);
690690
break;
691691
case XFS_DINODE_FMT_BTREE:
692692
/*
@@ -700,19 +700,19 @@ xfs_attr_shortform_bytesfit(
700700
return 0;
701701
return dp->i_forkoff;
702702
}
703-
dsize = XFS_BMAP_BROOT_SPACE(mp, dp->i_df.if_broot);
703+
dsize = xfs_bmap_bmdr_space(dp->i_df.if_broot);
704704
break;
705705
}
706706

707707
/*
708708
* A data fork btree root must have space for at least
709709
* MINDBTPTRS key/ptr pairs if the data fork is small or empty.
710710
*/
711-
minforkoff = max_t(int64_t, dsize, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
711+
minforkoff = max_t(int64_t, dsize, xfs_bmdr_space_calc(MINDBTPTRS));
712712
minforkoff = roundup(minforkoff, 8) >> 3;
713713

714714
/* attr fork btree root can have at least this many key/ptr pairs */
715-
maxforkoff = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS);
715+
maxforkoff = XFS_LITINO(mp) - xfs_bmdr_space_calc(MINABTPTRS);
716716
maxforkoff = maxforkoff >> 3; /* rounded down */
717717

718718
if (offset >= maxforkoff)

0 commit comments

Comments
 (0)