Merge remote-tracking branch 'lsk/v3.10/topic/arm64-misc' into linux-linaro-lsk
[firefly-linux-kernel-4.4.55.git] / fs / quota / quota_v1.c
index 34b37a67bb16c6c936bd725e5fa79e76ffb2ddc0..469c6848b322dd9f6b8aab6933b9cc75d8ee18c9 100644 (file)
@@ -54,7 +54,7 @@ static void v1_mem2disk_dqblk(struct v1_disk_dqblk *d, struct mem_dqblk *m)
 
 static int v1_read_dqblk(struct dquot *dquot)
 {
-       int type = dquot->dq_type;
+       int type = dquot->dq_id.type;
        struct v1_disk_dqblk dqblk;
 
        if (!sb_dqopt(dquot->dq_sb)->files[type])
@@ -63,7 +63,8 @@ static int v1_read_dqblk(struct dquot *dquot)
        /* Set structure to 0s in case read fails/is after end of file */
        memset(&dqblk, 0, sizeof(struct v1_disk_dqblk));
        dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type, (char *)&dqblk,
-                       sizeof(struct v1_disk_dqblk), v1_dqoff(dquot->dq_id));
+                       sizeof(struct v1_disk_dqblk),
+                       v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id)));
 
        v1_disk2mem_dqblk(&dquot->dq_dqb, &dqblk);
        if (dquot->dq_dqb.dqb_bhardlimit == 0 &&
@@ -78,12 +79,13 @@ static int v1_read_dqblk(struct dquot *dquot)
 
 static int v1_commit_dqblk(struct dquot *dquot)
 {
-       short type = dquot->dq_type;
+       short type = dquot->dq_id.type;
        ssize_t ret;
        struct v1_disk_dqblk dqblk;
 
        v1_mem2disk_dqblk(&dqblk, &dquot->dq_dqb);
-       if (dquot->dq_id == 0) {
+       if (((type == USRQUOTA) && uid_eq(dquot->dq_id.uid, GLOBAL_ROOT_UID)) ||
+           ((type == GRPQUOTA) && gid_eq(dquot->dq_id.gid, GLOBAL_ROOT_GID))) {
                dqblk.dqb_btime =
                        sb_dqopt(dquot->dq_sb)->info[type].dqi_bgrace;
                dqblk.dqb_itime =
@@ -93,7 +95,7 @@ static int v1_commit_dqblk(struct dquot *dquot)
        if (sb_dqopt(dquot->dq_sb)->files[type])
                ret = dquot->dq_sb->s_op->quota_write(dquot->dq_sb, type,
                        (char *)&dqblk, sizeof(struct v1_disk_dqblk),
-                       v1_dqoff(dquot->dq_id));
+                       v1_dqoff(from_kqid(&init_user_ns, dquot->dq_id)));
        if (ret != sizeof(struct v1_disk_dqblk)) {
                quota_error(dquot->dq_sb, "dquota write failed");
                if (ret >= 0)