From patchwork Tue Jul 9 18:49:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 2825424 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 4C4389F756 for ; Tue, 9 Jul 2013 18:50:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41B632015F for ; Tue, 9 Jul 2013 18:50:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E71E20119 for ; Tue, 9 Jul 2013 18:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752179Ab3GISu0 (ORCPT ); Tue, 9 Jul 2013 14:50:26 -0400 Received: from mail-we0-f181.google.com ([74.125.82.181]:44107 "EHLO mail-we0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761Ab3GISuZ (ORCPT ); Tue, 9 Jul 2013 14:50:25 -0400 Received: by mail-we0-f181.google.com with SMTP id p58so4992144wes.40 for ; Tue, 09 Jul 2013 11:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=bEB5b6arVKAlWh0bdG0SOt76CGQXyIcYZWr9UBzGJ3E=; b=bYSz8BHwH9G0hO7eUV6yJN9M6XKIa5832Mb41AgU52LYUvXgUBhh90LFjE+FcoVTsT iG4aJHFhZ39iD9cLjY8+eXRPKKrRJJt+BPJkAYsknOa3QuvbfcjY6b4QA1o+lX6kPj46 Gpw7cfUt479CQImbS14/MpIw06jL5yPRfy4S9rtwkeF/6We6TT+s8PjiozayXex24MY7 uNj+9bngLqXTDF5kWtGofY8a7lGB9ZsvQ9zMfLPCZO5/OU04i4ny4tuZBGX/3SBgonuz qMNkR+D7KVRLbxlMPTPzoU4okns82mzCAUmhWN6YWpZcWiLYeg73KfmHBWcMp7M8tG0J Ce0g== X-Received: by 10.194.48.116 with SMTP id k20mr16156759wjn.23.1373395824375; Tue, 09 Jul 2013 11:50:24 -0700 (PDT) Received: from storm-desktop.lan (bl10-255-22.dsl.telepac.pt. [85.243.255.22]) by mx.google.com with ESMTPSA id p1sm62931912wix.9.2013.07.09.11.50.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Jul 2013 11:50:23 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH 1/2] Btrfs-progs: remove duplicated code in cmds-restore.c Date: Tue, 9 Jul 2013 19:49:53 +0100 Message-Id: <1373395794-29140-2-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1373395794-29140-1-git-send-email-fdmanana@gmail.com> References: <1373395794-29140-1-git-send-email-fdmanana@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 The module cmds-restore.c was defining its own next_leaf() function, which did exactly the same as btrfs_next_leaf() from ctree.c. Signed-off-by: Filipe David Borba Manana --- cmds-restore.c | 62 +++++--------------------------------------------------- 1 file changed, 5 insertions(+), 57 deletions(-) diff --git a/cmds-restore.c b/cmds-restore.c index eca528d..ed4815a 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -148,58 +148,6 @@ static int decompress(char *inbuf, char *outbuf, u64 compress_len, return -1; } -int next_leaf(struct btrfs_root *root, struct btrfs_path *path) -{ - int slot; - int level = 1; - struct extent_buffer *c; - struct extent_buffer *next = NULL; - - for (; level < BTRFS_MAX_LEVEL; level++) { - if (path->nodes[level]) - break; - } - - if (level == BTRFS_MAX_LEVEL) - return 1; - - slot = path->slots[level] + 1; - - while(level < BTRFS_MAX_LEVEL) { - if (!path->nodes[level]) - return 1; - - slot = path->slots[level] + 1; - c = path->nodes[level]; - if (slot >= btrfs_header_nritems(c)) { - level++; - if (level == BTRFS_MAX_LEVEL) - return 1; - continue; - } - - if (path->reada) - reada_for_search(root, path, level, slot, 0); - - next = read_node_slot(root, c, slot); - break; - } - path->slots[level] = slot; - while(1) { - level--; - c = path->nodes[level]; - free_extent_buffer(c); - path->nodes[level] = next; - path->slots[level] = 0; - if (!level) - break; - if (path->reada) - reada_for_search(root, path, level, 0, 0); - next = read_node_slot(root, next, 0); - } - return 0; -} - static int copy_one_inline(int fd, struct btrfs_path *path, u64 pos) { struct extent_buffer *leaf = path->nodes[0]; @@ -447,7 +395,7 @@ static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key, leaf = path->nodes[0]; while (!leaf) { - ret = next_leaf(root, path); + ret = btrfs_next_leaf(root, path); if (ret < 0) { fprintf(stderr, "Error getting next leaf %d\n", ret); @@ -470,7 +418,7 @@ static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key, } if (path->slots[0] >= btrfs_header_nritems(leaf)) { do { - ret = next_leaf(root, path); + ret = btrfs_next_leaf(root, path); if (ret < 0) { fprintf(stderr, "Error searching %d\n", ret); btrfs_free_path(path); @@ -569,7 +517,7 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, if (verbose > 1) printf("No leaf after search, looking for the next " "leaf\n"); - ret = next_leaf(root, path); + ret = btrfs_next_leaf(root, path); if (ret < 0) { fprintf(stderr, "Error getting next leaf %d\n", ret); @@ -596,7 +544,7 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, if (path->slots[0] >= btrfs_header_nritems(leaf)) { do { - ret = next_leaf(root, path); + ret = btrfs_next_leaf(root, path); if (ret < 0) { fprintf(stderr, "Error searching %d\n", ret); @@ -937,7 +885,7 @@ again: goto out; } do { - ret = next_leaf(root, path); + ret = btrfs_next_leaf(root, path); if (ret < 0) { fprintf(stderr, "Error getting next leaf %d\n", ret);