lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 22 Jul 2022 15:55:37 -0700
From:   Mike Kravetz <mike.kravetz@...cle.com>
To:     Miaohe Lin <linmiaohe@...wei.com>
Cc:     akpm@...ux-foundation.org, songmuchun@...edance.com,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 5/5] hugetlbfs: fix confusing hugetlbfs stat

On 07/22/22 14:38, Miaohe Lin wrote:
> On 2022/7/22 8:28, Mike Kravetz wrote:
> > 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
> 
> From the standard statvfs() function.
> 
> > for sbinfo->spool was supposed to handle these cases.  Seems like it
> 
> sbinfo->spool could be created when ctx->max_hpages == -1 while
> ctx->min_hpages != -1 in hugetlbfs_fill_super.
> 
> > 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.

Thanks for the additional information (and test program)!

>From the hugetlbfs documentation:
"If the ``size``, ``min_size`` or ``nr_inodes`` option is not provided on
 command line then no limits are set."

So, having those values set to -1 indicates there is no limit set.

With this change, 0 is reported for the case where there is no limit set as
well as the case where the max value is 0.

There may be some value in reporting -1 as is done today.

To be honest, I am not sure what is the correct behavior here.  Unless
there is a user visible issue/problem, I am hesitant to change.  Other
opinions are welcome.
-- 
Mike Kravetz

> 
> I wrote a test program:
> 
> #include <sys/statvfs.h>
> #include <stdio.h>
> 
> int main(void)
> {
> 	struct statvfs buf;
> 
> 	if (statvfs("/root/huge/", &buf) == -1) {
>  		printf("statvfs() error\n");
> 		return -1;
> 	}
> 	printf("f_blocks %lld, f_bavail %lld, f_bfree %lld, f_files %lld, f_ffree %lld\n",
> 		buf.f_blocks, buf.f_bavail, buf.f_bfree, buf.f_files, buf.f_ffree);
> 	return 0;
> }
> 
> And test it in my env:
> [root@...alhost ~]# mount -t hugetlbfs none /root/huge/
> [root@...alhost ~]# ./stat
> f_blocks 0, f_bavail 0, f_bfree 0, f_files 0, f_ffree 0
> [root@...alhost ~]# umount /root/huge/
> [root@...alhost ~]# mount -t hugetlbfs -o min_size=32M none /root/huge/
> [root@...alhost ~]# ./stat
> f_blocks -1, f_bavail -1, f_bfree -1, f_files -1, f_ffree -1
> [root@...alhost ~]# umount /root/huge/
> [root@...alhost ~]# mount -t hugetlbfs -o min_size=32M,size=64M none /root/huge/
> [root@...alhost ~]# ./stat
> f_blocks 32, f_bavail 32, f_bfree 32, f_files -1, f_ffree -1
> [root@...alhost ~]# umount /root/huge/
> [root@...alhost ~]# mount -t hugetlbfs -o min_size=32M,size=64M,nr_inodes=1024 none /root/huge/
> [root@...alhost ~]# ./stat
> f_blocks 32, f_bavail 32, f_bfree 32, f_files 1024, f_ffree 1023
> [root@...alhost ~]# umount /root/huge/
> 
> Or am I miss something?
> 
> > 
> 
> Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ