quota: widen timestamps for the fs_disk_quota structure
Subsystems (3)
PATCH v2 1/1 quota: widen timestamps for the fs_disk_quota structure
From: Darrick J. Wong <[email protected]>
Soon, XFS will support quota grace period expiration timestamps beyond the year 2038, widen the timestamp fields to handle the extra time bits. Internally, XFS now stores unsigned 34-bit quantities, so the extra 8 bits here should work fine. (Note that XFS is the only user of this structure.)
---
v2: use __s8 for timestamp extension
--- fs/quota/quota.c | 43 +++++++++++++++++++++++++++++++++++----- include/uapi/linux/dqblk_xfs.h | 11 +++++++++- 2 files changed, 48 insertions(+), 6 deletions(-)
fs/quota/quota.c +38 -5
@@ -481,6 +481,14 @@ static inline u64 quota_btobb(u64 bytes)return (bytes + (1 <<XFS_BB_SHIFT ) -1 ) >>XFS_BB_SHIFT ; } +static inline s64 copy_from_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 timer,__s8 timer_hi) +{ +if (d->d_fieldmask &FS_DQ_BIGTIME ) +return (u32 )timer | (s64 )timer_hi <<32 ; +return timer; +} +static void copy_from_xfs_dqblk (struct qc_dqblk *dst,struct fs_disk_quota *src) { dst->d_spc_hardlimit =quota_bbtob (src->d_blk_hardlimit);
@@ -489,14 +497,18 @@ static void copy_from_xfs_dqblk(struct qc_dqblk *dst, struct fs_disk_quota *src) dst->d_ino_softlimit = src->d_ino_softlimit; dst->d_space =quota_bbtob (src->d_bcount); dst->d_ino_count = src->d_icount; - dst->d_ino_timer = src->d_itimer; - dst->d_spc_timer = src->d_btimer; + dst->d_ino_timer =copy_from_xfs_dqblk_ts (src, src->d_itimer, + src->d_itimer_hi); + dst->d_spc_timer =copy_from_xfs_dqblk_ts (src, src->d_btimer, + src->d_btimer_hi); dst->d_ino_warns = src->d_iwarns; dst->d_spc_warns = src->d_bwarns; dst->d_rt_spc_hardlimit =quota_bbtob (src->d_rtb_hardlimit); dst->d_rt_spc_softlimit =quota_bbtob (src->d_rtb_softlimit); dst->d_rt_space =quota_bbtob (src->d_rtbcount); dst->d_rt_spc_timer = src->d_rtbtimer; + dst->d_rt_spc_timer =copy_from_xfs_dqblk_ts (src, src->d_rtbtimer, + src->d_rtbtimer_hi); dst->d_rt_spc_warns = src->d_rtbwarns; dst->d_fieldmask =0 ;if (src->d_fieldmask &FS_DQ_ISOFT )
@@ -588,10 +600,28 @@ static int quota_setxquota(struct super_block *sb, int type, qid_t id,return sb->s_qcop->set_dqblk (sb, qid, &qdq); } +static inline void copy_to_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 *timer_lo,__s8 *timer_hi,s64 timer) +{ + *timer_lo = timer; +if (d->d_fieldmask &FS_DQ_BIGTIME ) + *timer_hi = timer >>32 ; +else + *timer_hi =0 ; +} + +static inline bool want_bigtime (s64 timer) +{ +return timer >S32_MAX || timer <S32_MIN ; +} +static void copy_to_xfs_dqblk (struct fs_disk_quota *dst,struct qc_dqblk *src,int type,qid_t id) {memset (dst,0 ,sizeof (*dst)); +if (want_bigtime (src->d_ino_timer) ||want_bigtime (src->d_spc_timer) || +want_bigtime (src->d_rt_spc_timer)) + dst->d_fieldmask |=FS_DQ_BIGTIME ; dst->d_version =FS_DQUOT_VERSION ; dst->d_id = id;if (type ==USRQUOTA )
@@ -606,14 +636,17 @@ static void copy_to_xfs_dqblk(struct fs_disk_quota *dst, struct qc_dqblk *src, dst->d_ino_softlimit = src->d_ino_softlimit; dst->d_bcount =quota_btobb (src->d_space); dst->d_icount = src->d_ino_count; - dst->d_itimer = src->d_ino_timer; - dst->d_btimer = src->d_spc_timer; +copy_to_xfs_dqblk_ts (dst, &dst->d_itimer, &dst->d_itimer_hi, + src->d_ino_timer); +copy_to_xfs_dqblk_ts (dst, &dst->d_btimer, &dst->d_btimer_hi, + src->d_spc_timer); dst->d_iwarns = src->d_ino_warns; dst->d_bwarns = src->d_spc_warns; dst->d_rtb_hardlimit =quota_btobb (src->d_rt_spc_hardlimit); dst->d_rtb_softlimit =quota_btobb (src->d_rt_spc_softlimit); dst->d_rtbcount =quota_btobb (src->d_rt_space); - dst->d_rtbtimer = src->d_rt_spc_timer; +copy_to_xfs_dqblk_ts (dst, &dst->d_rtbtimer, &dst->d_rtbtimer_hi, + src->d_rt_spc_timer); dst->d_rtbwarns = src->d_rt_spc_warns; }
include/uapi/linux/dqblk_xfs.h +10 -1
@@ -66,7 +66,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 */
@@ -121,6 +124,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). */
PATCH 1/1 quotatools: support grace period expirations past y2038 in userspace
From: Darrick J. Wong <[email protected]>
Add the ability to interpret the larger quota grace period expiration timestamps that the kernel can export via struct xfs_kern_dqblk.
--- quotaio_xfs.c | 33 +++++++++++++++++++++++++++++---- quotaio_xfs.h | 11 ++++++++++- 2 files changed, 39 insertions(+), 5 deletions(-)
quotaio_xfs.c +29 -4
@@ -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); }/*
quotaio_xfs.h +10 -1
@@ -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. */
Jan Kara
reviewerRe: [PATCH] quotatools: support grace period expirations past y2038 in userspace
Quoted 6 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
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 <[email protected]>
Thanks. I've added the patch to quota-tools tree. I've just extended it a bit so that xfs_util2kerndqblk() checks whether the passed time fits into the 40-bit field and returns error otherwise instead of silently truncating the timestamp...
Honza
Quoted 92 lines
--- quotaio_xfs.c | 33 +++++++++++++++++++++++++++++---- quotaio_xfs.h | 11 ++++++++++- 2 files changed, 39 insertions(+), 5 deletions(-)quotaio_xfs.c +29
-4@@ -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); }/* quotaio_xfs.h +10
-1@@ -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. */
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
fs/quota/quota.c static int quota_setxquota(struct super_block *sb, int type, qid_t id, · line 611
Quoted 9 lines · Darrick J. Wong
fs/quota/quota.c +9
-0+static inline void copy_to_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 *timer_lo,__s8 *timer_hi,s64 timer) +{ + *timer_lo = timer; +if (d->d_fieldmask &FS_DQ_BIGTIME ) + *timer_hi = timer >>32 ; +else + *timer_hi =0 ; +}
Is that actually the right thing to do? If FS_DQ_BIGTIME is not set, I would expect us to avoid writing to timer_hi at all. Alternatively, if we do want to write to timer_hi, why not write to it unconditionally?
Quoted 14 lines · Matthew Wilcox
fs/quota/quota.c static int quota_setxquota(struct super_block *sb, int type, qid_t id, · line 611
Quoted 9 lines · Darrick J. Wong
fs/quota/quota.c +9
-0+static inline void copy_to_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 *timer_lo,__s8 *timer_hi,s64 timer) +{ + *timer_lo = timer; +if (d->d_fieldmask &FS_DQ_BIGTIME ) + *timer_hi = timer >>32 ; +else + *timer_hi =0 ; +}Is that actually the right thing to do? If
FS_DQ_BIGTIMEis not set, I would expect us to avoid writing totimer_hiat all. Alternatively, if we do want to write totimer_hi, why not write to it unconditionally?
If the flag isn't set, then the space used by timer_hi is a zero-filled padding field. Therefore, I made this function zero timer_hi if the bigtime flag isn't set. It's redundant with the memset five lines up from the call site, but I don't like leaving logic bombs in case this function ever gets exported elsewhere.
--D
Jan Kara
reviewerQuoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Soon, XFS will support quota grace period expiration timestamps beyond the year 2038, widen the timestamp fields to handle the extra time bits. Internally, XFS now stores unsigned 34-bit quantities, so the extra 8 bits here should work fine. (Note that XFS is the only user of this structure.)
Signed-off-by Darrick J. Wong <[email protected]>
Looks good to me. Just one question below:
Quoted 6 lines
fs/quota/quota.c +0
-0@@ -481,6 +481,14 @@ static inline u64 quota_btobb(u64 bytes)return (bytes + (1 <<XFS_BB_SHIFT ) -1 ) >>XFS_BB_SHIFT ;
fs/quota/quota.c static inline u64 quota_btobb(u64 bytes) · line 491
Quoted 10 lines
fs/quota/quota.c +8
-0} +static inline s64 copy_from_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 timer,__s8 timer_hi) +{ +if (d->d_fieldmask &FS_DQ_BIGTIME ) +return (u32 )timer | (s64 )timer_hi <<32 ; +return timer; +} +
So this doesn't do any checks that the resulting time fits into 34-bits you speak about in the changelog. So how will XFS react if malicious / buggy userspace will pass too big timestamp? I suppose xfs_fs_set_dqblk() should return EFBIG or EINVAL or something like that which I'm not sure it does...
For record I've checked VFS quota implementation and it doesn't need any checks because VFS in memory structures and on-disk format use 64-bit timestamps. The ancient quota format uses 32-bit timestamps for 32-bit archs so these would get silently truncated when stored on disk but honestly I don't think I care (that format was deprecated some 20 years ago).
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 35 lines · Jan Kara
Quoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Soon, XFS will support quota grace period expiration timestamps beyond the year 2038, widen the timestamp fields to handle the extra time bits. Internally, XFS now stores unsigned 34-bit quantities, so the extra 8 bits here should work fine. (Note that XFS is the only user of this structure.)
Signed-off-by Darrick J. Wong <[email protected]>Looks good to me. Just one question below:
Quoted 6 lines
fs/quota/quota.c +0
-0@@ -481,6 +481,14 @@ static inline u64 quota_btobb(u64 bytes)return (bytes + (1 <<XFS_BB_SHIFT ) -1 ) >>XFS_BB_SHIFT ;fs/quota/quota.c static inline u64 quota_btobb(u64 bytes) · line 491
Quoted 10 lines
fs/quota/quota.c +8
-0} +static inline s64 copy_from_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 timer,__s8 timer_hi) +{ +if (d->d_fieldmask &FS_DQ_BIGTIME ) +return (u32 )timer | (s64 )timer_hi <<32 ; +return timer; +} +So this doesn't do any checks that the resulting time fits into 34-bits you speak about in the changelog. So how will XFS react if malicious / buggy userspace will pass too big timestamp? I suppose
xfs_fs_set_dqblk()should return EFBIG or EINVAL or something like that which I'm not sure it does...
Quoted 6 lines
For record I've checked VFS quota implementation and it doesn't need any checks because VFS in memory structures and on-disk format use 64-bit timestamps. The ancient quota format uses 32-bit timestamps for 32-bit archs so these would get silently truncated when stored on disk but honestly I don't think I care (that format was deprecated some 20 years ago).
XFS will clamp any out-of-bounds value to the nearest representable number. For example, if you tried to extend a quota's grace expiration to the year 2600, it set the expiration to 2486, similar to what the vfs does for timestamps now. If you try to set the default grace period to, say, 100 years, it will clamp that to 68 years (2^31-1).
(I doubt anyone cares to set a 60+ year grace period, but as some apparently immortal person claims to be playing a 600-year musical score[1] perhaps we will need to revisit that...)
--D
[1] https://en.wikipedia.org/wiki/As_Slow_as_Possible
Quoted 5 lines
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerQuoted 43 lines · Darrick J. Wong
Quoted 35 lines · Jan Kara
Quoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Soon, XFS will support quota grace period expiration timestamps beyond the year 2038, widen the timestamp fields to handle the extra time bits. Internally, XFS now stores unsigned 34-bit quantities, so the extra 8 bits here should work fine. (Note that XFS is the only user of this structure.)
Signed-off-by Darrick J. Wong <[email protected]>Looks good to me. Just one question below:
Quoted 6 lines
fs/quota/quota.c +0
-0@@ -481,6 +481,14 @@ static inline u64 quota_btobb(u64 bytes)return (bytes + (1 <<XFS_BB_SHIFT ) -1 ) >>XFS_BB_SHIFT ;fs/quota/quota.c static inline u64 quota_btobb(u64 bytes) · line 491
Quoted 10 lines
fs/quota/quota.c +8
-0} +static inline s64 copy_from_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 timer,__s8 timer_hi) +{ +if (d->d_fieldmask &FS_DQ_BIGTIME ) +return (u32 )timer | (s64 )timer_hi <<32 ; +return timer; +} +So this doesn't do any checks that the resulting time fits into 34-bits you speak about in the changelog. So how will XFS react if malicious / buggy userspace will pass too big timestamp? I suppose
xfs_fs_set_dqblk()should return EFBIG or EINVAL or something like that which I'm not sure it does...Quoted 6 lines
For record I've checked VFS quota implementation and it doesn't need any checks because VFS in memory structures and on-disk format use 64-bit timestamps. The ancient quota format uses 32-bit timestamps for 32-bit archs so these would get silently truncated when stored on disk but honestly I don't think I care (that format was deprecated some 20 years ago).
Quoted 5 lines
XFS will clamp any out-of-bounds value to the nearest representable number. For example, if you tried to extend a quota's grace expiration to the year 2600, it set the expiration to 2486, similar to what the vfs does for timestamps now. If you try to set the default grace period to, say, 100 years, it will clamp that to 68 years (2^31-1).
OK, sounds good. I've pushed out the patch to my tree.
Quoted 7 lines
(I doubt anyone cares to set a 60+ year grace period, but as some apparently immortal person claims to be playing a 600-year musical score[1] perhaps we will need to revisit that...)
--D
;)
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Soon, XFS will support quota grace period expiration timestamps beyond the year 2038, widen the timestamp fields to handle the extra time bits. Internally, XFS now stores unsigned 34-bit quantities, so the extra 8 bits here should work fine. (Note that XFS is the only user of this structure.)
Signed-off-by Darrick J. Wong <[email protected]>
Looks good,
Quoted 41 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Soon, XFS will support quota grace period expiration timestamps beyond the year 2038, widen the timestamp fields to handle the extra time bits. Internally, XFS now stores unsigned 34-bit quantities, so the extra 8 bits here should work fine. (Note that XFS is the only user of this structure.)
Signed-off-by Darrick J. Wong <[email protected]>---
v2: use__s8for timestamp extension--- fs/quota/quota.c | 43 +++++++++++++++++++++++++++++++++++----- include/uapi/linux/dqblk_xfs.h | 11 +++++++++- 2 files changed, 48 insertions(+), 6 deletions(-)fs/quota/quota.c +8
-2@@ -481,6 +481,14 @@ static inline u64 quota_btobb(u64 bytes)return (bytes + (1 <<XFS_BB_SHIFT ) -1 ) >>XFS_BB_SHIFT ; } +static inline s64 copy_from_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 timer,__s8 timer_hi) +{ +if (d->d_fieldmask &FS_DQ_BIGTIME ) +return (u32 )timer | (s64 )timer_hi <<32 ; +return timer; +} +static void copy_from_xfs_dqblk (struct qc_dqblk *dst,struct fs_disk_quota *src) { dst->d_spc_hardlimit =quota_bbtob (src->d_blk_hardlimit);@@ -489,14 +497,18 @@ static void copy_from_xfs_dqblk(struct qc_dqblk *dst, struct fs_disk_quota *src) dst->d_ino_softlimit = src->d_ino_softlimit; dst->d_space =quota_bbtob (src->d_bcount); dst->d_ino_count = src->d_icount; - dst->d_ino_timer = src->d_itimer; - dst->d_spc_timer = src->d_btimer;
fs/quota/quota.c static void copy_from_xfs_dqblk(struct qc_dqblk *dst, struct fs_disk_quota *src) · line 509
Quoted 10 lines
fs/quota/quota.c +4
-0+ dst->d_ino_timer =copy_from_xfs_dqblk_ts (src, src->d_itimer, + src->d_itimer_hi); + dst->d_spc_timer =copy_from_xfs_dqblk_ts (src, src->d_btimer, + src->d_btimer_hi); dst->d_ino_warns = src->d_iwarns; dst->d_spc_warns = src->d_bwarns; dst->d_rt_spc_hardlimit =quota_bbtob (src->d_rtb_hardlimit); dst->d_rt_spc_softlimit =quota_bbtob (src->d_rtb_softlimit); dst->d_rt_space =quota_bbtob (src->d_rtbcount); dst->d_rt_spc_timer = src->d_rtbtimer;
OFC it's only now that the 0day robot catches up and tells me that I forgot to remove the above statement. Ah well, v3 on its way...
--D
Quoted 84 lines
fs/quota/quota.c +26
-3+ dst->d_rt_spc_timer =copy_from_xfs_dqblk_ts (src, src->d_rtbtimer, + src->d_rtbtimer_hi); dst->d_rt_spc_warns = src->d_rtbwarns; dst->d_fieldmask =0 ;if (src->d_fieldmask &FS_DQ_ISOFT )@@ -588,10 +600,28 @@ static int quota_setxquota(struct super_block *sb, int type, qid_t id,return sb->s_qcop->set_dqblk (sb, qid, &qdq); } +static inline void copy_to_xfs_dqblk_ts (const struct fs_disk_quota *d, +__s32 *timer_lo,__s8 *timer_hi,s64 timer) +{ + *timer_lo = timer; +if (d->d_fieldmask &FS_DQ_BIGTIME ) + *timer_hi = timer >>32 ; +else + *timer_hi =0 ; +} + +static inline bool want_bigtime (s64 timer) +{ +return timer >S32_MAX || timer <S32_MIN ; +} +static void copy_to_xfs_dqblk (struct fs_disk_quota *dst,struct qc_dqblk *src,int type,qid_t id) {memset (dst,0 ,sizeof (*dst)); +if (want_bigtime (src->d_ino_timer) ||want_bigtime (src->d_spc_timer) || +want_bigtime (src->d_rt_spc_timer)) + dst->d_fieldmask |=FS_DQ_BIGTIME ; dst->d_version =FS_DQUOT_VERSION ; dst->d_id = id;if (type ==USRQUOTA )@@ -606,14 +636,17 @@ static void copy_to_xfs_dqblk(struct fs_disk_quota *dst, struct qc_dqblk *src, dst->d_ino_softlimit = src->d_ino_softlimit; dst->d_bcount =quota_btobb (src->d_space); dst->d_icount = src->d_ino_count; - dst->d_itimer = src->d_ino_timer; - dst->d_btimer = src->d_spc_timer; +copy_to_xfs_dqblk_ts (dst, &dst->d_itimer, &dst->d_itimer_hi, + src->d_ino_timer); +copy_to_xfs_dqblk_ts (dst, &dst->d_btimer, &dst->d_btimer_hi, + src->d_spc_timer); dst->d_iwarns = src->d_ino_warns; dst->d_bwarns = src->d_spc_warns; dst->d_rtb_hardlimit =quota_btobb (src->d_rt_spc_hardlimit); dst->d_rtb_softlimit =quota_btobb (src->d_rt_spc_softlimit); dst->d_rtbcount =quota_btobb (src->d_rt_space); - dst->d_rtbtimer = src->d_rt_spc_timer; +copy_to_xfs_dqblk_ts (dst, &dst->d_rtbtimer, &dst->d_rtbtimer_hi, + src->d_rt_spc_timer); dst->d_rtbwarns = src->d_rt_spc_warns; }include/uapi/linux/dqblk_xfs.h +10
-1@@ -66,7 +66,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 */ @@ -121,6 +124,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). */