linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Allison Henderson <achender@linux.vnet.ibm.com>
To: linux-ext4@vger.kernel.org
Cc: Allison Henderson <achender@linux.vnet.ibm.com>
Subject: [PATCH 4/6 v5] ext4: Correct large hole offset calcuation
Date: Sat, 20 Aug 2011 19:29:45 -0700	[thread overview]
Message-ID: <1313893787-25460-5-git-send-email-achender@linux.vnet.ibm.com> (raw)
In-Reply-To: <1313893787-25460-1-git-send-email-achender@linux.vnet.ibm.com>

This bug was reported by Lukas Czerner while working on a
new patch to add discard support for loop devices using
punch hole.

The bug is happens because the data type for logical blocks is
not large enough to calculate the block offset for holes that are
very large.  This bug is resolved by casting the ext4_lblk_t
to an loff_t before calculating the byte offset of the block.

Reviewed-and-Tested-by: Lukas Czerner <lczerner@redhat.com>

Signed-off-by: Allison Henderson <achender@linux.vnet.ibm.com>
---
:100644 100644 0d7617d... b417e47... M	fs/ext4/extents.c
 fs/ext4/extents.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0d7617d..b417e47 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4179,8 +4179,8 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)
 		EXT4_BLOCK_SIZE_BITS(sb);
 	last_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);
 
-	first_block_offset = first_block << EXT4_BLOCK_SIZE_BITS(sb);
-	last_block_offset = last_block << EXT4_BLOCK_SIZE_BITS(sb);
+	first_block_offset = ((loff_t)first_block) << EXT4_BLOCK_SIZE_BITS(sb);
+	last_block_offset = ((loff_t)last_block) << EXT4_BLOCK_SIZE_BITS(sb);
 
 	first_page = (offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 	last_page = (offset + length) >> PAGE_CACHE_SHIFT;
-- 
1.7.1


  parent reply	other threads:[~2011-08-21  2:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-21  2:29 [PATCH 0/6 v5] ext4: fix 1k block bugs Allison Henderson
2011-08-21  2:29 ` [PATCH 1/6 v5] ext4: Add new ext4_discard_partial_page_buffers routines Allison Henderson
2011-08-22  2:38   ` Ted Ts'o
2011-08-22 14:33     ` Allison Henderson
2011-08-21  2:29 ` [PATCH 2/6 v5] ext4: fix xfstests 75, 112, 127 punch hole failure Allison Henderson
2011-08-21  2:29 ` [PATCH 3/6 v5] ext4: fix 2nd xfstests " Allison Henderson
2011-08-21  2:29 ` Allison Henderson [this message]
2011-08-22 15:50   ` [PATCH 4/6 v5] ext4: Correct large hole offset calcuation Eric Sandeen
2011-08-22 17:19     ` Allison Henderson
2011-08-21  2:29 ` [PATCH 5/6 v5] ext4: fix fsx truncate failure Allison Henderson
2011-08-23  2:36   ` Ted Ts'o
2011-08-23  2:51     ` Allison Henderson
2011-08-21  2:29 ` [PATCH 6/6 v5] ext4: fix partial page writes Allison Henderson

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=1313893787-25460-5-git-send-email-achender@linux.vnet.ibm.com \
    --to=achender@linux.vnet.ibm.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).