From 2e584bce706a42a5dd86e9ac9f39900a20ba5175 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Mon, 15 Jan 2018 17:24:51 +0100 Subject: rbd: obj_request->completion is unused Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index cc93522a6d41..89d00038b7ce 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -281,7 +281,6 @@ struct rbd_obj_request { int result; rbd_obj_callback_t callback; - struct completion completion; struct kref kref; }; @@ -1734,10 +1733,7 @@ static void rbd_obj_request_complete(struct rbd_obj_request *obj_request) { dout("%s: obj %p cb %p\n", __func__, obj_request, obj_request->callback); - if (obj_request->callback) - obj_request->callback(obj_request); - else - complete_all(&obj_request->completion); + obj_request->callback(obj_request); } static void rbd_obj_request_error(struct rbd_obj_request *obj_request, int err) @@ -2013,7 +2009,6 @@ rbd_obj_request_create(enum obj_request_type type) obj_request->which = BAD_WHICH; obj_request->type = type; INIT_LIST_HEAD(&obj_request->links); - init_completion(&obj_request->completion); kref_init(&obj_request->kref); dout("%s %p\n", __func__, obj_request); -- cgit v1.2.3-59-g8ed1b From a0c5895b27f6bbf8aa20a2c640845fc261740051 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Mon, 22 Jan 2018 16:03:06 +0100 Subject: rbd: use kmem_cache_zalloc() in rbd_img_request_create() Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 89d00038b7ce..7646a2d3119c 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2124,15 +2124,13 @@ static struct rbd_img_request *rbd_img_request_create( { struct rbd_img_request *img_request; - img_request = kmem_cache_alloc(rbd_img_request_cache, GFP_NOIO); + img_request = kmem_cache_zalloc(rbd_img_request_cache, GFP_NOIO); if (!img_request) return NULL; - img_request->rq = NULL; img_request->rbd_dev = rbd_dev; img_request->offset = offset; img_request->length = length; - img_request->flags = 0; if (op_type == OBJ_OP_DISCARD) { img_request_discard_set(img_request); img_request->snapc = snapc; @@ -2144,11 +2142,8 @@ static struct rbd_img_request *rbd_img_request_create( } if (rbd_dev_parent_get(rbd_dev)) img_request_layered_set(img_request); + spin_lock_init(&img_request->completion_lock); - img_request->next_completion = 0; - img_request->callback = NULL; - img_request->result = 0; - img_request->obj_request_count = 0; INIT_LIST_HEAD(&img_request->obj_requests); kref_init(&img_request->kref); -- cgit v1.2.3-59-g8ed1b From d98f153f1a116f79e636edd34b4fec07e49ae9b2 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Thu, 18 Jan 2018 16:32:00 +0100 Subject: rbd: don't NULL out ->obj_request in rbd_img_obj_parent_read_full() If rbd_img_request_submit() fails, parent_request->obj_request is NULLed out, triggering an assert in rbd_obj_request_put(): rbd_img_request_put(parent_request) rbd_parent_request_destroy rbd_obj_request_put(NULL) Just remove it -- parent_request->obj_request will be put in rbd_parent_request_destroy(). Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/block') diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 7646a2d3119c..4a886d8c4a3c 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -2682,8 +2682,6 @@ static int rbd_img_obj_parent_read_full(struct rbd_obj_request *obj_request) parent_request->copyup_pages = NULL; parent_request->copyup_page_count = 0; - parent_request->obj_request = NULL; - rbd_obj_request_put(obj_request); out_err: if (pages) ceph_release_page_vector(pages, page_count); -- cgit v1.2.3-59-g8ed1b From e573427a440fd67d3f522357d7ac901d59281948 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Tue, 16 Jan 2018 15:41:54 +0100 Subject: rbd: whitelist RBD_FEATURE_OPERATIONS feature bit This feature bit restricts older clients from performing certain maintenance operations against an image (e.g. clone, snap create). krbd does not perform maintenance operations. Cc: stable@vger.kernel.org Signed-off-by: Ilya Dryomov Reviewed-by: Jason Dillaman --- drivers/block/rbd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/block') diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 4a886d8c4a3c..8e40da093766 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -124,11 +124,13 @@ static int atomic_dec_return_safe(atomic_t *v) #define RBD_FEATURE_STRIPINGV2 (1ULL<<1) #define RBD_FEATURE_EXCLUSIVE_LOCK (1ULL<<2) #define RBD_FEATURE_DATA_POOL (1ULL<<7) +#define RBD_FEATURE_OPERATIONS (1ULL<<8) #define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \ RBD_FEATURE_STRIPINGV2 | \ RBD_FEATURE_EXCLUSIVE_LOCK | \ - RBD_FEATURE_DATA_POOL) + RBD_FEATURE_DATA_POOL | \ + RBD_FEATURE_OPERATIONS) /* Features supported by this (client software) implementation. */ -- cgit v1.2.3-59-g8ed1b