Signed-off-by: Andrew Perepechko <andrew.perepechko@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
----
- fs/quota_v2.c | 140 ++++++++++++++++++++++++++++++++++++----------
- fs/quotaio_v2.h | 26 ++++++--
- 2 files changed, 132 insertions(+), 34 deletions(-)
-
-diff -puN fs/quota_v2.c~quota-support-64-bit-quota-format fs/quota_v2.c
---- a/fs/quota_v2.c~quota-support-64-bit-quota-format
-+++ a/fs/quota_v2.c
-@@ -23,14 +23,24 @@ MODULE_LICENSE("GPL");
+diff --git a/fs/quota/quota_v2.c a/fs/quota/quota_v2.c
+--- a/fs/quota/quota_v2.c
++++ b/fs/quota/quota_v2.c
+@@ -23,14 +23,23 @@
#define __QUOTA_V2_PARANOIA
+static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot);
+static void v2r0_disk2memdqb(struct dquot *dquot, void *dp);
+static int v2r0_is_id(void *dp, struct dquot *dquot);
++static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot);
++static void v2r1_disk2memdqb(struct dquot *dquot, void *dp);
++static int v2r1_is_id(void *dp, struct dquot *dquot);
+
+static struct qtree_fmt_operations v2r0_qtree_ops = {
+ .mem2disk_dqblk = v2r0_mem2diskdqb,
+ .is_id = v2r0_is_id,
+};
+
-+static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot);
-+static void v2r1_disk2memdqb(struct dquot *dquot, void *dp);
-+static int v2r1_is_id(void *dp, struct dquot *dquot);
-+
+static struct qtree_fmt_operations v2r1_qtree_ops = {
+ .mem2disk_dqblk = v2r1_mem2diskdqb,
+ .disk2mem_dqblk = v2r1_disk2memdqb,
};
#define QUOTABLOCK_BITS 10
-@@ -46,8 +56,7 @@ static inline qsize_t v2_qbtos(qsize_t b
+@@ -46,23 +55,32 @@
return blocks << QUOTABLOCK_BITS;
}
--/* Check whether given file is really vfsv0 quotafile */
--static int v2_check_quota_file(struct super_block *sb, int type)
-+static int v2_check_quota_file_header(struct super_block *sb, int type)
++static int v2_read_header(struct super_block *sb, int type,
++ struct v2_disk_dqheader *dqhead)
++{
++ ssize_t size;
++
++ size = sb->s_op->quota_read(sb, type, (char *)dqhead,
++ sizeof(struct v2_disk_dqheader), 0);
++ if (size != sizeof(struct v2_disk_dqheader)) {
++ printk("quota_v2: failed read expected=%zd got=%zd",
++ sizeof(struct v2_disk_dqheader), size);
++ return 0;
++ }
++ return 1;
++}
++
+ /* Check whether given file is really vfsv0 quotafile */
+ static int v2_check_quota_file(struct super_block *sb, int type)
{
struct v2_disk_dqheader dqhead;
- ssize_t size;
-@@ -58,12 +67,20 @@ static int v2_check_quota_file(struct su
- if (size != sizeof(struct v2_disk_dqheader)) {
- printk("quota_v2: failed read expected=%zd got=%zd\n",
- sizeof(struct v2_disk_dqheader), size);
-- return 0;
-+ return -EIO;
- }
-- if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] ||
+- ssize_t size;
+ static const uint quota_magics[] = V2_INITQMAGICS;
+ static const uint quota_versions[] = V2_INITQVERSIONS;
+
+- size = sb->s_op->quota_read(sb, type, (char *)&dqhead,
+- sizeof(struct v2_disk_dqheader), 0);
+- if (size != sizeof(struct v2_disk_dqheader)) {
+- printk("quota_v2: failed read expected=%zd got=%zd\n",
+- sizeof(struct v2_disk_dqheader), size);
++ if (!v2_read_header(sb, type, &dqhead))
+ return 0;
+- }
+ if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] ||
- le32_to_cpu(dqhead.dqh_version) != quota_versions[type])
-- return 0;
-- return 1;
-+ if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type])
-+ return -ENOENT;
-+ if (le32_to_cpu(dqhead.dqh_version) > quota_versions[type])
-+ return -EOPNOTSUPP;
-+ return le32_to_cpu(dqhead.dqh_version);
-+}
-+
-+
-+/* Check whether given file is really vfsv0 quotafile */
-+static int v2_check_quota_file(struct super_block *sb, int type)
-+{
-+ return v2_check_quota_file_header(sb, type) >= 0;
++ le32_to_cpu(dqhead.dqh_version) > quota_versions[type])
+ return 0;
+ return 1;
}
-
- /* Read information header from quota file */
-@@ -73,7 +90,13 @@ static int v2_read_file_info(struct supe
+@@ -71,9 +89,15 @@
+ static int v2_read_file_info(struct super_block *sb, int type)
+ {
+ struct v2_disk_dqinfo dinfo;
++ struct v2_disk_dqheader dqhead;
struct mem_dqinfo *info = sb_dqinfo(sb, type);
struct qtree_mem_dqinfo *qinfo;
ssize_t size;
-+ int version = v2_check_quota_file_header(sb, type);
-
-+ if (version < 0) {
-+ printk(KERN_WARNING "Cannot identify quota file version on "
-+ "device %s: %d\n", sb->s_id, version);
++ unsigned int version;
++
++ if (!v2_read_header(sb, type, &dqhead))
+ return -1;
-+ }
++ version = le32_to_cpu(dqhead.dqh_version);
+
size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
- if (size != sizeof(struct v2_disk_dqinfo)) {
-@@ -88,9 +111,14 @@ static int v2_read_file_info(struct supe
+@@ -89,9 +113,15 @@
return -1;
}
qinfo = info->dqi_priv;
+ info->dqi_maxblimit = 0xffffffff;
+ info->dqi_maxilimit = 0xffffffff;
+ } else {
-+ info->dqi_maxblimit = 0x7fffffffffffffffULL;
-+ info->dqi_maxilimit = 0x7fffffffffffffffULL;
++ /* used space is stored as unsigned 64-bit value */
++ info->dqi_maxblimit = 0xffffffffffffffffULL; /* 2^64-1 */
++ info->dqi_maxilimit = 0xffffffffffffffffULL;
+ }
info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
info->dqi_flags = le32_to_cpu(dinfo.dqi_flags);
-@@ -102,8 +130,13 @@ static int v2_read_file_info(struct supe
+@@ -103,8 +133,13 @@
qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS;
qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS;
qinfo->dqi_qtree_depth = qtree_depth(qinfo);
return 0;
}
-@@ -134,9 +167,9 @@ static int v2_write_file_info(struct sup
+@@ -135,9 +170,9 @@
return 0;
}
struct mem_dqblk *m = &dquot->dq_dqb;
m->dqb_ihardlimit = le32_to_cpu(d->dqb_ihardlimit);
-@@ -148,15 +181,15 @@ static void v2_disk2memdqb(struct dquot
+@@ -149,15 +184,15 @@
m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
m->dqb_btime = le64_to_cpu(d->dqb_btime);
/* We need to escape back all-zero structure */
struct mem_dqblk *m = &dquot->dq_dqb;
struct qtree_mem_dqinfo *info =
sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
-@@ -174,9 +207,60 @@ static void v2_mem2diskdqb(void *dp, str
+@@ -175,9 +210,60 @@
d->dqb_itime = cpu_to_le64(1);
}
+ struct v2r1_disk_dqblk *d = dp;
+ struct mem_dqblk *m = &dquot->dq_dqb;
+ struct qtree_mem_dqinfo *info =
-+ sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
++ sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
+
+ d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
+ d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
struct qtree_mem_dqinfo *info =
sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
-diff -puN fs/quotaio_v2.h~quota-support-64-bit-quota-format fs/quotaio_v2.h
---- a/fs/quotaio_v2.h~quota-support-64-bit-quota-format
-+++ a/fs/quotaio_v2.h
+@@ -301,20 +303,32 @@ static struct quota_format_ops v2_format
+ .release_dqblk = v2_release_dquot,
+ };
+
+-static struct quota_format_type v2_quota_format = {
++static struct quota_format_type v2r0_quota_format = {
+ .qf_fmt_id = QFMT_VFS_V0,
+ .qf_ops = &v2_format_ops,
+ .qf_owner = THIS_MODULE
+ };
+
++static struct quota_format_type v2r1_quota_format = {
++ .qf_fmt_id = QFMT_VFS_V1,
++ .qf_ops = &v2_format_ops,
++ .qf_owner = THIS_MODULE
++};
++
+ static int __init init_v2_quota_format(void)
+ {
+- return register_quota_format(&v2_quota_format);
++ int ret;
++
++ ret = register_quota_format(&v2r0_quota_format);
++ if (ret)
++ return ret;
++ return register_quota_format(&v2r1_quota_format);
+ }
+
+ static void __exit exit_v2_quota_format(void)
+ {
+- unregister_quota_format(&v2_quota_format);
++ unregister_quota_format(&v2r0_quota_format);
++ unregister_quota_format(&v2r1_quota_format);
+ }
+
+ module_init(init_v2_quota_format);
+diff --git a/fs/quota/quotaio_v2.h b/fs/quota/quotaio_v2.h
+--- a/fs/quota/quotaio_v2.h
++++ b/fs/quota/quotaio_v2.h
@@ -17,8 +17,8 @@
}
struct v2_disk_dqinfo {
__le32 dqi_bgrace; /* Time before block soft limit becomes hard limit */
_
+diff --git a/include/linux/quota.h b/include/linux/quota.h
+--- a/include/linux/quota.h
++++ b/include/linux/quota.h
+@@ -73,6 +73,8 @@
+ /* Quota format type IDs */
+ #define QFMT_VFS_OLD 1
+ #define QFMT_VFS_V0 2
++#define QFMT_OCFS2 3
++#define QFMT_VFS_V1 4
+
+ /* Size of block in which space limits are passed through the quota
+ * interface */
+@@ -398,6 +398,7 @@ struct quota_module_name {
+ #define INIT_QUOTA_MODULE_NAMES {\
+ {QFMT_VFS_OLD, "quota_v1"},\
+ {QFMT_VFS_V0, "quota_v2"},\
++ {QFMT_VFS_V1, "quota_v2"},\
+ {0, NULL}}
+
+ #else