Support grace period expirations past 2038 year for XFS
This commit is contained in:
parent
716ce4c86c
commit
5cf058e49c
104
quota-4.05-Handle-grace-time-overflows-for-XFS-quotas.patch
Normal file
104
quota-4.05-Handle-grace-time-overflows-for-XFS-quotas.patch
Normal file
@ -0,0 +1,104 @@
|
||||
From e777f46f3044ade15908dbb4c925dbb66556a595 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kara <jack@suse.cz>
|
||||
Date: Mon, 21 Sep 2020 13:30:32 +0200
|
||||
Subject: [PATCH 2/2] Handle grace time overflows for XFS quotas
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Add checks and error handling to report when grace times set for XFS
|
||||
quotas would overflow.
|
||||
|
||||
Signed-off-by: Jan Kara <jack@suse.cz>
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
quotaio_xfs.c | 26 +++++++++++++++++---------
|
||||
quotaio_xfs.h | 3 +++
|
||||
2 files changed, 20 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
|
||||
index 9854ec2..2db1c0c 100644
|
||||
--- a/quotaio_xfs.c
|
||||
+++ b/quotaio_xfs.c
|
||||
@@ -65,6 +65,11 @@ static inline int want_bigtime(time_t timer)
|
||||
return timer > INT32_MAX || timer < INT32_MIN;
|
||||
}
|
||||
|
||||
+static inline int timer_fits_xfs_dqblk(time_t timer)
|
||||
+{
|
||||
+ return timer >= FS_DQUOT_TIMER_MIN && timer <= FS_DQUOT_TIMER_MAX;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Convert XFS kernel quota format to utility format
|
||||
*/
|
||||
@@ -83,7 +88,7 @@ static inline void xfs_kern2utildqblk(struct util_dqblk *u, struct xfs_kern_dqbl
|
||||
/*
|
||||
* Convert utility quota format to XFS kernel format
|
||||
*/
|
||||
-static inline void xfs_util2kerndqblk(struct xfs_kern_dqblk *k, struct util_dqblk *u)
|
||||
+static inline int xfs_util2kerndqblk(struct xfs_kern_dqblk *k, struct util_dqblk *u)
|
||||
{
|
||||
memset(k, 0, sizeof(struct xfs_kern_dqblk));
|
||||
k->d_ino_hardlimit = u->dqb_ihardlimit;
|
||||
@@ -92,10 +97,16 @@ 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;
|
||||
+ if (!timer_fits_xfs_dqblk(u->dqb_itime) ||
|
||||
+ !timer_fits_xfs_dqblk(u->dqb_btime)) {
|
||||
+ errno = ERANGE;
|
||||
+ return -1;
|
||||
+ }
|
||||
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);
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -176,7 +187,8 @@ static int xfs_commit_dquot(struct dquot *dquot, int flags)
|
||||
if (!XFS_USRQUOTA(h) && !XFS_GRPQUOTA(h) && !XFS_PRJQUOTA(h))
|
||||
return 0;
|
||||
|
||||
- xfs_util2kerndqblk(&xdqblk, &dquot->dq_dqb);
|
||||
+ if (xfs_util2kerndqblk(&xdqblk, &dquot->dq_dqb) < 0)
|
||||
+ return -1;
|
||||
if (XFS_USRQUOTA(h))
|
||||
xdqblk.d_flags |= XFS_USER_QUOTA;
|
||||
else if (XFS_GRPQUOTA(h))
|
||||
@@ -198,13 +210,9 @@ static int xfs_commit_dquot(struct dquot *dquot, int flags)
|
||||
}
|
||||
|
||||
qcmd = QCMD(Q_XFS_SETQLIM, h->qh_type);
|
||||
- if (quotactl(qcmd, h->qh_quotadev, id, (void *)&xdqblk) < 0) {
|
||||
- ;
|
||||
- }
|
||||
- else {
|
||||
- return 0;
|
||||
- }
|
||||
- return -1;
|
||||
+ if (quotactl(qcmd, h->qh_quotadev, id, (void *)&xdqblk) < 0)
|
||||
+ return -1;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
diff --git a/quotaio_xfs.h b/quotaio_xfs.h
|
||||
index e0c2a62..28dc27e 100644
|
||||
--- a/quotaio_xfs.h
|
||||
+++ b/quotaio_xfs.h
|
||||
@@ -85,6 +85,9 @@ typedef struct fs_disk_quota {
|
||||
char d_padding4[8]; /* yet more padding */
|
||||
} fs_disk_quota_t;
|
||||
|
||||
+#define FS_DQUOT_TIMER_MAX (((__s64)1 << 39) - 1)
|
||||
+#define FS_DQUOT_TIMER_MIN (-((__s64)1 << 39))
|
||||
+
|
||||
/*
|
||||
* These fields are sent to Q_XSETQLIM to specify fields that need to change.
|
||||
*/
|
||||
--
|
||||
2.25.4
|
||||
|
||||
@ -0,0 +1,109 @@
|
||||
From 16b60cb9e315ed0e859dba6bea0f206d674d519f Mon Sep 17 00:00:00 2001
|
||||
From: "Darrick J. Wong" <darrick.wong@oracle.com>
|
||||
Date: Sat, 5 Sep 2020 09:50:26 -0700
|
||||
Subject: [PATCH 1/2] Support grace period expirations past y2038 for XFS
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
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>
|
||||
Signed-off-by: Jan Kara <jack@suse.cz>
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.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.
|
||||
*/
|
||||
--
|
||||
2.25.4
|
||||
|
||||
13
quota.spec
13
quota.spec
@ -13,7 +13,7 @@
|
||||
Name: quota
|
||||
Epoch: 1
|
||||
Version: 4.05
|
||||
Release: 16%{?dist}
|
||||
Release: 17%{?dist}
|
||||
Summary: System administration tools for monitoring users' disk usage
|
||||
# quota_nld.c, quotaio_xfs.h: GPLv2
|
||||
# bylabel.c copied from util-linux: GPLv2+
|
||||
@ -108,6 +108,12 @@ Patch19: quota-4.05-quota-tools-pass-quota-type-to-QCMD-for-Q_XFS_GETQST.patch
|
||||
Patch20: quota-4.05-quota-tools-Set-FS_DQ_TIMER_MASK-for-individual-xfs-.patch
|
||||
# 2/2 Support setting individual grace times for XFS, in upstream after 4.05
|
||||
Patch21: quota-4.05-Fix-limits-setting-on-XFS-filesystem.patch
|
||||
# 1/2 Support grace period expirations past 2038 year for XFS,
|
||||
# in upstream after 4.05
|
||||
Patch22: quota-4.05-Support-grace-period-expirations-past-y2038-for-XFS.patch
|
||||
# 2/2 Support grace period expirations past 2038 year for XFS,
|
||||
# in upstream after 4.05
|
||||
Patch23: quota-4.05-Handle-grace-time-overflows-for-XFS-quotas.patch
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: automake
|
||||
BuildRequires: bash
|
||||
@ -250,6 +256,8 @@ Linux/UNIX environment.
|
||||
%patch19 -p1
|
||||
%patch20 -p1
|
||||
%patch21 -p1
|
||||
%patch22 -p1
|
||||
%patch23 -p1
|
||||
# Regenerate build scripts
|
||||
autoreconf -f -i
|
||||
|
||||
@ -399,6 +407,9 @@ make check
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Nov 06 2020 Petr Pisar <ppisar@redhat.com> - 1:4.05-17
|
||||
- Support grace period expirations past 2038 year for XFS
|
||||
|
||||
* Wed Sep 02 2020 Petr Pisar <ppisar@redhat.com> - 1:4.05-16
|
||||
- Require libtirpc-devel by quota-devel because of rpc/rpc.h
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user