This patch fixes some cases in where we missed to consider
endianness when we access/update inode.i_flags.

Signed-off-by: Chao Yu <[email protected]>
---
 fsck/fsck.c        |  9 +++++----
 fsck/node.c        |  2 +-
 include/f2fs_fs.h  | 12 ++++--------
 mkfs/f2fs_format.c |  2 +-
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 7400dcf..d9e5359 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -924,14 +924,14 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
                 * the node tree.  Thus, it must be fixed unconditionally
                 * in the memory (node_blk).
                 */
-               node_blk->i.i_flags &= ~cpu_to_le32(F2FS_COMPR_FL);
+               i_flags &= ~F2FS_COMPR_FL;
                compressed = false;
                if (c.fix_on) {
                        need_fix = 1;
                        FIX_MSG("[0x%x] i_flags=0x%x -> 0x%x",
-                                       nid, i_flags, node_blk->i.i_flags);
+                                       nid, node_blk->i.i_flags, i_flags);
                }
-               i_flags &= ~F2FS_COMPR_FL;
+               node_blk->i.i_flags = cpu_to_le32(i_flags);
        }
 check_next:
        memset(&child, 0, sizeof(child));
@@ -1057,7 +1057,8 @@ check_next:
                ASSERT_MSG("[0x%x] unexpected casefold flag", nid);
                if (c.fix_on) {
                        FIX_MSG("ino[0x%x] clear casefold flag", nid);
-                       node_blk->i.i_flags &= ~cpu_to_le32(F2FS_CASEFOLD_FL);
+                       i_flags &= ~F2FS_CASEFOLD_FL;
+                       node_blk->i.i_flags = cpu_to_le32(i_flags);
                        need_fix = 1;
                }
        }
diff --git a/fsck/node.c b/fsck/node.c
index 7ee29ac..632151a 100644
--- a/fsck/node.c
+++ b/fsck/node.c
@@ -62,7 +62,7 @@ int f2fs_rebuild_qf_inode(struct f2fs_sb_info *sbi, int qtype)
 
        raw_node->i.i_size = cpu_to_le64(1024 * 6);
        raw_node->i.i_blocks = cpu_to_le64(1);
-       raw_node->i.i_flags = F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL;
+       raw_node->i.i_flags = cpu_to_le32(F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL);
 
        if (is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
                cp_ver |= (cur_cp_crc(ckpt) << 32);
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 870a6e4..75cbf22 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -659,9 +659,11 @@ enum {
 /*
  * On-disk inode flags (f2fs_inode::i_flags)
  */
+#define F2FS_COMPR_FL                  0x00000004 /* Compress file */
+#define F2FS_NODUMP_FL                 0x00000040 /* do not dump file */
 #define F2FS_IMMUTABLE_FL              0x00000010 /* Immutable file */
 #define F2FS_NOATIME_FL                        0x00000080 /* do not update 
atime */
-
+#define F2FS_CASEFOLD_FL               0x40000000 /* Casefolded file */
 
 #define F2FS_ENC_UTF8_12_1     1
 #define F2FS_ENC_STRICT_MODE_FL        (1 << 0)
@@ -984,9 +986,7 @@ static_assert(sizeof(struct node_footer) == 24, "");
 
 #define file_is_encrypt(fi)      ((fi)->i_advise & FADVISE_ENCRYPT_BIT)
 #define file_enc_name(fi)        ((fi)->i_advise & FADVISE_ENC_NAME_BIT)
-
-#define F2FS_CASEFOLD_FL       0x40000000 /* Casefolded file */
-#define IS_CASEFOLDED(dir)     ((dir)->i_flags & F2FS_CASEFOLD_FL)
+#define IS_CASEFOLDED(dir)     ((dir)->i_flags & cpu_to_le32(F2FS_CASEFOLD_FL))
 
 /*
  * fsck i_compr_blocks counting helper
@@ -1003,10 +1003,6 @@ struct f2fs_compr_blk_cnt {
 };
 #define CHEADER_PGOFS_NONE ((u32)-(1 << MAX_COMPRESS_LOG_SIZE))
 
-/*
- * inode flags
- */
-#define F2FS_COMPR_FL          0x00000004 /* Compress file */
 /*
  * On disk layout is
  * struct f2fs_inode
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index c9d335a..39d2d3e 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -1414,7 +1414,7 @@ static int f2fs_write_qf_inode(int qtype)
 
        raw_node->i.i_size = cpu_to_le64(1024 * 6);
        raw_node->i.i_blocks = cpu_to_le64(1 + QUOTA_DATA);
-       raw_node->i.i_flags = F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL;
+       raw_node->i.i_flags = cpu_to_le32(F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL);
 
        node_blkaddr = alloc_next_free_block(CURSEG_HOT_NODE);
        F2FS_NODE_FOOTER(raw_node)->next_blkaddr = cpu_to_le32(node_blkaddr + 
1);
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to