Skip to contentSkip to conversation

ocfs2: use correct endian in ocfs2_dinode_has_extents

PATCH Applied Joseph Qi 2 participants 4 messages Oct 25, 2025 – Oct 27, 2025 OCFS2

lore
Share & tools
lore

Joseph Qi

author maintainer
#0 lore raw

PATCH 1/2 ocfs2: use correct endian in ocfs2_dinode_has_extents

Fields in ocfs2_dinode is little endian, covert to host endian when checking those contents.

Fixes fdbb6cd96ed5 ("ocfs2: correct l_next_free_rec in online check")
---
 fs/ocfs2/inode.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
fs/ocfs2/inode.c +6 -4
index fcc89856ab95..0a0a96054bfe 100644
@@ -201,13 +201,15 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
 static int ocfs2_dinode_has_extents(struct ocfs2_dinode *di)
 {
 	/* inodes flagged with other stuff in id2 */
-	if (di->i_flags & (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL |
-			   OCFS2_CHAIN_FL | OCFS2_DEALLOC_FL))
+	if (le32_to_cpu(di->i_flags) &
+	    (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL | OCFS2_CHAIN_FL |
+	     OCFS2_DEALLOC_FL))
 		return 0;
 	/* i_flags doesn't indicate when id2 is a fast symlink */
-	if (S_ISLNK(di->i_mode) && di->i_size && di->i_clusters == 0)
+	if (S_ISLNK(le16_to_cpu(di->i_mode)) && le64_to_cpu(di->i_size) &&
+	    !le32_to_cpu(di->i_clusters))
 		return 0;
-	if (di->i_dyn_features & OCFS2_INLINE_DATA_FL)
+	if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL)
 		return 0;
 
 	return 1;
Signature · 1 line
2.39.3
author maintainer
#1 lore raw

PATCH 2/2 ocfs2: convert to host endian in ocfs2_validate_inode_block

Convert to host endian when checking OCFS2_VALID_FL to keep consistent with other checks.

---
 fs/ocfs2/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/inode.c +1 -1
index 0a0a96054bfe..dc4044a565b5 100644
@@ -1481,7 +1481,7 @@ int ocfs2_validate_inode_block(struct super_block *sb,
 		goto bail;
 	}
 
-	if (!(di->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
+	if (!(le32_to_cpu(di->i_flags) & OCFS2_VALID_FL)) {
 		rc = ocfs2_error(sb,
 				 "Invalid dinode #%llu: OCFS2_VALID_FL not set\n",
 				 (unsigned long long)bh->b_blocknr);
Signature · 1 line
2.39.3
reviewer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] ocfs2: convert to host endian in ocfs2_validate_inode_block

Quoted 4 lines · Joseph Qi

Convert to host endian when checking OCFS2_VALID_FL to keep consistent with other checks.

Quoted 20 lines
---
 fs/ocfs2/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/inode.c +1 -1
index 0a0a96054bfe..dc4044a565b5 100644
@@ -1481,7 +1481,7 @@ int ocfs2_validate_inode_block(struct super_block *sb,
 		goto bail;
 	}
 
-	if (!(di->i_flags & cpu_to_le32(OCFS2_VALID_FL))) {
+	if (!(le32_to_cpu(di->i_flags) & OCFS2_VALID_FL)) {
 		rc = ocfs2_error(sb,
 				 "Invalid dinode #%llu: OCFS2_VALID_FL not set\n",
 				 (unsigned long long)bh->b_blocknr);
Signature · 1 line
2.39.3
reviewer Reviewed-by on v1 1/2
#3 lore raw
In reply to Joseph Qi
Quoted 5 lines · Joseph Qi

Fields in ocfs2_dinode is little endian, covert to host endian when checking those contents.

Fixes fdbb6cd96ed5 ("ocfs2: correct l_next_free_rec in online check")
Quoted 31 lines
---
 fs/ocfs2/inode.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
fs/ocfs2/inode.c +6 -4
index fcc89856ab95..0a0a96054bfe 100644
@@ -201,13 +201,15 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,
 static int ocfs2_dinode_has_extents(struct ocfs2_dinode *di)
 {
 	/* inodes flagged with other stuff in id2 */
-	if (di->i_flags & (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL |
-			   OCFS2_CHAIN_FL | OCFS2_DEALLOC_FL))
+	if (le32_to_cpu(di->i_flags) &
+	    (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL | OCFS2_CHAIN_FL |
+	     OCFS2_DEALLOC_FL))
 		return 0;
 	/* i_flags doesn't indicate when id2 is a fast symlink */
-	if (S_ISLNK(di->i_mode) && di->i_size && di->i_clusters == 0)
+	if (S_ISLNK(le16_to_cpu(di->i_mode)) && le64_to_cpu(di->i_size) &&
+	    !le32_to_cpu(di->i_clusters))
 		return 0;
-	if (di->i_dyn_features & OCFS2_INLINE_DATA_FL)
+	if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL)
 		return 0;
 
 	return 1;
Signature · 1 line
2.39.3