From patchwork Tue Jun 18 03:13:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 2738241 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BFDED9F472 for ; Tue, 18 Jun 2013 03:12:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9EDE20276 for ; Tue, 18 Jun 2013 03:12:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD7732026B for ; Tue, 18 Jun 2013 03:12:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753533Ab3FRDMT (ORCPT ); Mon, 17 Jun 2013 23:12:19 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:10689 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752247Ab3FRDMT (ORCPT ); Mon, 17 Jun 2013 23:12:19 -0400 X-IronPort-AV: E=Sophos;i="4.87,885,1363104000"; d="scan'208";a="7583921" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 18 Jun 2013 11:09:23 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r5I3CHju013964; Tue, 18 Jun 2013 11:12:17 +0800 Received: from [10.167.233.149] ([10.167.233.149]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013061811101519-2221866 ; Tue, 18 Jun 2013 11:10:15 +0800 Message-ID: <51BFD061.4070404@cn.fujitsu.com> Date: Tue, 18 Jun 2013 11:13:37 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: Josef Bacik CC: Linux Btrfs Subject: [PATCH] Btrfs: fix wrong csum clone when doing relocation References: <51878334.4000807@cn.fujitsu.com> <20130614152712.GA28783@localhost.localdomain> In-Reply-To: <20130614152712.GA28783@localhost.localdomain> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/18 11:10:15, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/18 11:10:15, Serialize complete at 2013/06/18 11:10:15 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Bacik Patch "Btrfs: remove btrfs_sector_sum structure" introduced a problem that we copied the checksum value to the wrong address when doing relocation. The reason is: It is very likely that one ordered extent has two or more checksum structures to keep the relative checksum value, and ->bytenr in each checksum structure should point to the start of its extent, not the start of the ordered extent. Fix it. Signed-off-by: Josef Bacik Signed-off-by: Miao Xie --- fs/btrfs/relocation.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 35c0cf7..e3108e5 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4410,11 +4410,13 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len) if (ret) goto out; + disk_bytenr = ordered->start; while (!list_empty(&list)) { sums = list_entry(list.next, struct btrfs_ordered_sum, list); list_del_init(&sums->list); - sums->bytenr = ordered->start; + sums->bytenr = disk_bytenr; + disk_bytenr += sums->len; btrfs_add_ordered_sum(inode, ordered, sums); }