From patchwork Sat Mar 2 07:13:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry Snitselaar X-Patchwork-Id: 2206061 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E50F4DF230 for ; Sat, 2 Mar 2013 07:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751367Ab3CBHO4 (ORCPT ); Sat, 2 Mar 2013 02:14:56 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:40195 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819Ab3CBHOz (ORCPT ); Sat, 2 Mar 2013 02:14:55 -0500 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r227EAAU030425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 2 Mar 2013 07:14:11 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r227E91F023543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 2 Mar 2013 07:14:09 GMT Received: from abhmt107.oracle.com (abhmt107.oracle.com [141.146.116.59]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r227E9oZ005747; Sat, 2 Mar 2013 01:14:09 -0600 Received: from cantor.us.oracle.com (/10.159.107.77) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Mar 2013 23:14:08 -0800 From: Jerry Snitselaar To: linux-btrfs@vger.kernel.org Cc: chris.mason@fusionio.com, dsterba@suse.cz, linux-kernel@vger.kernel.org Subject: [PATCH] btrfs: return EPERM in btrfs_rm_device() Date: Sat, 2 Mar 2013 00:13:59 -0700 Message-Id: <1362208439-19245-1-git-send-email-jerry.snitselaar@oracle.com> X-Mailer: git-send-email 1.8.2.rc1 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Currently there are error paths in btrfs_rm_device() where EINVAL is returned telling the user they passed an invalid argument even though they passed a valid device. Change to return EPERM instead as the operation is not permitted. Signed-off-by: Jerry Snitselaar --- fs/btrfs/volumes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 5cbb7f4..3e1586c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1392,14 +1392,14 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && num_devices <= 4) { printk(KERN_ERR "btrfs: unable to go below four devices " "on raid10\n"); - ret = -EINVAL; + ret = -EPERM; goto out; } if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && num_devices <= 2) { printk(KERN_ERR "btrfs: unable to go below two " "devices on raid1\n"); - ret = -EINVAL; + ret = -EPERM; goto out; } @@ -1449,14 +1449,14 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) if (device->is_tgtdev_for_dev_replace) { pr_err("btrfs: unable to remove the dev_replace target dev\n"); - ret = -EINVAL; + ret = -EPERM; goto error_brelse; } if (device->writeable && root->fs_info->fs_devices->rw_devices == 1) { printk(KERN_ERR "btrfs: unable to remove the only writeable " "device\n"); - ret = -EINVAL; + ret = -EPERM; goto error_brelse; }