Skip to content

Commit 390600f

Browse files
committed
xfs: remove flags argument from xfs_inode_ag_walk
The incore inode walk code passes a flags argument and a pointer from the xfs_inode_ag_iterator caller all the way to the iteration function. We can reduce the function complexity by passing flags through the private pointer. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]>
1 parent 9be0590 commit 390600f

File tree

3 files changed

+27
-35
lines changed

3 files changed

+27
-35
lines changed

fs/xfs/xfs_icache.c

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,7 @@ STATIC int
810810
xfs_inode_ag_walk(
811811
struct xfs_mount *mp,
812812
struct xfs_perag *pag,
813-
int (*execute)(struct xfs_inode *ip, int flags,
814-
void *args),
815-
int flags,
813+
int (*execute)(struct xfs_inode *ip, void *args),
816814
void *args,
817815
int tag,
818816
int iter_flags)
@@ -888,7 +886,7 @@ xfs_inode_ag_walk(
888886
if ((iter_flags & XFS_AGITER_INEW_WAIT) &&
889887
xfs_iflags_test(batch[i], XFS_INEW))
890888
xfs_inew_wait(batch[i]);
891-
error = execute(batch[i], flags, args);
889+
error = execute(batch[i], args);
892890
xfs_irele(batch[i]);
893891
if (error == -EAGAIN) {
894892
skipped++;
@@ -992,9 +990,7 @@ int
992990
xfs_inode_ag_iterator(
993991
struct xfs_mount *mp,
994992
int iter_flags,
995-
int (*execute)(struct xfs_inode *ip, int flags,
996-
void *args),
997-
int flags,
993+
int (*execute)(struct xfs_inode *ip, void *args),
998994
void *args,
999995
int tag)
1000996
{
@@ -1006,7 +1002,7 @@ xfs_inode_ag_iterator(
10061002
ag = 0;
10071003
while ((pag = xfs_inode_walk_get_perag(mp, ag, tag))) {
10081004
ag = pag->pag_agno + 1;
1009-
error = xfs_inode_ag_walk(mp, pag, execute, flags, args, tag,
1005+
error = xfs_inode_ag_walk(mp, pag, execute, args, tag,
10101006
iter_flags);
10111007
xfs_perag_put(pag);
10121008
if (error) {
@@ -1463,12 +1459,14 @@ xfs_inode_match_id_union(
14631459
STATIC int
14641460
xfs_inode_free_eofblocks(
14651461
struct xfs_inode *ip,
1466-
int flags,
14671462
void *args)
14681463
{
1469-
int ret = 0;
1470-
struct xfs_eofblocks *eofb = args;
1471-
int match;
1464+
struct xfs_eofblocks *eofb = args;
1465+
bool wait;
1466+
int match;
1467+
int ret;
1468+
1469+
wait = eofb && (eofb->eof_flags & XFS_EOF_FLAGS_SYNC);
14721470

14731471
if (!xfs_can_free_eofblocks(ip, false)) {
14741472
/* inode could be preallocated or append-only */
@@ -1481,8 +1479,7 @@ xfs_inode_free_eofblocks(
14811479
* If the mapping is dirty the operation can block and wait for some
14821480
* time. Unless we are waiting, skip it.
14831481
*/
1484-
if (!(flags & SYNC_WAIT) &&
1485-
mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY))
1482+
if (!wait && mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY))
14861483
return 0;
14871484

14881485
if (eofb) {
@@ -1504,10 +1501,11 @@ xfs_inode_free_eofblocks(
15041501
* scanner moving and revisit the inode in a subsequent pass.
15051502
*/
15061503
if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) {
1507-
if (flags & SYNC_WAIT)
1508-
ret = -EAGAIN;
1509-
return ret;
1504+
if (wait)
1505+
return -EAGAIN;
1506+
return 0;
15101507
}
1508+
15111509
ret = xfs_free_eofblocks(ip);
15121510
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
15131511

@@ -1518,16 +1516,10 @@ static int
15181516
__xfs_icache_free_eofblocks(
15191517
struct xfs_mount *mp,
15201518
struct xfs_eofblocks *eofb,
1521-
int (*execute)(struct xfs_inode *ip, int flags,
1522-
void *args),
1519+
int (*execute)(struct xfs_inode *ip, void *args),
15231520
int tag)
15241521
{
1525-
int flags = SYNC_TRYLOCK;
1526-
1527-
if (eofb && (eofb->eof_flags & XFS_EOF_FLAGS_SYNC))
1528-
flags = SYNC_WAIT;
1529-
1530-
return xfs_inode_ag_iterator(mp, 0, execute, flags, eofb, tag);
1522+
return xfs_inode_ag_iterator(mp, 0, execute, eofb, tag);
15311523
}
15321524

15331525
int
@@ -1752,7 +1744,6 @@ xfs_prep_free_cowblocks(
17521744
STATIC int
17531745
xfs_inode_free_cowblocks(
17541746
struct xfs_inode *ip,
1755-
int flags,
17561747
void *args)
17571748
{
17581749
struct xfs_eofblocks *eofb = args;

fs/xfs/xfs_icache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ void xfs_cowblocks_worker(struct work_struct *);
7272
void xfs_queue_cowblocks(struct xfs_mount *);
7373

7474
int xfs_inode_ag_iterator(struct xfs_mount *mp, int iter_flags,
75-
int (*execute)(struct xfs_inode *ip, int flags, void *args),
76-
int flags, void *args, int tag);
75+
int (*execute)(struct xfs_inode *ip, void *args),
76+
void *args, int tag);
7777

7878
int xfs_icache_inode_is_allocated(struct xfs_mount *mp, struct xfs_trans *tp,
7979
xfs_ino_t ino, bool *inuse);

fs/xfs/xfs_qm_syscalls.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,10 @@ xfs_qm_scall_getquota_next(
737737
STATIC int
738738
xfs_dqrele_inode(
739739
struct xfs_inode *ip,
740-
int flags,
741740
void *args)
742741
{
742+
uint *flags = args;
743+
743744
/* skip quota inodes */
744745
if (ip == ip->i_mount->m_quotainfo->qi_uquotaip ||
745746
ip == ip->i_mount->m_quotainfo->qi_gquotaip ||
@@ -751,15 +752,15 @@ xfs_dqrele_inode(
751752
}
752753

753754
xfs_ilock(ip, XFS_ILOCK_EXCL);
754-
if ((flags & XFS_UQUOTA_ACCT) && ip->i_udquot) {
755+
if ((*flags & XFS_UQUOTA_ACCT) && ip->i_udquot) {
755756
xfs_qm_dqrele(ip->i_udquot);
756757
ip->i_udquot = NULL;
757758
}
758-
if ((flags & XFS_GQUOTA_ACCT) && ip->i_gdquot) {
759+
if ((*flags & XFS_GQUOTA_ACCT) && ip->i_gdquot) {
759760
xfs_qm_dqrele(ip->i_gdquot);
760761
ip->i_gdquot = NULL;
761762
}
762-
if ((flags & XFS_PQUOTA_ACCT) && ip->i_pdquot) {
763+
if ((*flags & XFS_PQUOTA_ACCT) && ip->i_pdquot) {
763764
xfs_qm_dqrele(ip->i_pdquot);
764765
ip->i_pdquot = NULL;
765766
}
@@ -776,10 +777,10 @@ xfs_dqrele_inode(
776777
*/
777778
void
778779
xfs_qm_dqrele_all_inodes(
779-
struct xfs_mount *mp,
780-
uint flags)
780+
struct xfs_mount *mp,
781+
uint flags)
781782
{
782783
ASSERT(mp->m_quotainfo);
783784
xfs_inode_ag_iterator(mp, XFS_AGITER_INEW_WAIT, xfs_dqrele_inode,
784-
flags, NULL, XFS_ICI_NO_TAG);
785+
&flags, XFS_ICI_NO_TAG);
785786
}

0 commit comments

Comments
 (0)