All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akira Fujita <a-fujita@rs.jp.nec.com>
To: unlisted-recipients:; (no To-header on input)
Cc: ext4 development <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 11/28] ext4: correctly calculate number of blocks for fiemap
Date: Fri, 05 Mar 2010 14:57:49 +0900	[thread overview]
Message-ID: <4B909D5D.5070402@rs.jp.nec.com> (raw)

Hi Ted,

> commit aca92ff6f57c000d1b4523e383c8bd6b8269b8b1
> Author: Leonard Michlmayr<leonard.michlmayr@gmail.com>
> Date:   Thu Mar 4 17:07:28 2010 -0500
>
>      ext4: correctly calculate number of blocks for fiemap
>
>      ext4_fiemap() rounds the length of the requested range down to
>      blocksize, which is is not the true number of blocks that cover the
>      requested region.  This problem is especially impressive if the user
>      requests only the first byte of a file: not a single extent will be
>      reported.
>
>      We fix this by calculating the last block of the region and then
>      subtract to find the number of blocks in the extents.
>
>      Signed-off-by: Leonard Michlmayr<leonard.michlmayr@gmail.com>
>      Signed-off-by: "Theodore Ts'o"<tytso@mit.edu>
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index bd80891..7d54850 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3768,7 +3768,6 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>           __u64 start, __u64 len)
>   {
>       ext4_lblk_t start_blk;
> -    ext4_lblk_t len_blks;
>       int error = 0;
>
>       /* fallback to generic here if not in extents fmt */
> @@ -3782,8 +3781,14 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>       if (fieinfo->fi_flags&  FIEMAP_FLAG_XATTR) {
>           error = ext4_xattr_fiemap(inode, fieinfo);
>       } else {
> +        ext4_lblk_t len_blks;
> +        __u64 last_blk;
> +
>           start_blk = start>>  inode->i_sb->s_blocksize_bits;
> -        len_blks = len>>  inode->i_sb->s_blocksize_bits;
> +        last_blk = (start + len - 1)>>  inode->i_sb->s_blocksize_bits;
> +        if (last_blk>= EXT_MAX_BLOCK)
> +            last_blk = EXT_MAX_BLOCK-1;

               last_blk = EXT_MAX_BLOCK - 1;

You seem to have already pushed this patch to Linus, though.
There is a coding style thing.
Anyway, the patch works fine for me.
Thanks for your work.  :-)

Tested-by: Akira Fujita <a-fujita@rs.jp.nec.com>

Regards,
Akira Fujita

> +        len_blks = ((ext4_lblk_t) last_blk) - start_blk + 1;
>
>           /*
>            * Walk the extent tree gathering extent information.
>

             reply	other threads:[~2010-03-05  5:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-05  5:57 Akira Fujita [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-03-02 18:18 [PATCH 00/28] Ext4 patch queue for the 2.6.34 merge window Theodore Ts'o
2010-03-02 18:18 ` [PATCH 11/28] ext4: correctly calculate number of blocks for fiemap Theodore Ts'o
2010-03-03  7:47   ` Akira Fujita
2010-03-03  8:34     ` Leonard Michlmayr
2010-03-03 17:52     ` tytso
2010-03-04  5:40       ` Akira Fujita
2010-03-04 21:44         ` Leonard Michlmayr
2010-03-04 23:38           ` Eric Sandeen
2010-03-05 16:46             ` Leonard Michlmayr
2010-03-04 22:08         ` tytso
2010-03-04 23:47           ` 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=4B909D5D.5070402@rs.jp.nec.com \
    --to=a-fujita@rs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.