Commit 68b2c8bc authored by Darrick J. Wong's avatar Darrick J. Wong

Merge tag 'rename-eofblocks-5.14_2021-06-08' of...

Merge tag 'rename-eofblocks-5.14_2021-06-08' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-5.14-merge2

xfs: rename struct xfs_eofblocks

In the old days, struct xfs_eofblocks was an optional parameter to the
speculative post-EOF allocation garbage collector to narrow the scope of
a scan to files fitting specific criteria.  Nowadays it is used for all
other kinds of inode cache walks (reclaim, quotaoff, inactivation), so
the name is no longer fitting.  Change the flag namespace and rename the
structure to something more appropriate for what it does.

v2: separate the inode cache walk flag namespace from eofblocks

* tag 'rename-eofblocks-5.14_2021-06-08' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: rename struct xfs_eofblocks to xfs_icwalk
  xfs: change the prefix of XFS_EOF_FLAGS_* to XFS_ICWALK_FLAG_
parents 295abff2 b26b2bf1
...@@ -769,18 +769,18 @@ xfs_file_buffered_write( ...@@ -769,18 +769,18 @@ xfs_file_buffered_write(
*/ */
if (ret == -EDQUOT && !cleared_space) { if (ret == -EDQUOT && !cleared_space) {
xfs_iunlock(ip, iolock); xfs_iunlock(ip, iolock);
xfs_blockgc_free_quota(ip, XFS_EOF_FLAGS_SYNC); xfs_blockgc_free_quota(ip, XFS_ICWALK_FLAG_SYNC);
cleared_space = true; cleared_space = true;
goto write_retry; goto write_retry;
} else if (ret == -ENOSPC && !cleared_space) { } else if (ret == -ENOSPC && !cleared_space) {
struct xfs_eofblocks eofb = {0}; struct xfs_icwalk icw = {0};
cleared_space = true; cleared_space = true;
xfs_flush_inodes(ip->i_mount); xfs_flush_inodes(ip->i_mount);
xfs_iunlock(ip, iolock); xfs_iunlock(ip, iolock);
eofb.eof_flags = XFS_EOF_FLAGS_SYNC; icw.icw_flags = XFS_ICWALK_FLAG_SYNC;
xfs_blockgc_free_space(ip->i_mount, &eofb); xfs_blockgc_free_space(ip->i_mount, &icw);
goto write_retry; goto write_retry;
} }
......
...@@ -56,13 +56,13 @@ xfs_icwalk_tag(enum xfs_icwalk_goal goal) ...@@ -56,13 +56,13 @@ xfs_icwalk_tag(enum xfs_icwalk_goal goal)
} }
static int xfs_icwalk(struct xfs_mount *mp, static int xfs_icwalk(struct xfs_mount *mp,
enum xfs_icwalk_goal goal, struct xfs_eofblocks *eofb); enum xfs_icwalk_goal goal, struct xfs_icwalk *icw);
static int xfs_icwalk_ag(struct xfs_perag *pag, static int xfs_icwalk_ag(struct xfs_perag *pag,
enum xfs_icwalk_goal goal, struct xfs_eofblocks *eofb); enum xfs_icwalk_goal goal, struct xfs_icwalk *icw);
/* /*
* Private inode cache walk flags for struct xfs_eofblocks. Must not coincide * Private inode cache walk flags for struct xfs_icwalk. Must not
* with XFS_EOF_FLAGS_*. * coincide with XFS_ICWALK_FLAGS_VALID.
*/ */
#define XFS_ICWALK_FLAG_DROP_UDQUOT (1U << 31) #define XFS_ICWALK_FLAG_DROP_UDQUOT (1U << 31)
#define XFS_ICWALK_FLAG_DROP_GDQUOT (1U << 30) #define XFS_ICWALK_FLAG_DROP_GDQUOT (1U << 30)
...@@ -72,12 +72,14 @@ static int xfs_icwalk_ag(struct xfs_perag *pag, ...@@ -72,12 +72,14 @@ static int xfs_icwalk_ag(struct xfs_perag *pag,
#define XFS_ICWALK_FLAG_SCAN_LIMIT (1U << 28) #define XFS_ICWALK_FLAG_SCAN_LIMIT (1U << 28)
#define XFS_ICWALK_FLAG_RECLAIM_SICK (1U << 27) #define XFS_ICWALK_FLAG_RECLAIM_SICK (1U << 27)
#define XFS_ICWALK_FLAG_UNION (1U << 26) /* union filter algorithm */
#define XFS_ICWALK_PRIVATE_FLAGS (XFS_ICWALK_FLAG_DROP_UDQUOT | \ #define XFS_ICWALK_PRIVATE_FLAGS (XFS_ICWALK_FLAG_DROP_UDQUOT | \
XFS_ICWALK_FLAG_DROP_GDQUOT | \ XFS_ICWALK_FLAG_DROP_GDQUOT | \
XFS_ICWALK_FLAG_DROP_PDQUOT | \ XFS_ICWALK_FLAG_DROP_PDQUOT | \
XFS_ICWALK_FLAG_SCAN_LIMIT | \ XFS_ICWALK_FLAG_SCAN_LIMIT | \
XFS_ICWALK_FLAG_RECLAIM_SICK) XFS_ICWALK_FLAG_RECLAIM_SICK | \
XFS_ICWALK_FLAG_UNION)
/* /*
* Allocate and initialise an xfs_inode. * Allocate and initialise an xfs_inode.
...@@ -846,21 +848,21 @@ xfs_dqrele_igrab( ...@@ -846,21 +848,21 @@ xfs_dqrele_igrab(
static void static void
xfs_dqrele_inode( xfs_dqrele_inode(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
if (xfs_iflags_test(ip, XFS_INEW)) if (xfs_iflags_test(ip, XFS_INEW))
xfs_inew_wait(ip); xfs_inew_wait(ip);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
if (eofb->eof_flags & XFS_ICWALK_FLAG_DROP_UDQUOT) { if (icw->icw_flags & XFS_ICWALK_FLAG_DROP_UDQUOT) {
xfs_qm_dqrele(ip->i_udquot); xfs_qm_dqrele(ip->i_udquot);
ip->i_udquot = NULL; ip->i_udquot = NULL;
} }
if (eofb->eof_flags & XFS_ICWALK_FLAG_DROP_GDQUOT) { if (icw->icw_flags & XFS_ICWALK_FLAG_DROP_GDQUOT) {
xfs_qm_dqrele(ip->i_gdquot); xfs_qm_dqrele(ip->i_gdquot);
ip->i_gdquot = NULL; ip->i_gdquot = NULL;
} }
if (eofb->eof_flags & XFS_ICWALK_FLAG_DROP_PDQUOT) { if (icw->icw_flags & XFS_ICWALK_FLAG_DROP_PDQUOT) {
xfs_qm_dqrele(ip->i_pdquot); xfs_qm_dqrele(ip->i_pdquot);
ip->i_pdquot = NULL; ip->i_pdquot = NULL;
} }
...@@ -878,16 +880,16 @@ xfs_dqrele_all_inodes( ...@@ -878,16 +880,16 @@ xfs_dqrele_all_inodes(
struct xfs_mount *mp, struct xfs_mount *mp,
unsigned int qflags) unsigned int qflags)
{ {
struct xfs_eofblocks eofb = { .eof_flags = 0 }; struct xfs_icwalk icw = { .icw_flags = 0 };
if (qflags & XFS_UQUOTA_ACCT) if (qflags & XFS_UQUOTA_ACCT)
eofb.eof_flags |= XFS_ICWALK_FLAG_DROP_UDQUOT; icw.icw_flags |= XFS_ICWALK_FLAG_DROP_UDQUOT;
if (qflags & XFS_GQUOTA_ACCT) if (qflags & XFS_GQUOTA_ACCT)
eofb.eof_flags |= XFS_ICWALK_FLAG_DROP_GDQUOT; icw.icw_flags |= XFS_ICWALK_FLAG_DROP_GDQUOT;
if (qflags & XFS_PQUOTA_ACCT) if (qflags & XFS_PQUOTA_ACCT)
eofb.eof_flags |= XFS_ICWALK_FLAG_DROP_PDQUOT; icw.icw_flags |= XFS_ICWALK_FLAG_DROP_PDQUOT;
return xfs_icwalk(mp, XFS_ICWALK_DQRELE, &eofb); return xfs_icwalk(mp, XFS_ICWALK_DQRELE, &icw);
} }
#else #else
# define xfs_dqrele_igrab(ip) (false) # define xfs_dqrele_igrab(ip) (false)
...@@ -914,7 +916,7 @@ xfs_dqrele_all_inodes( ...@@ -914,7 +916,7 @@ xfs_dqrele_all_inodes(
static bool static bool
xfs_reclaim_igrab( xfs_reclaim_igrab(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
ASSERT(rcu_read_lock_held()); ASSERT(rcu_read_lock_held());
...@@ -928,7 +930,7 @@ xfs_reclaim_igrab( ...@@ -928,7 +930,7 @@ xfs_reclaim_igrab(
/* Don't reclaim a sick inode unless the caller asked for it. */ /* Don't reclaim a sick inode unless the caller asked for it. */
if (ip->i_sick && if (ip->i_sick &&
(!eofb || !(eofb->eof_flags & XFS_ICWALK_FLAG_RECLAIM_SICK))) { (!icw || !(icw->icw_flags & XFS_ICWALK_FLAG_RECLAIM_SICK))) {
spin_unlock(&ip->i_flags_lock); spin_unlock(&ip->i_flags_lock);
return false; return false;
} }
...@@ -1047,16 +1049,16 @@ void ...@@ -1047,16 +1049,16 @@ void
xfs_reclaim_inodes( xfs_reclaim_inodes(
struct xfs_mount *mp) struct xfs_mount *mp)
{ {
struct xfs_eofblocks eofb = { struct xfs_icwalk icw = {
.eof_flags = 0, .icw_flags = 0,
}; };
if (xfs_want_reclaim_sick(mp)) if (xfs_want_reclaim_sick(mp))
eofb.eof_flags |= XFS_ICWALK_FLAG_RECLAIM_SICK; icw.icw_flags |= XFS_ICWALK_FLAG_RECLAIM_SICK;
while (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_RECLAIM_TAG)) { while (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_RECLAIM_TAG)) {
xfs_ail_push_all_sync(mp->m_ail); xfs_ail_push_all_sync(mp->m_ail);
xfs_icwalk(mp, XFS_ICWALK_RECLAIM, &eofb); xfs_icwalk(mp, XFS_ICWALK_RECLAIM, &icw);
} }
} }
...@@ -1072,19 +1074,19 @@ xfs_reclaim_inodes_nr( ...@@ -1072,19 +1074,19 @@ xfs_reclaim_inodes_nr(
struct xfs_mount *mp, struct xfs_mount *mp,
int nr_to_scan) int nr_to_scan)
{ {
struct xfs_eofblocks eofb = { struct xfs_icwalk icw = {
.eof_flags = XFS_ICWALK_FLAG_SCAN_LIMIT, .icw_flags = XFS_ICWALK_FLAG_SCAN_LIMIT,
.icw_scan_limit = nr_to_scan, .icw_scan_limit = nr_to_scan,
}; };
if (xfs_want_reclaim_sick(mp)) if (xfs_want_reclaim_sick(mp))
eofb.eof_flags |= XFS_ICWALK_FLAG_RECLAIM_SICK; icw.icw_flags |= XFS_ICWALK_FLAG_RECLAIM_SICK;
/* kick background reclaimer and push the AIL */ /* kick background reclaimer and push the AIL */
xfs_reclaim_work_queue(mp); xfs_reclaim_work_queue(mp);
xfs_ail_push_all(mp->m_ail); xfs_ail_push_all(mp->m_ail);
xfs_icwalk(mp, XFS_ICWALK_RECLAIM, &eofb); xfs_icwalk(mp, XFS_ICWALK_RECLAIM, &icw);
return 0; return 0;
} }
...@@ -1109,20 +1111,20 @@ xfs_reclaim_inodes_count( ...@@ -1109,20 +1111,20 @@ xfs_reclaim_inodes_count(
} }
STATIC bool STATIC bool
xfs_inode_match_id( xfs_icwalk_match_id(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
if ((eofb->eof_flags & XFS_EOF_FLAGS_UID) && if ((icw->icw_flags & XFS_ICWALK_FLAG_UID) &&
!uid_eq(VFS_I(ip)->i_uid, eofb->eof_uid)) !uid_eq(VFS_I(ip)->i_uid, icw->icw_uid))
return false; return false;
if ((eofb->eof_flags & XFS_EOF_FLAGS_GID) && if ((icw->icw_flags & XFS_ICWALK_FLAG_GID) &&
!gid_eq(VFS_I(ip)->i_gid, eofb->eof_gid)) !gid_eq(VFS_I(ip)->i_gid, icw->icw_gid))
return false; return false;
if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) && if ((icw->icw_flags & XFS_ICWALK_FLAG_PRID) &&
ip->i_projid != eofb->eof_prid) ip->i_projid != icw->icw_prid)
return false; return false;
return true; return true;
...@@ -1133,20 +1135,20 @@ xfs_inode_match_id( ...@@ -1133,20 +1135,20 @@ xfs_inode_match_id(
* criteria match. This is for global/internal scans only. * criteria match. This is for global/internal scans only.
*/ */
STATIC bool STATIC bool
xfs_inode_match_id_union( xfs_icwalk_match_id_union(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
if ((eofb->eof_flags & XFS_EOF_FLAGS_UID) && if ((icw->icw_flags & XFS_ICWALK_FLAG_UID) &&
uid_eq(VFS_I(ip)->i_uid, eofb->eof_uid)) uid_eq(VFS_I(ip)->i_uid, icw->icw_uid))
return true; return true;
if ((eofb->eof_flags & XFS_EOF_FLAGS_GID) && if ((icw->icw_flags & XFS_ICWALK_FLAG_GID) &&
gid_eq(VFS_I(ip)->i_gid, eofb->eof_gid)) gid_eq(VFS_I(ip)->i_gid, icw->icw_gid))
return true; return true;
if ((eofb->eof_flags & XFS_EOF_FLAGS_PRID) && if ((icw->icw_flags & XFS_ICWALK_FLAG_PRID) &&
ip->i_projid == eofb->eof_prid) ip->i_projid == icw->icw_prid)
return true; return true;
return false; return false;
...@@ -1154,29 +1156,29 @@ xfs_inode_match_id_union( ...@@ -1154,29 +1156,29 @@ xfs_inode_match_id_union(
/* /*
* Is this inode @ip eligible for eof/cow block reclamation, given some * Is this inode @ip eligible for eof/cow block reclamation, given some
* filtering parameters @eofb? The inode is eligible if @eofb is null or * filtering parameters @icw? The inode is eligible if @icw is null or
* if the predicate functions match. * if the predicate functions match.
*/ */
static bool static bool
xfs_inode_matches_eofb( xfs_icwalk_match(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
bool match; bool match;
if (!eofb) if (!icw)
return true; return true;
if (eofb->eof_flags & XFS_EOF_FLAGS_UNION) if (icw->icw_flags & XFS_ICWALK_FLAG_UNION)
match = xfs_inode_match_id_union(ip, eofb); match = xfs_icwalk_match_id_union(ip, icw);
else else
match = xfs_inode_match_id(ip, eofb); match = xfs_icwalk_match_id(ip, icw);
if (!match) if (!match)
return false; return false;
/* skip the inode if the file size is too small */ /* skip the inode if the file size is too small */
if ((eofb->eof_flags & XFS_EOF_FLAGS_MINFILESIZE) && if ((icw->icw_flags & XFS_ICWALK_FLAG_MINFILESIZE) &&
XFS_ISIZE(ip) < eofb->eof_min_file_size) XFS_ISIZE(ip) < icw->icw_min_file_size)
return false; return false;
return true; return true;
...@@ -1202,12 +1204,12 @@ xfs_reclaim_worker( ...@@ -1202,12 +1204,12 @@ xfs_reclaim_worker(
STATIC int STATIC int
xfs_inode_free_eofblocks( xfs_inode_free_eofblocks(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb, struct xfs_icwalk *icw,
unsigned int *lockflags) unsigned int *lockflags)
{ {
bool wait; bool wait;
wait = eofb && (eofb->eof_flags & XFS_EOF_FLAGS_SYNC); wait = icw && (icw->icw_flags & XFS_ICWALK_FLAG_SYNC);
if (!xfs_iflags_test(ip, XFS_IEOFBLOCKS)) if (!xfs_iflags_test(ip, XFS_IEOFBLOCKS))
return 0; return 0;
...@@ -1219,7 +1221,7 @@ xfs_inode_free_eofblocks( ...@@ -1219,7 +1221,7 @@ xfs_inode_free_eofblocks(
if (!wait && mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY)) if (!wait && mapping_tagged(VFS_I(ip)->i_mapping, PAGECACHE_TAG_DIRTY))
return 0; return 0;
if (!xfs_inode_matches_eofb(ip, eofb)) if (!xfs_icwalk_match(ip, icw))
return 0; return 0;
/* /*
...@@ -1364,13 +1366,13 @@ xfs_prep_free_cowblocks( ...@@ -1364,13 +1366,13 @@ xfs_prep_free_cowblocks(
STATIC int STATIC int
xfs_inode_free_cowblocks( xfs_inode_free_cowblocks(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb, struct xfs_icwalk *icw,
unsigned int *lockflags) unsigned int *lockflags)
{ {
bool wait; bool wait;
int ret = 0; int ret = 0;
wait = eofb && (eofb->eof_flags & XFS_EOF_FLAGS_SYNC); wait = icw && (icw->icw_flags & XFS_ICWALK_FLAG_SYNC);
if (!xfs_iflags_test(ip, XFS_ICOWBLOCKS)) if (!xfs_iflags_test(ip, XFS_ICOWBLOCKS))
return 0; return 0;
...@@ -1378,7 +1380,7 @@ xfs_inode_free_cowblocks( ...@@ -1378,7 +1380,7 @@ xfs_inode_free_cowblocks(
if (!xfs_prep_free_cowblocks(ip)) if (!xfs_prep_free_cowblocks(ip))
return 0; return 0;
if (!xfs_inode_matches_eofb(ip, eofb)) if (!xfs_icwalk_match(ip, icw))
return 0; return 0;
/* /*
...@@ -1495,16 +1497,16 @@ xfs_blockgc_igrab( ...@@ -1495,16 +1497,16 @@ xfs_blockgc_igrab(
static int static int
xfs_blockgc_scan_inode( xfs_blockgc_scan_inode(
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
unsigned int lockflags = 0; unsigned int lockflags = 0;
int error; int error;
error = xfs_inode_free_eofblocks(ip, eofb, &lockflags); error = xfs_inode_free_eofblocks(ip, icw, &lockflags);
if (error) if (error)
goto unlock; goto unlock;
error = xfs_inode_free_cowblocks(ip, eofb, &lockflags); error = xfs_inode_free_cowblocks(ip, icw, &lockflags);
unlock: unlock:
if (lockflags) if (lockflags)
xfs_iunlock(ip, lockflags); xfs_iunlock(ip, lockflags);
...@@ -1538,11 +1540,11 @@ xfs_blockgc_worker( ...@@ -1538,11 +1540,11 @@ xfs_blockgc_worker(
int int
xfs_blockgc_free_space( xfs_blockgc_free_space(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
trace_xfs_blockgc_free_space(mp, eofb, _RET_IP_); trace_xfs_blockgc_free_space(mp, icw, _RET_IP_);
return xfs_icwalk(mp, XFS_ICWALK_BLOCKGC, eofb); return xfs_icwalk(mp, XFS_ICWALK_BLOCKGC, icw);
} }
/* /*
...@@ -1552,7 +1554,7 @@ xfs_blockgc_free_space( ...@@ -1552,7 +1554,7 @@ xfs_blockgc_free_space(
* scan. * scan.
* *
* Callers must not hold any inode's ILOCK. If requesting a synchronous scan * Callers must not hold any inode's ILOCK. If requesting a synchronous scan
* (XFS_EOF_FLAGS_SYNC), the caller also must not hold any inode's IOLOCK or * (XFS_ICWALK_FLAG_SYNC), the caller also must not hold any inode's IOLOCK or
* MMAPLOCK. * MMAPLOCK.
*/ */
int int
...@@ -1561,9 +1563,9 @@ xfs_blockgc_free_dquots( ...@@ -1561,9 +1563,9 @@ xfs_blockgc_free_dquots(
struct xfs_dquot *udqp, struct xfs_dquot *udqp,
struct xfs_dquot *gdqp, struct xfs_dquot *gdqp,
struct xfs_dquot *pdqp, struct xfs_dquot *pdqp,
unsigned int eof_flags) unsigned int iwalk_flags)
{ {
struct xfs_eofblocks eofb = {0}; struct xfs_icwalk icw = {0};
bool do_work = false; bool do_work = false;
if (!udqp && !gdqp && !pdqp) if (!udqp && !gdqp && !pdqp)
...@@ -1573,42 +1575,42 @@ xfs_blockgc_free_dquots( ...@@ -1573,42 +1575,42 @@ xfs_blockgc_free_dquots(
* Run a scan to free blocks using the union filter to cover all * Run a scan to free blocks using the union filter to cover all
* applicable quotas in a single scan. * applicable quotas in a single scan.
*/ */
eofb.eof_flags = XFS_EOF_FLAGS_UNION | eof_flags; icw.icw_flags = XFS_ICWALK_FLAG_UNION | iwalk_flags;
if (XFS_IS_UQUOTA_ENFORCED(mp) && udqp && xfs_dquot_lowsp(udqp)) { if (XFS_IS_UQUOTA_ENFORCED(mp) && udqp && xfs_dquot_lowsp(udqp)) {
eofb.eof_uid = make_kuid(mp->m_super->s_user_ns, udqp->q_id); icw.icw_uid = make_kuid(mp->m_super->s_user_ns, udqp->q_id);
eofb.eof_flags |= XFS_EOF_FLAGS_UID; icw.icw_flags |= XFS_ICWALK_FLAG_UID;
do_work = true; do_work = true;
} }
if (XFS_IS_UQUOTA_ENFORCED(mp) && gdqp && xfs_dquot_lowsp(gdqp)) { if (XFS_IS_UQUOTA_ENFORCED(mp) && gdqp && xfs_dquot_lowsp(gdqp)) {
eofb.eof_gid = make_kgid(mp->m_super->s_user_ns, gdqp->q_id); icw.icw_gid = make_kgid(mp->m_super->s_user_ns, gdqp->q_id);
eofb.eof_flags |= XFS_EOF_FLAGS_GID; icw.icw_flags |= XFS_ICWALK_FLAG_GID;
do_work = true; do_work = true;
} }
if (XFS_IS_PQUOTA_ENFORCED(mp) && pdqp && xfs_dquot_lowsp(pdqp)) { if (XFS_IS_PQUOTA_ENFORCED(mp) && pdqp && xfs_dquot_lowsp(pdqp)) {
eofb.eof_prid = pdqp->q_id; icw.icw_prid = pdqp->q_id;
eofb.eof_flags |= XFS_EOF_FLAGS_PRID; icw.icw_flags |= XFS_ICWALK_FLAG_PRID;
do_work = true; do_work = true;
} }
if (!do_work) if (!do_work)
return 0; return 0;
return xfs_blockgc_free_space(mp, &eofb); return xfs_blockgc_free_space(mp, &icw);
} }
/* Run cow/eofblocks scans on the quotas attached to the inode. */ /* Run cow/eofblocks scans on the quotas attached to the inode. */
int int
xfs_blockgc_free_quota( xfs_blockgc_free_quota(
struct xfs_inode *ip, struct xfs_inode *ip,
unsigned int eof_flags) unsigned int iwalk_flags)
{ {
return xfs_blockgc_free_dquots(ip->i_mount, return xfs_blockgc_free_dquots(ip->i_mount,
xfs_inode_dquot(ip, XFS_DQTYPE_USER), xfs_inode_dquot(ip, XFS_DQTYPE_USER),
xfs_inode_dquot(ip, XFS_DQTYPE_GROUP), xfs_inode_dquot(ip, XFS_DQTYPE_GROUP),
xfs_inode_dquot(ip, XFS_DQTYPE_PROJ), eof_flags); xfs_inode_dquot(ip, XFS_DQTYPE_PROJ), iwalk_flags);
} }
/* XFS Inode Cache Walking Code */ /* XFS Inode Cache Walking Code */
...@@ -1630,7 +1632,7 @@ static inline bool ...@@ -1630,7 +1632,7 @@ static inline bool
xfs_icwalk_igrab( xfs_icwalk_igrab(
enum xfs_icwalk_goal goal, enum xfs_icwalk_goal goal,
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
switch (goal) { switch (goal) {
case XFS_ICWALK_DQRELE: case XFS_ICWALK_DQRELE:
...@@ -1638,7 +1640,7 @@ xfs_icwalk_igrab( ...@@ -1638,7 +1640,7 @@ xfs_icwalk_igrab(
case XFS_ICWALK_BLOCKGC: case XFS_ICWALK_BLOCKGC:
return xfs_blockgc_igrab(ip); return xfs_blockgc_igrab(ip);
case XFS_ICWALK_RECLAIM: case XFS_ICWALK_RECLAIM:
return xfs_reclaim_igrab(ip, eofb); return xfs_reclaim_igrab(ip, icw);
default: default:
return false; return false;
} }
...@@ -1653,16 +1655,16 @@ xfs_icwalk_process_inode( ...@@ -1653,16 +1655,16 @@ xfs_icwalk_process_inode(
enum xfs_icwalk_goal goal, enum xfs_icwalk_goal goal,
struct xfs_inode *ip, struct xfs_inode *ip,
struct xfs_perag *pag, struct xfs_perag *pag,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
int error = 0; int error = 0;
switch (goal) { switch (goal) {
case XFS_ICWALK_DQRELE: case XFS_ICWALK_DQRELE:
xfs_dqrele_inode(ip, eofb); xfs_dqrele_inode(ip, icw);
break; break;
case XFS_ICWALK_BLOCKGC: case XFS_ICWALK_BLOCKGC:
error = xfs_blockgc_scan_inode(ip, eofb); error = xfs_blockgc_scan_inode(ip, icw);
break; break;
case XFS_ICWALK_RECLAIM: case XFS_ICWALK_RECLAIM:
xfs_reclaim_inode(ip, pag); xfs_reclaim_inode(ip, pag);
...@@ -1679,7 +1681,7 @@ static int ...@@ -1679,7 +1681,7 @@ static int
xfs_icwalk_ag( xfs_icwalk_ag(
struct xfs_perag *pag, struct xfs_perag *pag,
enum xfs_icwalk_goal goal, enum xfs_icwalk_goal goal,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
struct xfs_mount *mp = pag->pag_mount; struct xfs_mount *mp = pag->pag_mount;
uint32_t first_index; uint32_t first_index;
...@@ -1727,7 +1729,7 @@ xfs_icwalk_ag( ...@@ -1727,7 +1729,7 @@ xfs_icwalk_ag(
for (i = 0; i < nr_found; i++) { for (i = 0; i < nr_found; i++) {
struct xfs_inode *ip = batch[i]; struct xfs_inode *ip = batch[i];
if (done || !xfs_icwalk_igrab(goal, ip, eofb)) if (done || !xfs_icwalk_igrab(goal, ip, icw))
batch[i] = NULL; batch[i] = NULL;
/* /*
...@@ -1756,7 +1758,7 @@ xfs_icwalk_ag( ...@@ -1756,7 +1758,7 @@ xfs_icwalk_ag(
if (!batch[i]) if (!batch[i])
continue; continue;
error = xfs_icwalk_process_inode(goal, batch[i], pag, error = xfs_icwalk_process_inode(goal, batch[i], pag,
eofb); icw);
if (error == -EAGAIN) { if (error == -EAGAIN) {
skipped++; skipped++;
continue; continue;
...@@ -1771,9 +1773,9 @@ xfs_icwalk_ag( ...@@ -1771,9 +1773,9 @@ xfs_icwalk_ag(
cond_resched(); cond_resched();
if (eofb && (eofb->eof_flags & XFS_ICWALK_FLAG_SCAN_LIMIT)) { if (icw && (icw->icw_flags & XFS_ICWALK_FLAG_SCAN_LIMIT)) {
eofb->icw_scan_limit -= XFS_LOOKUP_BATCH; icw->icw_scan_limit -= XFS_LOOKUP_BATCH;
if (eofb->icw_scan_limit <= 0) if (icw->icw_scan_limit <= 0)
break; break;
} }
} while (nr_found && !done); } while (nr_found && !done);
...@@ -1810,7 +1812,7 @@ static int ...@@ -1810,7 +1812,7 @@ static int
xfs_icwalk( xfs_icwalk(
struct xfs_mount *mp, struct xfs_mount *mp,
enum xfs_icwalk_goal goal, enum xfs_icwalk_goal goal,
struct xfs_eofblocks *eofb) struct xfs_icwalk *icw)
{ {
struct xfs_perag *pag; struct xfs_perag *pag;
int error = 0; int error = 0;
...@@ -1819,7 +1821,7 @@ xfs_icwalk( ...@@ -1819,7 +1821,7 @@ xfs_icwalk(
while ((pag = xfs_icwalk_get_perag(mp, agno, goal))) { while ((pag = xfs_icwalk_get_perag(mp, agno, goal))) {
agno = pag->pag_agno + 1; agno = pag->pag_agno + 1;
error = xfs_icwalk_ag(pag, goal, eofb); error = xfs_icwalk_ag(pag, goal, icw);
xfs_perag_put(pag); xfs_perag_put(pag);
if (error) { if (error) {
last_error = error; last_error = error;
...@@ -1828,5 +1830,5 @@ xfs_icwalk( ...@@ -1828,5 +1830,5 @@ xfs_icwalk(
} }
} }
return last_error; return last_error;
BUILD_BUG_ON(XFS_ICWALK_PRIVATE_FLAGS & XFS_EOF_FLAGS_VALID); BUILD_BUG_ON(XFS_ICWALK_PRIVATE_FLAGS & XFS_ICWALK_FLAGS_VALID);
} }
...@@ -9,15 +9,28 @@ ...@@ -9,15 +9,28 @@
struct xfs_mount; struct xfs_mount;
struct xfs_perag; struct xfs_perag;
struct xfs_eofblocks { struct xfs_icwalk {
__u32 eof_flags; __u32 icw_flags;
kuid_t eof_uid; kuid_t icw_uid;
kgid_t eof_gid; kgid_t icw_gid;
prid_t eof_prid; prid_t icw_prid;
__u64 eof_min_file_size; __u64 icw_min_file_size;
int icw_scan_limit; int icw_scan_limit;
}; };
/* Flags that reflect xfs_fs_eofblocks functionality. */
#define XFS_ICWALK_FLAG_SYNC (1U << 0) /* sync/wait mode scan */
#define XFS_ICWALK_FLAG_UID (1U << 1) /* filter by uid */
#define XFS_ICWALK_FLAG_GID (1U << 2) /* filter by gid */
#define XFS_ICWALK_FLAG_PRID (1U << 3) /* filter by project id */
#define XFS_ICWALK_FLAG_MINFILESIZE (1U << 4) /* filter by min file size */
#define XFS_ICWALK_FLAGS_VALID (XFS_ICWALK_FLAG_SYNC | \
XFS_ICWALK_FLAG_UID | \
XFS_ICWALK_FLAG_GID | \
XFS_ICWALK_FLAG_PRID | \
XFS_ICWALK_FLAG_MINFILESIZE)
/* /*
* Flags for xfs_iget() * Flags for xfs_iget()
*/ */
...@@ -43,9 +56,9 @@ void xfs_inode_mark_reclaimable(struct xfs_inode *ip); ...@@ -43,9 +56,9 @@ void xfs_inode_mark_reclaimable(struct xfs_inode *ip);
int xfs_blockgc_free_dquots(struct xfs_mount *mp, struct xfs_dquot *udqp, int xfs_blockgc_free_dquots(struct xfs_mount *mp, struct xfs_dquot *udqp,
struct xfs_dquot *gdqp, struct xfs_dquot *pdqp, struct xfs_dquot *gdqp, struct xfs_dquot *pdqp,
unsigned int eof_flags); unsigned int iwalk_flags);
int xfs_blockgc_free_quota(struct xfs_inode *ip, unsigned int eof_flags); int xfs_blockgc_free_quota(struct xfs_inode *ip, unsigned int iwalk_flags);
int xfs_blockgc_free_space(struct xfs_mount *mp, struct xfs_eofblocks *eofb); int xfs_blockgc_free_space(struct xfs_mount *mp, struct xfs_icwalk *icm);
void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip); void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip);
void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip); void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip);
......
...@@ -1875,7 +1875,7 @@ xfs_ioc_setlabel( ...@@ -1875,7 +1875,7 @@ xfs_ioc_setlabel(
static inline int static inline int
xfs_fs_eofblocks_from_user( xfs_fs_eofblocks_from_user(
struct xfs_fs_eofblocks *src, struct xfs_fs_eofblocks *src,
struct xfs_eofblocks *dst) struct xfs_icwalk *dst)
{ {
if (src->eof_version != XFS_EOFBLOCKS_VERSION) if (src->eof_version != XFS_EOFBLOCKS_VERSION)
return -EINVAL; return -EINVAL;
...@@ -1887,21 +1887,32 @@ xfs_fs_eofblocks_from_user( ...@@ -1887,21 +1887,32 @@ xfs_fs_eofblocks_from_user(
memchr_inv(src->pad64, 0, sizeof(src->pad64))) memchr_inv(src->pad64, 0, sizeof(src->pad64)))
return -EINVAL; return -EINVAL;
dst->eof_flags = src->eof_flags; dst->icw_flags = 0;
dst->eof_prid = src->eof_prid; if (src->eof_flags & XFS_EOF_FLAGS_SYNC)
dst->eof_min_file_size = src->eof_min_file_size; dst->icw_flags |= XFS_ICWALK_FLAG_SYNC;
if (src->eof_flags & XFS_EOF_FLAGS_UID)
dst->eof_uid = INVALID_UID; dst->icw_flags |= XFS_ICWALK_FLAG_UID;
if (src->eof_flags & XFS_EOF_FLAGS_GID)
dst->icw_flags |= XFS_ICWALK_FLAG_GID;
if (src->eof_flags & XFS_EOF_FLAGS_PRID)
dst->icw_flags |= XFS_ICWALK_FLAG_PRID;
if (src->eof_flags & XFS_EOF_FLAGS_MINFILESIZE)
dst->icw_flags |= XFS_ICWALK_FLAG_MINFILESIZE;
dst->icw_prid = src->eof_prid;
dst->icw_min_file_size = src->eof_min_file_size;
dst->icw_uid = INVALID_UID;
if (src->eof_flags & XFS_EOF_FLAGS_UID) { if (src->eof_flags & XFS_EOF_FLAGS_UID) {
dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid); dst->icw_uid = make_kuid(current_user_ns(), src->eof_uid);
if (!uid_valid(dst->eof_uid)) if (!uid_valid(dst->icw_uid))
return -EINVAL; return -EINVAL;
} }
dst->eof_gid = INVALID_GID; dst->icw_gid = INVALID_GID;
if (src->eof_flags & XFS_EOF_FLAGS_GID) { if (src->eof_flags & XFS_EOF_FLAGS_GID) {
dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid); dst->icw_gid = make_kgid(current_user_ns(), src->eof_gid);
if (!gid_valid(dst->eof_gid)) if (!gid_valid(dst->icw_gid))
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
...@@ -2165,7 +2176,7 @@ xfs_file_ioctl( ...@@ -2165,7 +2176,7 @@ xfs_file_ioctl(
case XFS_IOC_FREE_EOFBLOCKS: { case XFS_IOC_FREE_EOFBLOCKS: {
struct xfs_fs_eofblocks eofb; struct xfs_fs_eofblocks eofb;
struct xfs_eofblocks keofb; struct xfs_icwalk icw;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
...@@ -2176,14 +2187,14 @@ xfs_file_ioctl( ...@@ -2176,14 +2187,14 @@ xfs_file_ioctl(
if (copy_from_user(&eofb, arg, sizeof(eofb))) if (copy_from_user(&eofb, arg, sizeof(eofb)))
return -EFAULT; return -EFAULT;
error = xfs_fs_eofblocks_from_user(&eofb, &keofb); error = xfs_fs_eofblocks_from_user(&eofb, &icw);
if (error) if (error)
return error; return error;
trace_xfs_ioc_free_eofblocks(mp, &keofb, _RET_IP_); trace_xfs_ioc_free_eofblocks(mp, &icw, _RET_IP_);
sb_start_write(mp->m_super); sb_start_write(mp->m_super);
error = xfs_blockgc_free_space(mp, &keofb); error = xfs_blockgc_free_space(mp, &icw);
sb_end_write(mp->m_super); sb_end_write(mp->m_super);
return error; return error;
} }
......
...@@ -37,7 +37,7 @@ struct xfs_trans_res; ...@@ -37,7 +37,7 @@ struct xfs_trans_res;
struct xfs_inobt_rec_incore; struct xfs_inobt_rec_incore;
union xfs_btree_ptr; union xfs_btree_ptr;
struct xfs_dqtrx; struct xfs_dqtrx;
struct xfs_eofblocks; struct xfs_icwalk;
#define XFS_ATTR_FILTER_FLAGS \ #define XFS_ATTR_FILTER_FLAGS \
{ XFS_ATTR_ROOT, "ROOT" }, \ { XFS_ATTR_ROOT, "ROOT" }, \
...@@ -3885,10 +3885,10 @@ DEFINE_EVENT(xfs_timestamp_range_class, name, \ ...@@ -3885,10 +3885,10 @@ DEFINE_EVENT(xfs_timestamp_range_class, name, \
DEFINE_TIMESTAMP_RANGE_EVENT(xfs_inode_timestamp_range); DEFINE_TIMESTAMP_RANGE_EVENT(xfs_inode_timestamp_range);
DEFINE_TIMESTAMP_RANGE_EVENT(xfs_quota_expiry_range); DEFINE_TIMESTAMP_RANGE_EVENT(xfs_quota_expiry_range);
DECLARE_EVENT_CLASS(xfs_eofblocks_class, DECLARE_EVENT_CLASS(xfs_icwalk_class,
TP_PROTO(struct xfs_mount *mp, struct xfs_eofblocks *eofb, TP_PROTO(struct xfs_mount *mp, struct xfs_icwalk *icw,
unsigned long caller_ip), unsigned long caller_ip),
TP_ARGS(mp, eofb, caller_ip), TP_ARGS(mp, icw, caller_ip),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(dev_t, dev) __field(dev_t, dev)
__field(__u32, flags) __field(__u32, flags)
...@@ -3901,14 +3901,14 @@ DECLARE_EVENT_CLASS(xfs_eofblocks_class, ...@@ -3901,14 +3901,14 @@ DECLARE_EVENT_CLASS(xfs_eofblocks_class,
), ),
TP_fast_assign( TP_fast_assign(
__entry->dev = mp->m_super->s_dev; __entry->dev = mp->m_super->s_dev;
__entry->flags = eofb ? eofb->eof_flags : 0; __entry->flags = icw ? icw->icw_flags : 0;
__entry->uid = eofb ? from_kuid(mp->m_super->s_user_ns, __entry->uid = icw ? from_kuid(mp->m_super->s_user_ns,
eofb->eof_uid) : 0; icw->icw_uid) : 0;
__entry->gid = eofb ? from_kgid(mp->m_super->s_user_ns, __entry->gid = icw ? from_kgid(mp->m_super->s_user_ns,
eofb->eof_gid) : 0; icw->icw_gid) : 0;
__entry->prid = eofb ? eofb->eof_prid : 0; __entry->prid = icw ? icw->icw_prid : 0;
__entry->min_file_size = eofb ? eofb->eof_min_file_size : 0; __entry->min_file_size = icw ? icw->icw_min_file_size : 0;
__entry->scan_limit = eofb ? eofb->icw_scan_limit : 0; __entry->scan_limit = icw ? icw->icw_scan_limit : 0;
__entry->caller_ip = caller_ip; __entry->caller_ip = caller_ip;
), ),
TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %d caller %pS", TP_printk("dev %d:%d flags 0x%x uid %u gid %u prid %u minsize %llu scan_limit %d caller %pS",
...@@ -3921,13 +3921,13 @@ DECLARE_EVENT_CLASS(xfs_eofblocks_class, ...@@ -3921,13 +3921,13 @@ DECLARE_EVENT_CLASS(xfs_eofblocks_class,
__entry->scan_limit, __entry->scan_limit,
(char *)__entry->caller_ip) (char *)__entry->caller_ip)
); );
#define DEFINE_EOFBLOCKS_EVENT(name) \ #define DEFINE_ICWALK_EVENT(name) \
DEFINE_EVENT(xfs_eofblocks_class, name, \ DEFINE_EVENT(xfs_icwalk_class, name, \
TP_PROTO(struct xfs_mount *mp, struct xfs_eofblocks *eofb, \ TP_PROTO(struct xfs_mount *mp, struct xfs_icwalk *icw, \
unsigned long caller_ip), \ unsigned long caller_ip), \
TP_ARGS(mp, eofb, caller_ip)) TP_ARGS(mp, icw, caller_ip))
DEFINE_EOFBLOCKS_EVENT(xfs_ioc_free_eofblocks); DEFINE_ICWALK_EVENT(xfs_ioc_free_eofblocks);
DEFINE_EOFBLOCKS_EVENT(xfs_blockgc_free_space); DEFINE_ICWALK_EVENT(xfs_blockgc_free_space);
#endif /* _TRACE_XFS_H */ #endif /* _TRACE_XFS_H */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment