Skip to contentSkip to conversation

staging: erofs: change inode related info in erofs_statfs()

PATCH New Chengguang Xu 2 participants 2 messages Sep 24, 2018 – Sep 25, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: erofs: change inode related info in erofs_statfs()

As a read only filesystem, it's better to show available inode num as 0 in statfs.

Signed-off-by Chengguang Xu <cgxu519 at gmx.com>
---
 drivers/staging/erofs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/erofs/super.c +2 -2
index 51b076255988..6601a242071f 100644
@@ -627,8 +627,8 @@ static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_blocks = sbi->blocks;
 	buf->f_bfree = buf->f_bavail = 0;
 
-	buf->f_files = ULLONG_MAX;
-	buf->f_ffree = ULLONG_MAX - sbi->inos;
+	buf->f_files = sbi->inos;
+	buf->f_ffree = 0;
 
 	buf->f_namelen = EROFS_NAME_LEN;
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 staging: erofs: change inode related info in erofs_statfs()

Hi Chengguang,

Quoted 13 lines · Chengguang Xu

As a read only filesystem, it's better to show available inode num as 0 in statfs.

Signed-off-by Chengguang Xu <cgxu519 at gmx.com>
---
 drivers/staging/erofs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/erofs/super.c +0 -0
index 51b076255988..6601a242071f 100644

drivers/staging/erofs/super.c static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf) · line 630

Quoted 6 lines
drivers/staging/erofs/super.c +1 -2
@@ -627,8 +627,8 @@ static int erofs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_blocks = sbi->blocks;
 	buf->f_bfree = buf->f_bavail = 0;
 
-	buf->f_files = ULLONG_MAX;
-	buf->f_ffree = ULLONG_MAX - sbi->inos;
+	buf->f_files = sbi->inos;

For erofs, nid indicates the inode position rather than just a id, and it could not be continious.

The in-byte inode position is calculated by the following formula:
nid * 32(inode_v1) + meta_blkaddr * 4096

These two fields are defined as:

fsfilcnt_t    f_files    Total number of file serial numbers.
fsfilcnt_t    f_ffree    Total number of free file serial numbers.

I'm afraid if f_files == sbi->inos, the actual inode number (nid) could be larger than f_files. I have no idea whether it could give undefined behavior to user program...

Thanks,
Gao Xiang

Quoted 5 lines
drivers/staging/erofs/super.c +1 -0
+	buf->f_ffree = 0;
 
 	buf->f_namelen = EROFS_NAME_LEN;