From patchwork Mon Feb 15 17:34:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 8317401 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 0A95BC02AA for ; Mon, 15 Feb 2016 17:37:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F2AF2039C for ; Mon, 15 Feb 2016 17:37:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BA04202E5 for ; Mon, 15 Feb 2016 17:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753790AbcBORfv (ORCPT ); Mon, 15 Feb 2016 12:35:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:34952 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752898AbcBORer (ORCPT ); Mon, 15 Feb 2016 12:34:47 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1E0A0ABD3; Mon, 15 Feb 2016 17:34:46 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 23925DA9DC; Mon, 15 Feb 2016 18:34:43 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba , anand.jain@oracle.com Subject: [PATCH 14/15] btrfs: rename btrfs_find_device_by_user_input Date: Mon, 15 Feb 2016 18:34:43 +0100 Message-Id: X-Mailer: git-send-email 2.7.1 In-Reply-To: References: 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 For clarity how we are going to find the device, let's call it a device specifier, devspec for short. Also rename the arguments that are a leftover from previous function purpose. Signed-off-by: David Sterba Reviewed-by: Anand Jain --- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/volumes.c | 17 ++++++++++------- fs/btrfs/volumes.h | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 3e2616d151d9..1731f92b6247 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -322,7 +322,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root, /* the disk copy procedure reuses the scrub code */ mutex_lock(&fs_info->volume_mutex); - ret = btrfs_find_device_by_user_input(root, args->start.srcdevid, + ret = btrfs_find_device_by_devspec(root, args->start.srcdevid, args->start.srcdev_name, &src_device); if (ret) { diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8fee24f92574..05d9bc0cdd49 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1779,7 +1779,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path, u64 devid) if (ret) goto out; - ret = btrfs_find_device_by_user_input(root, devid, device_path, + ret = btrfs_find_device_by_devspec(root, devid, device_path, &device); if (ret) goto out; @@ -2065,23 +2065,26 @@ int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, } } -int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid, - char *srcdev_name, +/* + * Lookup a device given by device id, or the path if the id is 0. + */ +int btrfs_find_device_by_devspec(struct btrfs_root *root, u64 devid, + char *devpath, struct btrfs_device **device) { int ret; - if (srcdevid) { + if (devid) { ret = 0; - *device = btrfs_find_device(root->fs_info, srcdevid, NULL, + *device = btrfs_find_device(root->fs_info, devid, NULL, NULL); if (!*device) ret = -ENOENT; } else { - if (!srcdev_name || !srcdev_name[0]) + if (!devpath || !devpath[0]) return -EINVAL; - ret = btrfs_find_device_missing_or_by_path(root, srcdev_name, + ret = btrfs_find_device_missing_or_by_path(root, devpath, device); } return ret; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index a13a538cb01e..febdb7bc9370 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -448,8 +448,8 @@ void btrfs_close_extra_devices(struct btrfs_fs_devices *fs_devices, int step); int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, char *device_path, struct btrfs_device **device); -int btrfs_find_device_by_user_input(struct btrfs_root *root, u64 srcdevid, - char *srcdev_name, +int btrfs_find_device_by_devspec(struct btrfs_root *root, u64 devid, + char *devpath, struct btrfs_device **device); struct btrfs_device *btrfs_alloc_device(struct btrfs_fs_info *fs_info, const u64 *devid,