linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ji Wu <wu_ji2012@163.com>
To: linux-ext4@vger.kernel.org
Subject: Two questions regarding ext4_fallocate()
Date: Sat, 04 May 2013 23:31:42 +0800	[thread overview]
Message-ID: <518529DE.4080302@163.com> (raw)

Hi,
    I have two questions regarding ext4_fallocate(),

    (1) The first is the FALLOC_FL_PUNCH_HOLE support, I am wondering
what is the usage for it? The only use case comes to my mind is while 
ext4 being
used for virtual machine image file storage. When VMM is aware of the 
file deleting
operation in guest os, it can invoke host file system's fallocate() on 
the virtual machine
image file to punch a hole to free host storage, so that save host 
space. But how can VMM being
aware of guest file deleting? Simulate a virtual SSD-like block device 
to guest os,
then capture the TRIM instruction issued by guest file system? That 
seems too tricky.
So basically, where and how to benefit from hole punching?

    (2) At the beginning of the function ext4_ext_punch_hole(), the 
codes are as follows,

         /* write out all dirty pages to avoid race condition */
         filemap_write_and_wait_range(mapping, offset, offset+length-1);
         mutex_lock(&inode->i_mutex);
         truncate_page_cache_range();

     Why does it need synchronously write back the dirty pages fit into 
the hole,
     the data on the disk responding to those pages are to be deleted, 
why not directly
     release those pages, no matter they are dirty or not. And 
furthermore, this is done
     before the inode lock is held, so it seems it may happen that after 
the pages are written
     back, and before the lock is held, those pages are dirtied again.
     So basically, why does it need call filemap_write_and_wait_range() 
before releasing those pages?

Explanations are appreciated.

Cheers,
Ji Wu


             reply	other threads:[~2013-05-04 15:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-04 15:31 Ji Wu [this message]
     [not found] <5185222A.20801@163.com>
2013-05-04 17:33 ` Two questions regarding ext4_fallocate() Theodore Ts'o
2013-05-05  1:14   ` Ji Wu
2013-05-05  7:18   ` Dmitry Monakhov

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=518529DE.4080302@163.com \
    --to=wu_ji2012@163.com \
    --cc=linux-ext4@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
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).