From patchwork Fri Sep 25 02:38:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 7262091 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 490F99F6CD for ; Fri, 25 Sep 2015 02:39:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E355020879 for ; Fri, 25 Sep 2015 02:39:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D470320887 for ; Fri, 25 Sep 2015 02:39:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754312AbbIYCiX (ORCPT ); Thu, 24 Sep 2015 22:38:23 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:54197 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754177AbbIYCiU (ORCPT ); Thu, 24 Sep 2015 22:38:20 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101082333" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Sep 2015 10:40:48 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8P2bjLE019989; Fri, 25 Sep 2015 10:37:45 +0800 Received: from localhost.localdomain (10.167.226.33) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 25 Sep 2015 10:38:04 +0800 From: Qu Wenruo To: , Subject: [PATCH 1/2] btrfs: Add support to do stack item key operation Date: Fri, 25 Sep 2015 10:38:00 +0800 Message-ID: <1443148681-3015-2-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1443148681-3015-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1443148681-3015-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, 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 Normal btrfs_item_key_to_cpu() will need extent buffer to do it, and there is not stack version to handle in memory leaf. Add btrfs_stack_item_key_to_cpu() function for such operation, which will provide the basis for later qgroup fix. Signed-off-by: Qu Wenruo --- fs/btrfs/ctree.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 938efe3..33e9d04 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2683,6 +2683,17 @@ static inline void btrfs_item_key(struct extent_buffer *eb, read_eb_member(eb, item, struct btrfs_item, key, disk_key); } +static inline void btrfs_stack_item_key(char *stack_leaf, + struct btrfs_disk_key *disk_key, + int nr) +{ + unsigned long item_offset = btrfs_item_nr_offset(nr); + struct btrfs_item *item; + + item = (struct btrfs_item *)(stack_leaf + item_offset); + memcpy(disk_key, &item->key, sizeof(*disk_key)); +} + static inline void btrfs_set_item_key(struct extent_buffer *eb, struct btrfs_disk_key *disk_key, int nr) { @@ -2785,6 +2796,15 @@ static inline void btrfs_item_key_to_cpu(struct extent_buffer *eb, btrfs_disk_key_to_cpu(key, &disk_key); } +static inline void btrfs_stack_item_key_to_cpu(char *stack_leaf, + struct btrfs_key *key, + int nr) +{ + struct btrfs_disk_key disk_key; + btrfs_stack_item_key(stack_leaf, &disk_key, nr); + btrfs_disk_key_to_cpu(key, &disk_key); +} + static inline void btrfs_dir_item_key_to_cpu(struct extent_buffer *eb, struct btrfs_dir_item *item, struct btrfs_key *key)