From: Wang Sheng-Hui <shhuiw@gmail.com>
To: Allison Henderson <achender@linux.vnet.ibm.com>,
Lukas Czerner <lczerner@redhat.com>,
"Theodore Ts'o" <tytso@mit.edu>,
linux-ext4@vger.kernel.org
Subject: Question about extents.c/ext4_ext_punch_hole
Date: Sun, 15 Jul 2012 21:03:42 +0800 [thread overview]
Message-ID: <5002BFAE.9030408@gmail.com> (raw)
Dear all,
I'm reading the code of extents.c, and confused by the function "ext4_ext_punch_hole".
In my understanding, if we want to punch hole for the range (loff_t offset, loff_t length),
then we finally will get one hole block-size aligned, right?
[code in ext4_ext_punch_hole]
first_block = (offset + sb->s_blocksize - 1) >>
EXT4_BLOCK_SIZE_BITS(sb);
stop_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);
[code]
>From the code, we'll get one hole range contained in the range [offset, length+offset-1].
For example, we set the block size to 1K, and we specify the range [offset:1000, offset:2000].
Then we'll get first_block:1,stop_block:2, with some head/tail range ignored.
{-23------|===========|----952---}
1000 1024 2048 2999
offset offset+length-1
'==='means punched hole here.
Please correct me if I'm wrong.
Regards,
next reply other threads:[~2012-07-15 13:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-15 13:03 Wang Sheng-Hui [this message]
2012-07-16 6:36 ` Question about extents.c/ext4_ext_punch_hole Lukáš Czerner
2012-07-16 8:04 ` Wang Sheng-Hui
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=5002BFAE.9030408@gmail.com \
--to=shhuiw@gmail.com \
--cc=achender@linux.vnet.ibm.com \
--cc=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--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).