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;
} }
......
This diff is collapsed.
...@@ -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;
...@@ -2164,8 +2175,8 @@ xfs_file_ioctl( ...@@ -2164,8 +2175,8 @@ xfs_file_ioctl(
return xfs_errortag_clearall(mp); return xfs_errortag_clearall(mp);
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