aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-02-20 22:59:33 -0500
committerAlex Elder <elder@inktank.com>2013-02-25 16:36:36 -0500
commit4dda41d3d76747414586a4bad5615b550e0986b1 (patch)
tree9a2f3cc8d6071fa2d242de8e6a36231e1ba6a902 /drivers/block
parent92a49fb0f79f3300e6e50ddf56238e70678e4202 (diff)
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/4237 Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b0eea3eaee93..3cc003b26610 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1560,6 +1560,7 @@ static int rbd_img_request_fill_bio(struct rbd_img_request *img_request,
1560 image_offset = img_request->offset; 1560 image_offset = img_request->offset;
1561 rbd_assert(image_offset == bio_list->bi_sector << SECTOR_SHIFT); 1561 rbd_assert(image_offset == bio_list->bi_sector << SECTOR_SHIFT);
1562 resid = img_request->length; 1562 resid = img_request->length;
1563 rbd_assert(resid > 0);
1563 while (resid) { 1564 while (resid) {
1564 const char *object_name; 1565 const char *object_name;
1565 unsigned int clone_size; 1566 unsigned int clone_size;
@@ -1627,8 +1628,10 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
1627 bool more = true; 1628 bool more = true;
1628 1629
1629 img_request = obj_request->img_request; 1630 img_request = obj_request->img_request;
1631
1630 rbd_assert(img_request != NULL); 1632 rbd_assert(img_request != NULL);
1631 rbd_assert(img_request->rq != NULL); 1633 rbd_assert(img_request->rq != NULL);
1634 rbd_assert(img_request->obj_request_count > 0);
1632 rbd_assert(which != BAD_WHICH); 1635 rbd_assert(which != BAD_WHICH);
1633 rbd_assert(which < img_request->obj_request_count); 1636 rbd_assert(which < img_request->obj_request_count);
1634 rbd_assert(which >= img_request->next_completion); 1637 rbd_assert(which >= img_request->next_completion);
@@ -1918,6 +1921,19 @@ static void rbd_request_fn(struct request_queue *q)
1918 /* Ignore any non-FS requests that filter through. */ 1921 /* Ignore any non-FS requests that filter through. */
1919 1922
1920 if (rq->cmd_type != REQ_TYPE_FS) { 1923 if (rq->cmd_type != REQ_TYPE_FS) {
1924 dout("%s: non-fs request type %d\n", __func__,
1925 (int) rq->cmd_type);
1926 __blk_end_request_all(rq, 0);
1927 continue;
1928 }
1929
1930 /* Ignore/skip any zero-length requests */
1931
1932 offset = (u64) blk_rq_pos(rq) << SECTOR_SHIFT;
1933 length = (u64) blk_rq_bytes(rq);
1934
1935 if (!length) {
1936 dout("%s: zero-length request\n", __func__);
1921 __blk_end_request_all(rq, 0); 1937 __blk_end_request_all(rq, 0);
1922 continue; 1938 continue;
1923 } 1939 }
@@ -1947,9 +1963,6 @@ static void rbd_request_fn(struct request_queue *q)
1947 goto end_request; 1963 goto end_request;
1948 } 1964 }
1949 1965
1950 offset = (u64) blk_rq_pos(rq) << SECTOR_SHIFT;
1951 length = (u64) blk_rq_bytes(rq);
1952
1953 result = -EINVAL; 1966 result = -EINVAL;
1954 if (WARN_ON(offset && length > U64_MAX - offset + 1)) 1967 if (WARN_ON(offset && length > U64_MAX - offset + 1))
1955 goto end_request; /* Shouldn't happen */ 1968 goto end_request; /* Shouldn't happen */