Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2017 18:30:32 -0700
From:      Alan Somers <asomers@freebsd.org>
To:        Ngie Cooper <yaneurabeya@gmail.com>
Cc:        "Rodney W. Grimes" <freebsd-rwg@pdx.rh.cn85.dnsmgr.net>, Subbsd <subbsd@gmail.com>, Peter Jeremy <peter@rulingia.com>, freebsd-hackers <freebsd-hackers@freebsd.org>,  freebsd-current Current <freebsd-current@freebsd.org>
Subject:   Re: effect of strip(1) on du(1)
Message-ID:  <CAOtMX2hbvnDqBWry4GNX=9-1nqEgcF8PwFZLQS_EaX2nkZsPRQ@mail.gmail.com>
In-Reply-To: <CAGHfRMCVQdD4uULOPZsNxrrEZ%2BNAtJ6f1qMdSc8xtCHmwEfYMg@mail.gmail.com>
References:  <CAFt_eMom-C68Fo4NR8HVqPBUwKTKYUvCy2seXDg3hzOOU_f=Vw@mail.gmail.com> <201703030031.v230VvIl066398@pdx.rh.CN85.dnsmgr.net> <CAGHfRMCVQdD4uULOPZsNxrrEZ%2BNAtJ6f1qMdSc8xtCHmwEfYMg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Mar 2, 2017 at 6:12 PM, Ngie Cooper <yaneurabeya@gmail.com> wrote:
> On Thu, Mar 2, 2017 at 4:31 PM, Rodney W. Grimes
> <freebsd-rwg@pdx.rh.cn85.dnsmgr.net> wrote:
> ...
>> Even if that is the case file system cache effects should NOT be
>> visible to a userland process.   This is NOT as if your running
>> 2 different processing beating on a file.  Your test cases are
>> serialially syncronous shell invoked commands seperated with
>> && the results should be exact and predictable.
>>
>> When strip returns the operation from the userland perspecive
>> is completed and any and all processeses started after that
>> should have the view of the completed strip command.
>>
>> This IS a bug.
>
> Would the same statement necessarily apply if the filesystem was
> writing things asynchronously to the backing storage?
> Thanks,
> -Ngie

du(1) is using fts_read(3), which is based on the stat(2) information.
The OpenGroup defines st_blocksize as "Number of blocks allocated for
this object."  In the case of ZFS, a write(2) may return before any
blocks are actually allocated.  And thanks to compression, gang
blocks, and deduplication, at this point it's not even possible for
ZFS to know how many blocks it will need to allocate.  I think
st_blocksize should be interpreted as a "best effort" output.  Just
like df(1), you can't rely on du's output to be mathematically precise
in any way.  I certainly don't see any way to fix it besides doing
something like an fsync(2) before getting stat information, and we
certainly don't want to do that.

-Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2hbvnDqBWry4GNX=9-1nqEgcF8PwFZLQS_EaX2nkZsPRQ>