linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Czerner <lczerner@redhat.com>
To: hughd@google.com, linux-mm@kvack.org
Cc: linux-fsdevel@vger.kernel.org
Subject: unusual behavior of loop dev with backing file in tmpfs
Date: Fri, 26 Nov 2021 08:51:00 +0100	[thread overview]
Message-ID: <20211126075100.gd64odg2bcptiqeb@work> (raw)

Hello,

I've noticed unusual test failure in e2fsprogs testsuite
(m_assume_storage_prezeroed) where we use mke2fs to create a file system
on loop device backed in file on tmpfs. For some reason sometimes the
resulting file number of allocated blocks (stat -c '%b' /tmp/file) differs,
but it really should not.

I was trying to create a simplified reproducer and noticed the following
behavior on mainline kernel (v5.16-rc2-54-g5d9f4cf36721)

# truncate -s16M /tmp/file
# stat -c '%b' /tmp/file
0

# losetup -f /tmp/file
# stat -c '%b' /tmp/file
672

That alone is a little unexpected since the file is really supposed to
be empty and when copied out of the tmpfs, it really is empty. But the
following is even more weird.

We have a loop setup from above, so let's assume it's /dev/loop0. The
following should be executed in quick succession, like in a script.

# dd if=/dev/zero of=/dev/loop0 bs=4k
# blkdiscard -f /dev/loop0
# stat -c '%b' /tmp/file
0
# sleep 1
# stat -c '%b' /tmp/file
672

Is that expected behavior ? From what I've seen when I use mkfs instead
of this simplified example the number of blocks allocated as reported by
stat can vary a quite a lot given more complex operations. The file itself
does not seem to be corrupted in any way, so it is likely just an
accounting problem.

Any idea what is going on there ?

Thanks!
-Lukas



             reply	other threads:[~2021-11-26  7:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-26  7:51 Lukas Czerner [this message]
2022-01-12  4:28 ` unusual behavior of loop dev with backing file in tmpfs Hugh Dickins
2022-01-12 12:29   ` Mikulas Patocka
2022-01-12 17:19   ` Darrick J. Wong
2022-01-12 17:46     ` Matthew Wilcox

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=20211126075100.gd64odg2bcptiqeb@work \
    --to=lczerner@redhat.com \
    --cc=hughd@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.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
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).