Skip to contentSkip to conversation

erofs: fix misbehavior of unsupported chunk format check

PATCH In review Gao Xiang 4 participants 4 messages Sep 22, 2021 – Sep 23, 2021 EROFS file system

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs: fix misbehavior of unsupported chunk format check

Unsupported chunk format should be checked with
"if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)"

Found when checking with 4k-byte blockmap (although currently mkfs uses inode chunk indexes format by default.)

Fixes c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
Cc Liu Bo <[email protected]>
Cc Chao Yu <[email protected]>
---
 fs/erofs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/inode.c +1 -1
index 31ac3a7..a552399 100644
@@ -176,7 +176,7 @@ static struct page *erofs_read_inode(struct inode *inode,
 	}
 
 	if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
-		if (!(vi->chunkformat & EROFS_CHUNK_FORMAT_ALL)) {
+		if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL) {
 			erofs_err(inode->i_sb,
 				  "unsupported chunk format %x of nid %llu",
 				  vi->chunkformat, vi->nid);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Gao Xiang

Unsupported chunk format should be checked with
"if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)"

Found when checking with 4k-byte blockmap (although currently mkfs uses inode chunk indexes format by default.)

Good catch.

thanks,
liubo

Quoted 23 lines
Fixes c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
Cc Liu Bo <[email protected]>
Cc Chao Yu <[email protected]>
---
 fs/erofs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/inode.c +1 -1
index 31ac3a7..a552399 100644
@@ -176,7 +176,7 @@ static struct page *erofs_read_inode(struct inode *inode,
 	}
 
 	if (vi->datalayout == EROFS_INODE_CHUNK_BASED) {
-		if (!(vi->chunkformat & EROFS_CHUNK_FORMAT_ALL)) {
+		if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL) {
 			erofs_err(inode->i_sb,
 				  "unsupported chunk format %x of nid %llu",
 				  vi->chunkformat, vi->nid);
Signature · 1 line
1.8.3.1
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Gao Xiang
Quoted 4 lines · Gao Xiang

Unsupported chunk format should be checked with
"if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)"

Found when checking with 4k-byte blockmap (although currently mkfs

That means for 4k-byte blockmap, chunkformat should be zero, right?

Quoted 6 lines

uses inode chunk indexes format by default.)

Fixes c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
Cc Liu Bo <[email protected]>
Cc Chao Yu <[email protected]>

Thanks,

maintainer
#3 lore raw
Quoted 7 lines · Chao Yu
Quoted 4 lines · Gao Xiang

Unsupported chunk format should be checked with
"if (vi->chunkformat & ~EROFS_CHUNK_FORMAT_ALL)"

Found when checking with 4k-byte blockmap (although currently mkfs

That means for 4k-byte blockmap, chunkformat should be zero, right?

Yeah, correct. It's a regression of 4kb chunk blockmap..

Quoted 9 lines
Quoted 7 lines

uses inode chunk indexes format by default.)

Fixes c5aa903a59db ("erofs: support reading chunk-based uncompressed files")
Cc Liu Bo <[email protected]>
Cc Chao Yu <[email protected]>

Thanks!

Thanks,
Gao Xiang

Quoted 2 lines

Thanks,