提交 74a8a65c 编写于 作者: D David Gibson 提交者: Linus Torvalds

[PATCH] Fix hugetlbfs_statfs() reporting of block limits

Currently, if a hugetlbfs is mounted without limits (the default), statfs()
will return -1 for max/free/used blocks.  This does not appear to be in
line with normal convention: simple_statfs() and shmem_statfs() both return
0 in similar cases.  Worse, it confuses the translation logic in
put_compat_statfs(), causing it to return -EOVERFLOW on such a mount.

This patch alters hugetlbfs_statfs() to return 0 for max/free/used blocks
on a mount without limits.  Note that we need the test in the patch below,
rather than just using 0 in the sbinfo structure, because the -1 marked in
the free blocks field is used internally to tell the
Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 86e07ce7
...@@ -512,10 +512,14 @@ static int hugetlbfs_statfs(struct super_block *sb, struct kstatfs *buf) ...@@ -512,10 +512,14 @@ static int hugetlbfs_statfs(struct super_block *sb, struct kstatfs *buf)
buf->f_bsize = HPAGE_SIZE; buf->f_bsize = HPAGE_SIZE;
if (sbinfo) { if (sbinfo) {
spin_lock(&sbinfo->stat_lock); spin_lock(&sbinfo->stat_lock);
buf->f_blocks = sbinfo->max_blocks; /* If no limits set, just report 0 for max/free/used
buf->f_bavail = buf->f_bfree = sbinfo->free_blocks; * blocks, like simple_statfs() */
buf->f_files = sbinfo->max_inodes; if (sbinfo->max_blocks >= 0) {
buf->f_ffree = sbinfo->free_inodes; buf->f_blocks = sbinfo->max_blocks;
buf->f_bavail = buf->f_bfree = sbinfo->free_blocks;
buf->f_files = sbinfo->max_inodes;
buf->f_ffree = sbinfo->free_inodes;
}
spin_unlock(&sbinfo->stat_lock); spin_unlock(&sbinfo->stat_lock);
} }
buf->f_namelen = NAME_MAX; buf->f_namelen = NAME_MAX;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册