提交 4dda41d3 编写于 作者: A Alex Elder

rbd: ignore zero-length requests

The old request code simply ignored zero-length requests.  We should
still operate that same way to avoid any changes in behavior.  We
can implement handling for special zero-length requests separately
(see http://tracker.ceph.com/issues/4236).

Add some assertions based on this new constraint.

This resolves:
    http://tracker.ceph.com/issues/4237Signed-off-by: NAlex Elder <elder@inktank.com>
Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
上级 92a49fb0
...@@ -1560,6 +1560,7 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request, ...@@ -1560,6 +1560,7 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
image_offset = img_request->offset; image_offset = img_request->offset;
rbd_assert(image_offset == bio_list->bi_sector << SECTOR_SHIFT); rbd_assert(image_offset == bio_list->bi_sector << SECTOR_SHIFT);
resid = img_request->length; resid = img_request->length;
rbd_assert(resid > 0);
while (resid) { while (resid) {
const char *object_name; const char *object_name;
unsigned int clone_size; unsigned int clone_size;
...@@ -1627,8 +1628,10 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request) ...@@ -1627,8 +1628,10 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
bool more = true; bool more = true;
img_request = obj_request->img_request; img_request = obj_request->img_request;
rbd_assert(img_request != NULL); rbd_assert(img_request != NULL);
rbd_assert(img_request->rq != NULL); rbd_assert(img_request->rq != NULL);
rbd_assert(img_request->obj_request_count > 0);
rbd_assert(which != BAD_WHICH); rbd_assert(which != BAD_WHICH);
rbd_assert(which < img_request->obj_request_count); rbd_assert(which < img_request->obj_request_count);
rbd_assert(which >= img_request->next_completion); rbd_assert(which >= img_request->next_completion);
...@@ -1918,6 +1921,19 @@ static void rbd_request_fn(struct request_queue *q) ...@@ -1918,6 +1921,19 @@ static void rbd_request_fn(struct request_queue *q)
/* Ignore any non-FS requests that filter through. */ /* Ignore any non-FS requests that filter through. */
if (rq->cmd_type != REQ_TYPE_FS) { if (rq->cmd_type != REQ_TYPE_FS) {
dout("%s: non-fs request type %d\n", __func__,
(int) rq->cmd_type);
__blk_end_request_all(rq, 0);
continue;
}
/* Ignore/skip any zero-length requests */
offset = (u64) blk_rq_pos(rq) << SECTOR_SHIFT;
length = (u64) blk_rq_bytes(rq);
if (!length) {
dout("%s: zero-length request\n", __func__);
__blk_end_request_all(rq, 0); __blk_end_request_all(rq, 0);
continue; continue;
} }
...@@ -1947,9 +1963,6 @@ static void rbd_request_fn(struct request_queue *q) ...@@ -1947,9 +1963,6 @@ static void rbd_request_fn(struct request_queue *q)
goto end_request; goto end_request;
} }
offset = (u64) blk_rq_pos(rq) << SECTOR_SHIFT;
length = (u64) blk_rq_bytes(rq);
result = -EINVAL; result = -EINVAL;
if (WARN_ON(offset && length > U64_MAX - offset + 1)) if (WARN_ON(offset && length > U64_MAX - offset + 1))
goto end_request; /* Shouldn't happen */ goto end_request; /* Shouldn't happen */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册