This patch modifies enabling quota options in which enables user/group quotas only if user specifies the "-O quota" especially.
1) -O quota : enables usr/grp 2) -O project_quota -O extra_attr : enabled prj 3) -O quota -O project_quota -O extra_attr : enables usr/grp/proj 4) -g android : enables usr/grp 5) -g android -O project_quota -O extra_attr : enables usr/grp/proj Signed-off-by: Jaegeuk Kim <jaeg...@kernel.org> --- include/f2fs_fs.h | 1 + mkfs/f2fs_format.c | 37 ++++++++++++++----------------------- mkfs/f2fs_format_main.c | 9 +++++++++ 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 9f918ba8f750..d236437475f5 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -504,6 +504,7 @@ struct f2fs_configuration { int large_nat_bitmap; int fix_chksum; /* fix old cp.chksum position */ __le32 feature; /* defined features */ + unsigned int quota_bits; /* quota bits */ time_t fixed_time; /* mkfs parameters */ diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index d6a92f800513..864d2851bd6a 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -38,8 +38,6 @@ struct f2fs_checkpoint *cp; /* Return time fixed by the user or current time by default */ #define mkfs_time ((c.fixed_time == -1) ? time(NULL) : c.fixed_time) -static unsigned int quotatype_bits = 0; - const char *media_ext_lists[] = { /* common prefix */ "mp", // Covers mp3, mp4, mpeg, mpg @@ -513,14 +511,8 @@ static int f2fs_prepare_super_block(void) set_sb(root_ino, 3); c.next_free_nid = 4; - if (c.feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { - quotatype_bits = QUOTA_USR_BIT | QUOTA_GRP_BIT; - if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) - quotatype_bits |= QUOTA_PRJ_BIT; - } - for (qtype = 0; qtype < F2FS_MAX_QUOTAS; qtype++) { - if (!((1 << qtype) & quotatype_bits)) + if (!((1 << qtype) & c.quota_bits)) continue; sb->qf_ino[qtype] = cpu_to_le32(c.next_free_nid++); MSG(0, "Info: add quota type = %u => %u\n", @@ -867,7 +859,7 @@ static int f2fs_write_check_point_pack(void) get_cp(cur_node_segno[0]) * c.blks_per_seg); for (qtype = 0, i = 1; qtype < F2FS_MAX_QUOTAS; qtype++) { - if (sb->qf_ino[qtype] == 0) + if (!((1 << qtype) & c.quota_bits)) continue; journal->nat_j.entries[i].nid = sb->qf_ino[qtype]; journal->nat_j.entries[i].ne.version = 0; @@ -958,10 +950,11 @@ static int f2fs_write_check_point_pack(void) off = 1; for (qtype = 0; qtype < F2FS_MAX_QUOTAS; qtype++) { - if (sb->qf_ino[qtype] == 0) - continue; int j; + if (!((1 << qtype) & c.quota_bits)) + continue; + for (j = 0; j < QUOTA_DATA(qtype); j++) { (sum_entry + off + j)->nid = sb->qf_ino[qtype]; (sum_entry + off + j)->ofs_in_node = cpu_to_le16(j); @@ -992,7 +985,7 @@ static int f2fs_write_check_point_pack(void) sum->entries[0].nid = sb->root_ino; sum->entries[0].ofs_in_node = 0; for (qtype = i = 0; qtype < F2FS_MAX_QUOTAS; qtype++) { - if (sb->qf_ino[qtype] == 0) + if (!((1 << qtype) & c.quota_bits)) continue; sum->entries[1 + i].nid = sb->qf_ino[qtype]; sum->entries[1 + i].ofs_in_node = 0; @@ -1360,7 +1353,7 @@ static int f2fs_write_default_quota(int qtype, unsigned int blkaddr, return 0; } -static int f2fs_write_qf_inode(int qtype) +static int f2fs_write_qf_inode(int qtype, int offset) { struct f2fs_node *raw_node = NULL; u_int64_t data_blk_nor; @@ -1382,11 +1375,9 @@ static int f2fs_write_qf_inode(int qtype) raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA(qtype)); data_blk_nor = get_sb(main_blkaddr) + - c.cur_seg[CURSEG_HOT_DATA] * c.blks_per_seg + 1; + c.cur_seg[CURSEG_HOT_DATA] * c.blks_per_seg + 1 + + offset * QUOTA_DATA(i); - 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) @@ -1408,7 +1399,7 @@ static int f2fs_write_qf_inode(int qtype) main_area_node_seg_blk_offset = get_sb(main_blkaddr); main_area_node_seg_blk_offset += c.cur_seg[CURSEG_HOT_NODE] * - c.blks_per_seg + qtype + 1; + c.blks_per_seg + offset + 1; DBG(1, "\tWriting quota inode (hot node), %x %x %x at offset 0x%08"PRIu64"\n", get_sb(main_blkaddr), @@ -1440,7 +1431,7 @@ static int f2fs_update_nat_root(void) /* update quota */ for (qtype = i = 0; qtype < F2FS_MAX_QUOTAS; qtype++) { - if (sb->qf_ino[qtype] == 0) + if (!((1 << qtype) & c.quota_bits)) continue; nat_blk->entries[sb->qf_ino[qtype]].block_addr = cpu_to_le32(get_sb(main_blkaddr) + @@ -1678,7 +1669,7 @@ static int f2fs_add_default_dentry_root(void) static int f2fs_create_root_dir(void) { enum quota_type qtype; - int err = 0; + int err = 0, i = 0; err = f2fs_write_root_inode(); if (err < 0) { @@ -1687,9 +1678,9 @@ static int f2fs_create_root_dir(void) } for (qtype = 0; qtype < F2FS_MAX_QUOTAS; qtype++) { - if (sb->qf_ino[qtype] == 0) + if (!((1 << qtype) & c.quota_bits)) continue; - err = f2fs_write_qf_inode(qtype); + err = f2fs_write_qf_inode(qtype, i++); if (err < 0) { MSG(1, "\tError: Failed to write quota inode!!!\n"); goto exit; diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index b89efe691a49..8d4dbe1a28b1 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -28,6 +28,7 @@ #endif #include "f2fs_fs.h" +#include "quota.h" #include "f2fs_format_utils.h" #ifdef WITH_ANDROID @@ -127,9 +128,17 @@ static void add_default_options(void) c.feature |= cpu_to_le32(F2FS_FEATURE_CASEFOLD); #endif #ifdef CONF_PROJID + c.feature |= cpu_to_le32(F2FS_FEATURE_QUOTA_INO); c.feature |= cpu_to_le32(F2FS_FEATURE_PRJQUOTA); c.feature |= cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR); #endif + + if (c.feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) + c.quota_bits = QUOTA_USR_BIT | QUOTA_GRP_BIT; + if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) { + c.feature |= cpu_to_le32(F2FS_FEATURE_QUOTA_INO); + c.quota_bits |= QUOTA_PRJ_BIT; + } } static void f2fs_parse_options(int argc, char *argv[]) -- 2.34.1.703.g22d0c6ccf7-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel