From patchwork Mon Aug 12 11:33:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 2843042 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 67A059F239 for ; Mon, 12 Aug 2013 11:33:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 44F1B2035E for ; Mon, 12 Aug 2013 11:33:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93FB82035D for ; Mon, 12 Aug 2013 11:33:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754756Ab3HLLdZ (ORCPT ); Mon, 12 Aug 2013 07:33:25 -0400 Received: from mail-lb0-f179.google.com ([209.85.217.179]:43711 "EHLO mail-lb0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755242Ab3HLLdX (ORCPT ); Mon, 12 Aug 2013 07:33:23 -0400 Received: by mail-lb0-f179.google.com with SMTP id v1so4687462lbd.38 for ; Mon, 12 Aug 2013 04:33:21 -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:in-reply-to:references; bh=W+UGwLdfjaGLhsGNYvyKozEaEn0zREu0cmT3cGDEgWg=; b=Mymj8fNzTHJXKRlqEhhUZYT6Vhc2jZGULd3mLetc4RQ2/Q0aZCRxZthGVbbLQxdm1o 5Sinvo9ScfE1cgErjiLtW68VDS9/XKxzaucfdIMQFVi+oilEUcI5ckK6XBJtWI7rZsTp wswqs4Etx5SUjiMyghYfrwOP6V4LIKXT4shtVV/FShTcqS6rknpzF2i79r2nIkH/KSO3 R8CLt9stfz9+Z7J9hYu6hPe7+rG+fWgZog7GReQ0W63l4ZlqdmtpeuOG/dcmriMv1INM wwbmULp2+yhlMW7MUfz9TChxWkFp0/YBqQ52ANxm8q6tNm43nYFq1oxV3dEM1s7TCBQV FBsg== X-Received: by 10.112.157.2 with SMTP id wi2mr7239105lbb.68.1376307201166; Mon, 12 Aug 2013 04:33:21 -0700 (PDT) Received: from localhost ([109.110.78.166]) by mx.google.com with ESMTPSA id db5sm11699734lac.10.2013.08.12.04.33.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 12 Aug 2013 04:33:20 -0700 (PDT) From: Ilya Dryomov To: linux-btrfs@vger.kernel.org Cc: Chris Mason , idryomov@gmail.com Subject: [PATCH 1/4] Btrfs: find_next_devid: root -> fs_info Date: Mon, 12 Aug 2013 14:33:01 +0300 Message-Id: <1376307184-7175-2-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1376307184-7175-1-git-send-email-idryomov@gmail.com> References: <1376307184-7175-1-git-send-email-idryomov@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=-9.6 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 find_next_devid() knows which root to search, so it should take an fs_info instead of an arbitrary root. Signed-off-by: Ilya Dryomov --- fs/btrfs/volumes.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 78b8717..ae1bcb0 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1307,15 +1307,14 @@ static u64 find_next_chunk(struct btrfs_fs_info *fs_info) return ret; } -static noinline int find_next_devid(struct btrfs_root *root, u64 *objectid) +static noinline int find_next_devid(struct btrfs_fs_info *fs_info, + u64 *devid_ret) { int ret; struct btrfs_key key; struct btrfs_key found_key; struct btrfs_path *path; - root = root->fs_info->chunk_root; - path = btrfs_alloc_path(); if (!path) return -ENOMEM; @@ -1324,20 +1323,21 @@ static noinline int find_next_devid(struct btrfs_root *root, u64 *objectid) key.type = BTRFS_DEV_ITEM_KEY; key.offset = (u64)-1; - ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); + ret = btrfs_search_slot(NULL, fs_info->chunk_root, &key, path, 0, 0); if (ret < 0) goto error; BUG_ON(ret == 0); /* Corruption */ - ret = btrfs_previous_item(root, path, BTRFS_DEV_ITEMS_OBJECTID, + ret = btrfs_previous_item(fs_info->chunk_root, path, + BTRFS_DEV_ITEMS_OBJECTID, BTRFS_DEV_ITEM_KEY); if (ret) { - *objectid = 1; + *devid_ret = 1; } else { btrfs_item_key_to_cpu(path->nodes[0], &found_key, path->slots[0]); - *objectid = found_key.offset + 1; + *devid_ret = found_key.offset + 1; } ret = 0; error: @@ -1971,7 +1971,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) } rcu_assign_pointer(device->name, name); - ret = find_next_devid(root, &device->devid); + ret = find_next_devid(root->fs_info, &device->devid); if (ret) { rcu_string_free(device->name); kfree(device);