Skip to content

Commit f48f0a8

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: move the tagged perag lookup helpers to xfs_icache.c
The tagged perag helpers are only used in xfs_icache.c in the kernel code and not at all in xfsprogs. Move them to xfs_icache.c in preparation for switching to an xarray, for which I have no plan to implement the tagged lookup functions for userspace. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 4ef7c6d commit f48f0a8

File tree

3 files changed

+58
-62
lines changed

3 files changed

+58
-62
lines changed

fs/xfs/libxfs/xfs_ag.c

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -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(
@@ -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)

fs/xfs/libxfs/xfs_ag.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,11 @@ void xfs_free_perag(struct xfs_mount *mp);
153153

154154
/* Passive AG references */
155155
struct xfs_perag *xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno);
156-
struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *mp, xfs_agnumber_t agno,
157-
unsigned int tag);
158156
struct xfs_perag *xfs_perag_hold(struct xfs_perag *pag);
159157
void xfs_perag_put(struct xfs_perag *pag);
160158

161159
/* Active AG references */
162160
struct xfs_perag *xfs_perag_grab(struct xfs_mount *, xfs_agnumber_t);
163-
struct xfs_perag *xfs_perag_grab_tag(struct xfs_mount *, xfs_agnumber_t,
164-
int tag);
165161
void xfs_perag_rele(struct xfs_perag *pag);
166162

167163
/*
@@ -263,13 +259,6 @@ xfs_perag_next(
263259
(agno) = 0; \
264260
for_each_perag_from((mp), (agno), (pag))
265261

266-
#define for_each_perag_tag(mp, agno, pag, tag) \
267-
for ((agno) = 0, (pag) = xfs_perag_grab_tag((mp), 0, (tag)); \
268-
(pag) != NULL; \
269-
(agno) = (pag)->pag_agno + 1, \
270-
xfs_perag_rele(pag), \
271-
(pag) = xfs_perag_grab_tag((mp), (agno), (tag)))
272-
273262
static inline struct xfs_perag *
274263
xfs_perag_next_wrap(
275264
struct xfs_perag *pag,

fs/xfs/xfs_icache.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,64 @@ xfs_perag_clear_inode_tag(
292292
trace_xfs_perag_clear_inode_tag(pag, _RET_IP_);
293293
}
294294

295+
/*
296+
* Search from @first to find the next perag with the given tag set.
297+
*/
298+
static struct xfs_perag *
299+
xfs_perag_get_tag(
300+
struct xfs_mount *mp,
301+
xfs_agnumber_t first,
302+
unsigned int tag)
303+
{
304+
struct xfs_perag *pag;
305+
int found;
306+
307+
rcu_read_lock();
308+
found = radix_tree_gang_lookup_tag(&mp->m_perag_tree,
309+
(void **)&pag, first, 1, tag);
310+
if (found <= 0) {
311+
rcu_read_unlock();
312+
return NULL;
313+
}
314+
trace_xfs_perag_get_tag(pag, _RET_IP_);
315+
atomic_inc(&pag->pag_ref);
316+
rcu_read_unlock();
317+
return pag;
318+
}
319+
320+
/*
321+
* Search from @first to find the next perag with the given tag set.
322+
*/
323+
static struct xfs_perag *
324+
xfs_perag_grab_tag(
325+
struct xfs_mount *mp,
326+
xfs_agnumber_t first,
327+
int tag)
328+
{
329+
struct xfs_perag *pag;
330+
int found;
331+
332+
rcu_read_lock();
333+
found = radix_tree_gang_lookup_tag(&mp->m_perag_tree,
334+
(void **)&pag, first, 1, tag);
335+
if (found <= 0) {
336+
rcu_read_unlock();
337+
return NULL;
338+
}
339+
trace_xfs_perag_grab_tag(pag, _RET_IP_);
340+
if (!atomic_inc_not_zero(&pag->pag_active_ref))
341+
pag = NULL;
342+
rcu_read_unlock();
343+
return pag;
344+
}
345+
346+
#define for_each_perag_tag(mp, agno, pag, tag) \
347+
for ((agno) = 0, (pag) = xfs_perag_grab_tag((mp), 0, (tag)); \
348+
(pag) != NULL; \
349+
(agno) = (pag)->pag_agno + 1, \
350+
xfs_perag_rele(pag), \
351+
(pag) = xfs_perag_grab_tag((mp), (agno), (tag)))
352+
295353
/*
296354
* When we recycle a reclaimable inode, we need to re-initialise the VFS inode
297355
* part of the structure. This is made more complex by the fact we store

0 commit comments

Comments
 (0)