This patch fixes mismatched root inode and quota info.

Signed-off-by: Jaegeuk Kim <[email protected]>
---
 mkfs/f2fs_format.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 45963c8..ddd0809 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -1061,7 +1061,8 @@ static int f2fs_write_root_inode(void)
        return 0;
 }
 
-static int f2fs_write_default_quota(int qtype, unsigned int blkaddr)
+static int f2fs_write_default_quota(int qtype, unsigned int blkaddr,
+                                               __le32 raw_id)
 {
        char *filebuf = calloc(F2FS_BLKSIZE, 2);
        int file_magics[] = INITQMAGICS;
@@ -1098,7 +1099,7 @@ static int f2fs_write_default_quota(int qtype, unsigned 
int blkaddr)
 
        filebuf[5120 + 8] = 1;
 
-       dqblk.dqb_id = cpu_to_le32(0);
+       dqblk.dqb_id = raw_id;
        dqblk.dqb_pad = cpu_to_le32(0);
        dqblk.dqb_ihardlimit = cpu_to_le64(0);
        dqblk.dqb_isoftlimit = cpu_to_le64(0);
@@ -1129,6 +1130,7 @@ static int f2fs_write_qf_inode(int qtype)
        struct f2fs_node *raw_node = NULL;
        u_int64_t data_blk_nor;
        u_int64_t main_area_node_seg_blk_offset = 0;
+       __le32 raw_id;
        int i;
 
        raw_node = calloc(F2FS_BLKSIZE, 1);
@@ -1180,9 +1182,17 @@ static int f2fs_write_qf_inode(int qtype)
        for (i = 0; i < qtype; i++)
                if (sb->qf_ino[i])
                        data_blk_nor += QUOTA_DATA(i);
+       if (qtype == 0)
+               raw_id = raw_node->i.i_uid;
+       else if (qtype == 1)
+               raw_id = raw_node->i.i_gid;
+       else if (qtype == 2)
+               raw_id = raw_node->i.i_projid;
+       else
+               ASSERT(0);
 
        /* write two blocks */
-       if (f2fs_write_default_quota(qtype, data_blk_nor)) {
+       if (f2fs_write_default_quota(qtype, data_blk_nor, raw_id)) {
                free(raw_node);
                return -1;
        }
-- 
2.15.0.403.gc27cc4dac6-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to