linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiaying Zhang <jiayingz@google.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: use vmtruncate() instead of ext4_truncate() in ext4_setattr()
Date: Wed, 18 May 2011 13:38:20 -0700	[thread overview]
Message-ID: <BANLkTi=-mHcK529AC=s3aVfEEjoF7Rx-rg@mail.gmail.com> (raw)
In-Reply-To: <4DD42CA1.8050700@redhat.com>

On Wed, May 18, 2011 at 1:31 PM, Eric Sandeen <sandeen@redhat.com> wrote:
> On 5/18/11 3:28 PM, Jiaying Zhang wrote:
>>
>>
>> On Tue, May 17, 2011 at 8:19 PM, Eric Sandeen <sandeen@redhat.com <mailto:sandeen@redhat.com>> wrote:
>>
>>     On 5/17/11 5:59 PM, Jiaying Zhang wrote:
>>     > There is a bug in commit c8d46e41 "ext4: Add flag to files with blocks
>>     > intentionally past EOF" that if we fallocate a file with FALLOC_FL_KEEP_SIZE
>>     > flag and then ftruncate the file to a size larger than the file's i_size,
>>     > any allocated but unwritten blocks will be freed but the file size is set
>>     > to the size that ftruncate specifies.
>>     >
>>     > Here is a simple test to reproduce the problem:
>>     >   1. fallocate a 12k size file with KEEP_SIZE flag
>>     >   2. write the first 4k
>>     >   3. ftruncate the file to 8k
>>     > Then 'ls -l' shows that the i_size of the file becomes 8k but debugfs
>>     > shows the file has only the first written block left.
>>
>>     To be honest I'm not 100% certain what the fiesystem -should- do in this case.
>>
>>     If I go through that same sequence on xfs, I get 4k written / 8k unwritten:
>>
>>     # xfs_bmap -vp testfile
>>     testfile:
>>      EXT: FILE-OFFSET      BLOCK-RANGE            AG AG-OFFSET              TOTAL FLAGS
>>       0: [0..7]:          2648750760..2648750767  3 (356066400..356066407)     8 00000
>>       1: [8..23]:         2648750768..2648750783  3 (356066408..356066423)    16 10000
>>
>>     size 8k:
>>     # ls -l testfile
>>     -rw-r--r-- 1 root root 8192 May 17 22:33 testfile
>>
>>     and diskspace used 12k:
>>     # du -hc testfile
>>     12K     testfile
>>     12K     total
>>
>>     I think this is a different result from ext4, either with or without your patch.
>>
>>     On ext4 I get size 8k, but only the first 4k mapped, as you say.
>>
>> I agree that truncating to a size larger than i_size is un-specified by
>> POSIX. However, I think the problem with the current behavior is that
>> we have an inconsistency between file's i_size and its extent tree.
>> Now we have 8k i_size but the file has only 4k space allocated. That
>> can confuse applications.
>
> That's called "a sparse file" right?  Apps should not be confused by that ...
But applications don't intend to create a sparse file in this case. They may
create a lot of such files in this way with 'df' showing there is
still plenty of
free space available but as they start writing to these files they will fill up
space and get ENOSPC unexpectedly.

Jiaying
>
> -Eric
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-05-18 20:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17 22:59 [PATCH] ext4: use vmtruncate() instead of ext4_truncate() in ext4_setattr() Jiaying Zhang
2011-05-18  2:46 ` Yongqiang Yang
2011-05-18  2:56 ` Yongqiang Yang
2011-05-18  3:27   ` Yongqiang Yang
2011-05-18  3:19 ` Eric Sandeen
2011-05-18  5:35   ` Andreas Dilger
2011-05-18 20:32     ` Jiaying Zhang
2011-05-18 20:45       ` Andreas Dilger
2011-05-18 20:57         ` Jiaying Zhang
2011-05-18  6:13   ` Dave Chinner
2011-05-18 14:05     ` Eric Sandeen
2011-05-18 20:42     ` Jiaying Zhang
2011-05-18 20:29   ` Jiaying Zhang
     [not found]   ` <BANLkTi=Yv_q820aHFa2wkCL-PnYNcZdWCQ@mail.gmail.com>
2011-05-18 20:31     ` Eric Sandeen
2011-05-18 20:38       ` Jiaying Zhang [this message]
2011-05-22 23:56 ` Ted Ts'o
2011-05-23 18:30   ` Jiaying Zhang
2011-05-23 19:19     ` [PATCH -v2] ext4: use truncate_setsize() unconditionally Theodore Ts'o
2011-05-23 20:22       ` Jiaying Zhang
2011-05-24 14:30       ` Eric Sandeen
2011-05-24 22:06         ` Jiaying Zhang
2011-05-24 22:31           ` Eric Sandeen

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='BANLkTi=-mHcK529AC=s3aVfEEjoF7Rx-rg@mail.gmail.com' \
    --to=jiayingz@google.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=tytso@mit.edu \
    /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).