From patchwork Wed Feb 4 07:16:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 5774761 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B7EEEBF440 for ; Wed, 4 Feb 2015 07:19:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DFC58202AE for ; Wed, 4 Feb 2015 07:19:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00D3D2024F for ; Wed, 4 Feb 2015 07:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128AbbBDHTt (ORCPT ); Wed, 4 Feb 2015 02:19:49 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:57071 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751483AbbBDHTt (ORCPT ); Wed, 4 Feb 2015 02:19:49 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="57098267" Received: from localhost (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Feb 2015 15:15:27 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t147IFGi020230 for ; Wed, 4 Feb 2015 15:18:15 +0800 Received: from localhost.localdomain (10.167.226.33) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 4 Feb 2015 15:19:03 +0800 From: Qu Wenruo To: Subject: [PATCH 4/7] btrfs-progs: Export write_tree_block() and allow it to do nocow write. Date: Wed, 4 Feb 2015 15:16:48 +0800 Message-ID: <1423034213-14018-5-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1423034213-14018-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1423034213-14018-1-git-send-email-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.33] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Export write_tree_block() function, and allow it to write data to disk without transaction. This is useful for resetting tree block csum, where the reset is done level by level, so btrfs_search_slot() is doing lowest_level search and can't do cow (cow with lowest_level will screw up extent backref). Signed-off-by: Qu Wenruo --- disk-io.c | 4 ++-- disk-io.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/disk-io.c b/disk-io.c index 747ef15..755cb7c 100644 --- a/disk-io.c +++ b/disk-io.c @@ -371,7 +371,7 @@ int write_and_map_eb(struct btrfs_trans_handle *trans, return 0; } -static int write_tree_block(struct btrfs_trans_handle *trans, +int write_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *eb) { @@ -380,7 +380,7 @@ static int write_tree_block(struct btrfs_trans_handle *trans, BUG(); } - if (!btrfs_buffer_uptodate(eb, trans->transid)) + if (trans && !btrfs_buffer_uptodate(eb, trans->transid)) BUG(); btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN); diff --git a/disk-io.h b/disk-io.h index c3eceaa..0cbe2dc 100644 --- a/disk-io.h +++ b/disk-io.h @@ -59,6 +59,9 @@ struct btrfs_device; int read_whole_eb(struct btrfs_fs_info *info, struct extent_buffer *eb, int mirror); struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, u64 parent_transid); +int write_tree_block(struct btrfs_trans_handle *trans, + struct btrfs_root *root, + struct extent_buffer *eb); void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, u64 parent_transid); struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,