OSDN Git Service

rbd: return -ENOMEM instead of pool id if rbd_dev_create() fails
authorIlya Dryomov <idryomov@gmail.com>
Thu, 15 Oct 2015 13:38:57 +0000 (15:38 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 2 Nov 2015 22:36:48 +0000 (23:36 +0100)
Returning pool id (i.e. >= 0) from a sysfs ->store() callback makes
userspace think it needs to retry the write.  Fix it - it's a leftover
from the times when the equivalent of rbd_dev_create() was the first
action in rbd_add().

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
drivers/block/rbd.c

index 8f3dcb6..5e7234d 100644 (file)
@@ -5397,7 +5397,7 @@ static ssize_t do_rbd_add(struct bus_type *bus,
        struct rbd_spec *spec = NULL;
        struct rbd_client *rbdc;
        bool read_only;
-       int rc = -ENOMEM;
+       int rc;
 
        if (!try_module_get(THIS_MODULE))
                return -ENODEV;
@@ -5432,8 +5432,10 @@ static ssize_t do_rbd_add(struct bus_type *bus,
        }
 
        rbd_dev = rbd_dev_create(rbdc, spec, rbd_opts);
-       if (!rbd_dev)
+       if (!rbd_dev) {
+               rc = -ENOMEM;
                goto err_out_client;
+       }
        rbdc = NULL;            /* rbd_dev now owns this */
        spec = NULL;            /* rbd_dev now owns this */
        rbd_opts = NULL;        /* rbd_dev now owns this */