[PATCH] btrfs: return EPERM in btrfs_rm_device()

2013-03-01 Thread Jerry Snitselaar
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;
}
 
-- 
1.8.2.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


btrfs-progs: question about error message

2013-02-05 Thread Jerry Snitselaar
In some testing that was being done the tester ran into the following:

--

/mnt/abo is a filesystem in Raid1-configuration having two disks: /dev/sdg2 
and /dev/sdg3. When trying to remove one of the devices, you get this error 
on the console: 

# btrfs device delete /dev/sdg2 /mnt/abo 
ERROR: error removing the device '/dev/sdg2' - Invalid argument 

/var/log/messages shows the real error: 
Jan 29 13:54:58 ca-ostest202 kernel: btrfs: unable to go below two devices on 
raid1 

The error message on the console output is wrong : '/dev/sdg2' is not an 
invalid argument, there's another reason why the delete-action can't be 
executed. 

--

Looking at it I can see the EINVAL being correct because it is being
told to remove a member from a raid1 with only 2 members, but I can
see how that message could be confusing as well. Is there some place
that tells users to look at /var/log/messages to see the other
message? Wondering if the error message should point users to
/var/log/messages to get more details.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html