From: Mike Kravetz <mike.kravetz@oracle.com>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: akpm@linux-foundation.org, songmuchun@bytedance.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] hugetlbfs: fix confusing hugetlbfs stat
Date: Thu, 21 Jul 2022 17:28:04 -0700 [thread overview]
Message-ID: <YtnvFBn8tSm7y/mV@monkey> (raw)
In-Reply-To: <20220721131637.6306-6-linmiaohe@huawei.com>
On 07/21/22 21:16, Miaohe Lin wrote:
> When size option is not specified, f_blocks, f_bavail and f_bfree will be
> set to -1 instead of 0. Likewise, when nr_inodes is not specified, f_files
> and f_ffree will be set to -1 too. Check max_hpages and max_inodes against
> -1 first to make sure 0 is reported for max/free/used when no limit is set
> as the comment states.
Just curious, where are you seeing values reported as -1? The check
for sbinfo->spool was supposed to handle these cases. Seems like it
should handle the max_hpages == -1 case. But, it doesn't look like it
considers the max_inodes == -1 case.
If I create/mount a hugetlb filesystem without specifying size or nr_inodes,
df seems to report zero instead of -1.
Just want to understand the reasoning behind the change.
--
Mike Kravetz
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
> fs/hugetlbfs/inode.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 19fc62a9c2fe..44da9828e171 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -1083,16 +1083,20 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)
> /* If no limits set, just report 0 for max/free/used
> * blocks, like simple_statfs() */
> if (sbinfo->spool) {
> - long free_pages;
> -
> spin_lock_irq(&sbinfo->spool->lock);
> - buf->f_blocks = sbinfo->spool->max_hpages;
> - free_pages = sbinfo->spool->max_hpages
> - - sbinfo->spool->used_hpages;
> - buf->f_bavail = buf->f_bfree = free_pages;
> + if (sbinfo->spool->max_hpages != -1) {
> + long free_pages;
> +
> + buf->f_blocks = sbinfo->spool->max_hpages;
> + free_pages = sbinfo->spool->max_hpages
> + - sbinfo->spool->used_hpages;
> + buf->f_bavail = buf->f_bfree = free_pages;
> + }
> spin_unlock_irq(&sbinfo->spool->lock);
> - buf->f_files = sbinfo->max_inodes;
> - buf->f_ffree = sbinfo->free_inodes;
> + if (sbinfo->max_inodes != -1) {
> + buf->f_files = sbinfo->max_inodes;
> + buf->f_ffree = sbinfo->free_inodes;
> + }
> }
> spin_unlock(&sbinfo->stat_lock);
> }
> --
> 2.23.0
>
next prev parent reply other threads:[~2022-07-22 0:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 13:16 [PATCH 0/5] A few cleanup and fixup patches for hugetlbfs Miaohe Lin
2022-07-21 13:16 ` [PATCH 1/5] hugetlbfs: use helper macro SZ_1{K,M} Miaohe Lin
2022-07-21 23:13 ` Mike Kravetz
2022-07-21 13:16 ` [PATCH 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration Miaohe Lin
2022-07-21 23:14 ` Mike Kravetz
2022-07-21 13:16 ` [PATCH 3/5] hugetlbfs: remove unneeded header file Miaohe Lin
2022-07-21 23:18 ` Mike Kravetz
2022-07-22 6:12 ` Miaohe Lin
2022-07-21 13:16 ` [PATCH 4/5] hugetlbfs: cleanup some comments in inode.c Miaohe Lin
2022-07-21 23:23 ` Mike Kravetz
2022-07-22 6:19 ` Miaohe Lin
2022-07-22 21:38 ` Mike Kravetz
2022-07-21 13:16 ` [PATCH 5/5] hugetlbfs: fix confusing hugetlbfs stat Miaohe Lin
2022-07-22 0:28 ` Mike Kravetz [this message]
2022-07-22 6:38 ` Miaohe Lin
2022-07-22 22:55 ` Mike Kravetz
2022-07-23 2:56 ` Miaohe Lin
2022-07-25 23:40 ` Mike Kravetz
2022-07-26 2:01 ` Miaohe Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YtnvFBn8tSm7y/mV@monkey \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=songmuchun@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox