From: Jan Kara <jack@suse.cz>
To: Akshay Nehe <akshaynehe785@gmail.com>
Cc: Jan Kara <jack@suse.cz>, linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: Required help for understanding ext4 block allocation
Date: Thu, 22 Mar 2012 15:11:55 +0100 [thread overview]
Message-ID: <20120322141155.GB19587@quack.suse.cz> (raw)
In-Reply-To: <CA+tw96C9kRHYhiQoyRRH8U_gPtcXZimJL0=kHBX4m7dLrXwaPg@mail.gmail.com>
Hello,
On Thu 22-03-12 18:54:26, Akshay Nehe wrote:
> Yes, i got extents as you have suggested, but one thing i found that
> each time modification occurs on any file from ext4 file system then
> kernel deallocates all current blocks and allocate new blocks and
> write modified data on newly allocated blocks.
That is not true. Why do you think it is? Maybe you are modifying the
file with something like a text editor? That certainly truncates the old
file and writes a new one. But generally ext4 supports overwriting.
> So by tracing kernel code i got some useful functions, for
> deallocation: ext4_free_blocks, for allocation: ext4_map_blocks, but
> found difficult to analyse each of them. Can anyone suggest correct
> functions which actually dose allocation and deallocation?
Ext4 uses multiblock allocator which is in fs/ext4/mballoc.c. In
particular function allocating blocks in ext4_mb_new_blocks(), function
freeing blocks is ext4_free_blocks(). But you will need to understand most
of mballoc.c to understand how mballoc works. You can read comments in the
beginning of the file to understand some basics about mballoc. You can
also read some basics from by presentation about ext4 at Linux Kongress in
2009 (http://www.linux-kongress.org/2009/slides/ext4+btrfs_jan_kara.pdf).
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2012-03-22 14:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 13:18 Required help for understanding ext4 block allocation Akshay Nehe
2012-03-16 9:18 ` Jan Kara
2012-03-22 13:24 ` Akshay Nehe
2012-03-22 14:11 ` Jan Kara [this message]
2012-03-22 15:22 ` Akshay Nehe
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=20120322141155.GB19587@quack.suse.cz \
--to=jack@suse.cz \
--cc=akshaynehe785@gmail.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