From patchwork Wed Jul 4 13:52:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liubo X-Patchwork-Id: 1156271 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 3705FDFF0F for ; Wed, 4 Jul 2012 13:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753229Ab2GDNzv (ORCPT ); Wed, 4 Jul 2012 09:55:51 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:38125 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752619Ab2GDNzu (ORCPT ); Wed, 4 Jul 2012 09:55:50 -0400 X-IronPort-AV: E=Sophos;i="4.77,524,1336320000"; d="scan'208";a="5329205" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 04 Jul 2012 21:54:56 +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 q64DgqxV028818 for ; Wed, 4 Jul 2012 21:42:53 +0800 Received: from localhost.localdomain ([10.167.225.27]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012070421425656-517858 ; Wed, 4 Jul 2012 21:42:56 +0800 From: Liu Bo To: Subject: [PATCH 2/4] Btrfs: fix a bug of writting free space cache with nodatacow option Date: Wed, 4 Jul 2012 21:52:56 +0800 Message-Id: <1341409978-22423-2-git-send-email-liubo2009@cn.fujitsu.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1341409978-22423-1-git-send-email-liubo2009@cn.fujitsu.com> References: <1341409978-22423-1-git-send-email-liubo2009@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/07/04 21:42:56, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/07/04 21:42:57, Serialize complete at 2012/07/04 21:42:57 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We can set a block group readonly when we relocate the block group. If the block group covers the disk offset where our free space cache inode is going to write, it will force the free space cache inode into cow_file_range(), which is not allowed due to free space cache design. Signed-off-by: Liu Bo --- fs/btrfs/inode.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 1f72817..4892396 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1245,7 +1245,11 @@ next_slot: goto out_check; if (extent_type == BTRFS_FILE_EXTENT_REG && !force) goto out_check; - if (btrfs_extent_readonly(root, disk_bytenr)) + /* + * nolock means that we're free space cache inode, and + * free space cache inode cannot go to cow_file_range(). + */ + if (btrfs_extent_readonly(root, disk_bytenr) && !nolock) goto out_check; if (btrfs_cross_ref_exist(trans, root, ino, found_key.offset -