linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: kreijack@inwind.it, Chris Murphy <lists@colorremedies.com>
Cc: Piotr Szymaniak <szarpaj@grubelek.pl>,
	Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Subject: Re: btrfs fi du -s gives Inappropriate ioctl for device
Date: Fri, 18 Aug 2017 09:34:04 +0300	[thread overview]
Message-ID: <e965d461-7185-59ef-d025-d51a886aacb7@suse.com> (raw)
In-Reply-To: <9d24b092-6b03-8d97-b4bd-feb36e00b9e0@inwind.it>



On 17.08.2017 23:59, Goffredo Baroncelli wrote:
> Hi,
> 
> On 08/17/2017 08:43 PM, Chris Murphy wrote:
>> # btrfs sub create test1
>> Create subvolume './test1'
>> # btrfs sub create test1/test2
>> Create subvolume 'test1/test2'
>> # btrfs sub snap test1 test1.snap
>> Create a snapshot of 'test1' in './test1.snap'
>> # btrfs fi du -s test1
>>      Total   Exclusive  Set shared  Filename
>>      0.00B       0.00B       0.00B  test1
>> # btrfs fi du -s test1.snap
>>      Total   Exclusive  Set shared  Filename
>> ERROR: cannot check space of 'test1.snap': Inappropriate ioctl for device
>> #
>>
> 
> tanks for the test case. Now I was able to reproduce the problem. The bug(s) are two:
> 
> 1) to get the treeid of the files/directory, the function lookup_path_rootid() is used, which behaves strangely when it is called on a directory that is BTRFS_EMPTY_SUBVOL_DIR_OBJECTID. In fact this function is commented as following:
> [....]
> /*
>  * For a given:
>  * - file or directory return the containing tree root id
>  * - subvolume return its own tree id
>  * - BTRFS_EMPTY_SUBVOL_DIR_OBJECTID (directory with ino == 2) the result is
>  *   undefined and function returns -1
>  */
> int lookup_path_rootid(int fd, u64 *rootid)
> {
> [....]
> 
> The caller (du_add_file()) doesn't consider this case.
> 
> 2) in the function du_walk_dir(), an error returned by du_add_file() is ignored, but the return value is not reset. So if the last entry has ino BTRFS_EMPTY_SUBVOL_DIR_OBJECTID (directory with ino == 2) an error is returned. But if there is another directory item no error is returned !
> 
> See the following tests cases:
> 
> # btrfs sub create test1
> # btrfs sub create test1/test2
> # btrfs sub snap test1 test1.snap
> # btrfs fi du -s test1
>      Total   Exclusive  Set shared  Filename
>      0.00B       0.00B       0.00B  test1
> # btrfs fi du -s test1.snap
>      Total   Exclusive  Set shared  Filename
> ERROR: cannot check space of 'test1.snap': Inappropriate ioctl for device
> 
> But if you add *another* file/dir in test1.snap you got:
> 
> # mkdir test1.snap/dir
> # btrfs fi du -s test1.snap
>      Total   Exclusive  Set shared  Filename
>      0.00B       0.00B       0.00B  test1.snap
> 
> The error disappea> Patches will follow shortly

It would be awesome if you manage to introduce xfstests for this case

> 
>>
>> # uname -r
>> 4.13.0-0.rc4.git1.1.fc27.x86_64
>> # rpm -q btrfs-progs
>> btrfs-progs-4.12-1.fc27.x86_64
>>
>>
>> ----
>> Chris Murphy
>>
> 
> 

  reply	other threads:[~2017-08-18  6:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-14 22:57 btrfs fi du -s gives Inappropriate ioctl for device Piotr Szymaniak
2017-08-14 23:40 ` Chris Murphy
2017-08-16  9:27   ` Piotr Szymaniak
2017-08-17  0:23     ` Chris Murphy
2017-08-17 15:37 ` Goffredo Baroncelli
2017-08-17 18:43   ` Chris Murphy
2017-08-17 20:59     ` Goffredo Baroncelli
2017-08-18  6:34       ` Nikolay Borisov [this message]
2017-08-18  7:09         ` Goffredo Baroncelli
2017-08-18  7:12           ` Nikolay Borisov
2017-08-18  7:22             ` Goffredo Baroncelli
2017-08-18  8:38       ` Piotr Szymaniak

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=e965d461-7185-59ef-d025-d51a886aacb7@suse.com \
    --to=nborisov@suse.com \
    --cc=kreijack@inwind.it \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@colorremedies.com \
    --cc=szarpaj@grubelek.pl \
    /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;
as well as URLs for NNTP newsgroup(s).