summaryrefslogtreecommitdiff
path: root/quotaio_v2.c
diff options
context:
space:
mode:
authorOssama Othman <ossama.othman@intel.com>2013-11-25 15:00:02 -0800
committerOssama Othman <ossama.othman@intel.com>2013-11-25 15:00:02 -0800
commit47ae1cde69cd6bf2c22e20902cefa3f0e25c8cb4 (patch)
treeadd9aa20a19f410a91522d4b95df3e93c57f8637 /quotaio_v2.c
parent8c82de96cd23e4823a2d29eb2de2295c0866b0c9 (diff)
downloadquota-47ae1cde69cd6bf2c22e20902cefa3f0e25c8cb4.tar.gz
quota-47ae1cde69cd6bf2c22e20902cefa3f0e25c8cb4.tar.bz2
quota-47ae1cde69cd6bf2c22e20902cefa3f0e25c8cb4.zip
Update to latest version of quota.4.01upstream
Change-Id: I2271f01ae7877d43dde2432a45b49b910ddb6f8f Signed-off-by: Ossama Othman <ossama.othman@intel.com>
Diffstat (limited to 'quotaio_v2.c')
-rw-r--r--quotaio_v2.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/quotaio_v2.c b/quotaio_v2.c
index 2e3c725..06be04e 100644
--- a/quotaio_v2.c
+++ b/quotaio_v2.c
@@ -144,6 +144,7 @@ static void v2r1_mem2diskdqblk(void *dp, struct dquot *dquot)
d->dqb_itime = __cpu_to_le64(m->dqb_itime);
d->dqb_btime = __cpu_to_le64(m->dqb_btime);
d->dqb_id = __cpu_to_le32(dquot->dq_id);
+ d->dqb_pad = 0; /* Initialize because of qtree_entry_unused() scan */
if (qtree_entry_unused(&dquot->dq_h->qh_info.u.v2_mdqi.dqi_qtree, dp))
d->dqb_itime = __cpu_to_le64(1);
}
@@ -307,9 +308,17 @@ static int v2_init_io(struct quota_handle *h)
if (__le32_to_cpu(header.dqh_version) == 0) {
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size = sizeof(struct v2r0_disk_dqblk);
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r0_fmt_ops;
+ h->qh_info.dqi_max_b_limit = ~(uint32_t)0;
+ h->qh_info.dqi_max_i_limit = ~(uint32_t)0;
+ h->qh_info.dqi_max_b_usage = ~(uint64_t)0;
+ h->qh_info.dqi_max_i_usage = ~(uint32_t)0;
} else {
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r1_fmt_ops;
+ h->qh_info.dqi_max_b_limit = ~(uint64_t)0;
+ h->qh_info.dqi_max_i_limit = ~(uint64_t)0;
+ h->qh_info.dqi_max_b_usage = ~(uint64_t)0;
+ h->qh_info.dqi_max_i_usage = ~(uint64_t)0;
}
} else {
/* We don't have the file open -> we don't need quota tree operations */
@@ -351,9 +360,17 @@ static int v2_new_io(struct quota_handle *h)
if (version == 0) {
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size = sizeof(struct v2r0_disk_dqblk);
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r0_fmt_ops;
+ h->qh_info.dqi_max_b_limit = ~(uint32_t)0;
+ h->qh_info.dqi_max_i_limit = ~(uint32_t)0;
+ h->qh_info.dqi_max_b_usage = ~(uint64_t)0;
+ h->qh_info.dqi_max_i_usage = ~(uint32_t)0;
} else if (version == 1) {
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r1_fmt_ops;
+ h->qh_info.dqi_max_b_limit = ~(uint64_t)0;
+ h->qh_info.dqi_max_i_limit = ~(uint64_t)0;
+ h->qh_info.dqi_max_b_usage = ~(uint64_t)0;
+ h->qh_info.dqi_max_i_usage = ~(uint64_t)0;
}
v2_mem2diskdqinfo(&ddqinfo, &h->qh_info);
lseek(h->qh_fd, V2_DQINFOOFF, SEEK_SET);
@@ -477,18 +494,18 @@ static int v2_commit_dquot(struct dquot *dquot, int flags)
if (!b->dqb_curspace && !b->dqb_curinodes && !b->dqb_bsoftlimit && !b->dqb_isoftlimit
&& !b->dqb_bhardlimit && !b->dqb_ihardlimit)
qtree_delete_dquot(dquot);
- else
+ else {
+ if (check_dquot_range(dquot) < 0) {
+ errno = ERANGE;
+ return -1;
+ }
qtree_write_dquot(dquot);
+ }
return 0;
}
static int v2_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *, char *))
{
- if (QIO_ENABLED(h)) /* Kernel uses same file? */
- if (quotactl(QCMD((kernel_iface == IFACE_GENERIC) ? Q_SYNC : Q_6_5_SYNC, h->qh_type),
- h->qh_quotadev, 0, NULL) < 0)
- die(4, _("Cannot sync quotas on device %s: %s\n"), h->qh_quotadev,
- strerror(errno));
return qtree_scan_dquots(h, process_dquot);
}