linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ted Ts'o <tytso@mit.edu>
To: Kazuya Mio <k-mio@sx.jp.nec.com>
Cc: ext4 <linux-ext4@vger.kernel.org>
Subject: Re: ext4: Fix 32bit overflow in ext4_ext_find_goal()
Date: Sun, 2 Jan 2011 16:40:31 -0500	[thread overview]
Message-ID: <20110102214031.GA10889@thunk.org> (raw)
In-Reply-To: <4D05B132.3060402@sx.jp.nec.com>

On Sun, Dec 12, 2010 at 07:37:54PM -0000, Kazuya Mio wrote:
> Hi,
> 
> ext4_ext_find_goal() returns an ideal physical block number that the block
> allocator tries to allocate first. However, if a required file offset is
> smaller than the existing extent's one, ext4_ext_find_goal() returns
> a wrong block number because it may overflow at
> "block - le32_to_cpu(ex->ee_block)". This patch fixes the problem.

Thanks, applied.  One comment which I've added to the code:

The block placement algorithm in this section of code assumes that we
are filling in a file which will eventually be non-sparse --- i.e., in
the case of libbfd writing an ELF object sections out-of-order but in
a way the eventually results in a contiguous object or executable
file, or the old BSD dbm library writing dbm files.  However, this is
actually somewhat non-ideal if we are writing a sparse file such as
qemu or KVM writing a raw image file, as it will result in the free
space getting unnecessarily fragmented.  Maybe we should have some
hueristics to determine whether we are in the first or second case?

I don't currently think using raw image files is that common in most
virtualization application, but if someone can think of some common
use cases where we would care, it might be worth adding either some
hueristics to detect this, or perhaps some way that userspace can pass
a hint to the file system that what we're doing is writing a raw
sparse file.  For now I'm going to consider the first scenario more
common than the second....

						- Ted

  reply	other threads:[~2011-01-03  2:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-13  5:37 [PATCH] ext4: Fix 32bit overflow in ext4_ext_find_goal() Kazuya Mio
2011-01-02 21:40 ` Ted Ts'o [this message]
2011-01-03  3:35   ` Andreas Dilger
2011-01-03  4:11     ` Ted Ts'o
2011-01-03  7:02       ` Amir Goldstein
2011-01-03 17:25       ` Eric Sandeen
2011-01-03 15:36   ` Rogier Wolff

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=20110102214031.GA10889@thunk.org \
    --to=tytso@mit.edu \
    --cc=k-mio@sx.jp.nec.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).