All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: dsterba@suse.com, linux-btrfs@vger.kernel.org
Subject: [PATCH 1/2] btrfs-progs: convert: Fix a bug which fails to insert hole file extent
Date: Thu,  2 Jun 2016 15:22:49 +0800	[thread overview]
Message-ID: <20160602072250.25214-1-quwenruo@cn.fujitsu.com> (raw)

When copying inode, if there is a file referring part of a hole range,
convert will fail.

The problem is, when calculating real extent bytenr, it doesn't check if
the original extent is a hole.

In case the orinal extent is a hole, we still calculate bytenr using
file_pos - found_extent_file_pos, causing non-zero value, and later
btrfs_record_file_extent() detects that we are pointing to non-exist
extent and aborts convert.

Fix it by checking the disk_bytenr before calculating real disk bytenr.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
These commits (especially for next testcase commits, which includes 4
80+K e2image raw dumps) can also be fetched from my github:
https://github.com/adam900710/btrfs-progs.git convert_fixes
---
 btrfs-convert.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/btrfs-convert.c b/btrfs-convert.c
index 5f6b44c..43b8b08 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -572,7 +572,11 @@ static int record_file_blocks(struct blk_iterate_data *data,
 		BUG_ON(cur_off - key.offset >= extent_num_bytes);
 		btrfs_release_path(path);
 
-		real_disk_bytenr = cur_off - key.offset + extent_disk_bytenr;
+		if (extent_disk_bytenr)
+			real_disk_bytenr = cur_off - key.offset +
+					   extent_disk_bytenr;
+		else
+			real_disk_bytenr = 0;
 		cur_len = min(key.offset + extent_num_bytes,
 			      old_disk_bytenr + num_bytes) - cur_off;
 		ret = btrfs_record_file_extent(data->trans, data->root,
-- 
2.8.3




             reply	other threads:[~2016-06-02  7:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02  7:22 Qu Wenruo [this message]
2016-06-02  7:22 ` [PATCH 2/2] btrfs-progs: convert-test: Add specially built test cases for new convert Qu Wenruo
2016-06-02 17:34   ` David Sterba
2016-06-02 17:37 ` [PATCH 1/2] btrfs-progs: convert: Fix a bug which fails to insert hole file extent David Sterba

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=20160602072250.25214-1-quwenruo@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@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.