Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] quotatools: support grace period expirations past y2038 in userspace
Date: Sat, 5 Sep 2020 09:50:26 -0700 [thread overview]
Message-ID: <20200905165026.GD7955@magnolia> (raw)
In-Reply-To: <20200905164703.GC7955@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Add the ability to interpret the larger quota grace period expiration
timestamps that the kernel can export via struct xfs_kern_dqblk.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
quotaio_xfs.c | 33 +++++++++++++++++++++++++++++----
quotaio_xfs.h | 11 ++++++++++-
2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
index 3333bb1..9854ec2 100644
--- a/quotaio_xfs.c
+++ b/quotaio_xfs.c
@@ -42,6 +42,29 @@ scan_dquots: xfs_scan_dquots,
report: xfs_report
};
+static inline time_t xfs_kern2utildqblk_ts(const struct xfs_kern_dqblk *k,
+ __s32 timer, __s8 timer_hi)
+{
+ if (k->d_fieldmask & FS_DQ_BIGTIME)
+ return (__u32)timer | (__s64)timer_hi << 32;
+ return timer;
+}
+
+static inline void xfs_util2kerndqblk_ts(const struct xfs_kern_dqblk *k,
+ __s32 *timer_lo, __s8 *timer_hi, time_t timer)
+{
+ *timer_lo = timer;
+ if (k->d_fieldmask & FS_DQ_BIGTIME)
+ *timer_hi = timer >> 32;
+ else
+ *timer_hi = 0;
+}
+
+static inline int want_bigtime(time_t timer)
+{
+ return timer > INT32_MAX || timer < INT32_MIN;
+}
+
/*
* Convert XFS kernel quota format to utility format
*/
@@ -53,8 +76,8 @@ static inline void xfs_kern2utildqblk(struct util_dqblk *u, struct xfs_kern_dqbl
u->dqb_bsoftlimit = k->d_blk_softlimit >> 1;
u->dqb_curinodes = k->d_icount;
u->dqb_curspace = ((qsize_t)k->d_bcount) << 9;
- u->dqb_itime = k->d_itimer;
- u->dqb_btime = k->d_btimer;
+ u->dqb_itime = xfs_kern2utildqblk_ts(k, k->d_itimer, k->d_itimer_hi);
+ u->dqb_btime = xfs_kern2utildqblk_ts(k, k->d_btimer, k->d_btimer_hi);
}
/*
@@ -69,8 +92,10 @@ static inline void xfs_util2kerndqblk(struct xfs_kern_dqblk *k, struct util_dqbl
k->d_blk_softlimit = u->dqb_bsoftlimit << 1;
k->d_icount = u->dqb_curinodes;
k->d_bcount = u->dqb_curspace >> 9;
- k->d_itimer = u->dqb_itime;
- k->d_btimer = u->dqb_btime;
+ if (want_bigtime(u->dqb_itime) || want_bigtime(u->dqb_btime))
+ k->d_fieldmask |= FS_DQ_BIGTIME;
+ xfs_util2kerndqblk_ts(k, &k->d_itimer, &k->d_itimer_hi, u->dqb_itime);
+ xfs_util2kerndqblk_ts(k, &k->d_btimer, &k->d_btimer_hi, u->dqb_btime);
}
/*
diff --git a/quotaio_xfs.h b/quotaio_xfs.h
index be7f86f..e0c2a62 100644
--- a/quotaio_xfs.h
+++ b/quotaio_xfs.h
@@ -72,7 +72,10 @@ typedef struct fs_disk_quota {
__s32 d_btimer; /* similar to above; for disk blocks */
__u16 d_iwarns; /* # warnings issued wrt num inodes */
__u16 d_bwarns; /* # warnings issued wrt disk blocks */
- __s32 d_padding2; /* padding2 - for future use */
+ __s8 d_itimer_hi; /* upper 8 bits of timer values */
+ __s8 d_btimer_hi;
+ __s8 d_rtbtimer_hi;
+ __s8 d_padding2; /* padding2 - for future use */
__u64 d_rtb_hardlimit; /* absolute limit on realtime blks */
__u64 d_rtb_softlimit; /* preferred limit on RT disk blks */
__u64 d_rtbcount; /* # realtime blocks owned */
@@ -114,6 +117,12 @@ typedef struct fs_disk_quota {
#define FS_DQ_RTBCOUNT (1<<14)
#define FS_DQ_ACCT_MASK (FS_DQ_BCOUNT | FS_DQ_ICOUNT | FS_DQ_RTBCOUNT)
+/*
+ * Quota expiration timestamps are 40-bit signed integers, with the upper 8
+ * bits encoded in the _hi fields.
+ */
+#define FS_DQ_BIGTIME (1<<15)
+
/*
* Various flags related to quotactl(2). Only relevant to XFS filesystems.
*/
next prev parent reply other threads:[~2020-09-05 16:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-05 16:47 [PATCH v2] quota: widen timestamps for the fs_disk_quota structure Darrick J. Wong
2020-09-05 16:50 ` Darrick J. Wong [this message]
2020-09-07 10:22 ` [PATCH] quotatools: support grace period expirations past y2038 in userspace Jan Kara
2020-09-05 22:02 ` [PATCH v2] quota: widen timestamps for the fs_disk_quota structure Matthew Wilcox
2020-09-06 17:09 ` Darrick J. Wong
2020-09-07 10:02 ` Jan Kara
2020-09-07 15:01 ` Darrick J. Wong
2020-09-07 16:28 ` Jan Kara
2020-09-08 14:33 ` Christoph Hellwig
2020-09-09 1:33 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200905165026.GD7955@magnolia \
--to=darrick.wong@oracle.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--subject='Re: [PATCH] quotatools: support grace period expirations past y2038 in userspace' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).