Skip to contentSkip to conversation

hugetlbfs: report inode limits without a memory subpool

PATCH In review Hungyu Lin 3 participants 3 messages Nov 11 – Nov 16

Subsystems (3)
lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

PATCH v2 1/1 hugetlbfs: report inode limits without a memory subpool

A hugetlbfs mount can limit inodes with nr_inodes independently of size or min_size. hugetlbfs_statfs() only fills f_files and f_ffree when a memory subpool exists, so an inode-only limit is enforced but its inode counts are reported as zero.

For example, a fresh mount with nr_inodes=4 reports zero total and free inodes instead of 4 and 3. This hides the inode limit from tools such as df -i, even when creating another file fails with ENOSPC.

Report the inode counters when an inode limit is configured, independently of the memory subpool. Preserve the existing zero and -1 results for unlimited inode counts.

Fixes 74a8a65c5261 ("[PATCH] Fix hugetlbfs_statfs() reporting of block limits")

---
Changes in v2:
- Add Aveline Noir's Reviewed-by and Tested-by.

v1: https://lore.kernel.org/r/[email protected]

 fs/hugetlbfs/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/hugetlbfs/inode.c +2 -0
index 01c4d6f44ebe..e94ee8e17004 100644
@@ -1113,6 +1113,8 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 				- sbinfo->spool->used_hpages;
 			buf->f_bavail = buf->f_bfree = free_pages;
 			spin_unlock_irq(&sbinfo->spool->lock);
+		}
+		if (sbinfo->spool || sbinfo->max_inodes >= 0) {
 			buf->f_files = sbinfo->max_inodes;
 			buf->f_ffree = sbinfo->free_inodes;
 		}
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Hungyu Lin

A hugetlbfs mount can limit inodes with nr_inodes independently of size or min_size. hugetlbfs_statfs() only fills f_files and f_ffree when a memory subpool exists, so an inode-only limit is enforced but its inode counts are reported as zero.

For example, a fresh mount with nr_inodes=4 reports zero total and free inodes instead of 4 and 3. This hides the inode limit from tools such as df -i, even when creating another file fails with ENOSPC.

Quoted 8 lines

Report the inode counters when an inode limit is configured, independently of the memory subpool. Preserve the existing zero and -1 results for unlimited inode counts.

Fixes 74a8a65c5261 ("[PATCH] Fix hugetlbfs_statfs() reporting of block limits")

LGTM:

Signature · 2 lines
cheers,
jose a. p-a
Acked-by on v2 1/1
#2 lore raw
In reply to Hungyu Lin
Quoted 9 lines · Hungyu Lin

A hugetlbfs mount can limit inodes with nr_inodes independently of size or min_size. hugetlbfs_statfs() only fills f_files and f_ffree when a memory subpool exists, so an inode-only limit is enforced but its inode counts are reported as zero.

For example, a fresh mount with nr_inodes=4 reports zero total and free inodes instead of 4 and 3. This hides the inode limit from tools such as df -i, even when creating another file fails with ENOSPC.

Quoted 8 lines

Report the inode counters when an inode limit is configured, independently of the memory subpool. Preserve the existing zero and -1 results for unlimited inode counts.

Fixes 74a8a65c5261 ("[PATCH] Fix hugetlbfs_statfs() reporting of block limits")
Signature · 2 lines
Oscar Salvador
SUSE Labs