Linux-Fsdevel Archive on lore.kernel.org
 help / color / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: udf: Suspicious values in udf_statfs()
Date: Thu, 16 Jan 2020 16:30:19 +0100
Message-ID: <20200116153019.5awize7ufnxtjagf@pali> (raw)
In-Reply-To: <20200113120851.GG23642@quack2.suse.cz>

On Monday 13 January 2020 13:08:51 Jan Kara wrote:
> Hello,
> 
> On Sun 12-01-20 17:23:11, Pali Rohár wrote:
> > I looked at udf_statfs() implementation and I see there two things which
> > are probably incorrect:
> > 
> > First one:
> > 
> > 	buf->f_blocks = sbi->s_partmaps[sbi->s_partition].s_partition_len;
> > 
> > If sbi->s_partition points to Metadata partition then reported number
> > of blocks seems to be incorrect. Similar like in udf_count_free().
> 
> Oh, right. This needs similar treatment like udf_count_free(). I'll fix it.
> Thanks for spotting.

Ok.

> > Second one:
> > 
> > 	buf->f_files = (lvidiu != NULL ? (le32_to_cpu(lvidiu->numFiles) +
> > 					  le32_to_cpu(lvidiu->numDirs)) : 0)
> > 			+ buf->f_bfree;
> > 
> > What f_files entry should report? Because result of sum of free blocks
> > and number of files+directories does not make sense for me.
> 
> This is related to the fact that we return 'f_bfree' as the number of 'free
> file nodes' in 'f_ffree'. And tools generally display f_files-f_ffree as
> number of used inodes. In other words we treat every free block also as a
> free 'inode' and report it in total amount of 'inodes'. I know this is not
> very obvious but IMHO it causes the least confusion to users reading df(1)
> output.

So current code which returns sum of free blocks and number of
files+directories is correct. Could be this information about statvfs
f_files somewhere documented? Because this is not really obvious nor for
userspace applications which use statvfs() nor for kernel filesystem
drivers.

-- 
Pali Rohár
pali.rohar@gmail.com

  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-12 16:23 Pali Rohár
2020-01-13 12:08 ` Jan Kara
2020-01-16 15:30   ` Pali Rohár [this message]
2020-01-17 11:38     ` Jan Kara
2020-01-17 22:35       ` Pali Rohár
2020-01-17 12:05   ` Jan Kara
2020-01-18  0:11     ` Pali Rohár
2020-01-20 13:02       ` Jan Kara

Reply instructions:

You may reply publically 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=20200116153019.5awize7ufnxtjagf@pali \
    --to=pali.rohar@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    /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

Linux-Fsdevel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fsdevel/0 linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ https://lore.kernel.org/linux-fsdevel \
		linux-fsdevel@vger.kernel.org
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fsdevel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git