Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 331649
b: refs/heads/master
c: df111be
h: refs/heads/master
i:
  331647: e201068
v: v3
  • Loading branch information
Alex Elder committed Oct 1, 2012
1 parent c3002fb commit 8157b6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 38f5f65e9d25b0a7270c337a35c724ca3d56f4d8
refs/heads/master: df111be6310fc41d059a485368e3c51a684859c2
23 changes: 21 additions & 2 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
#define SECTOR_SHIFT 9
#define SECTOR_SIZE (1ULL << SECTOR_SHIFT)

/* It might be useful to have this defined elsewhere too */

#define U64_MAX ((u64) (~0ULL))

#define RBD_DRV_NAME "rbd"
#define RBD_DRV_NAME_LONG "rbd (rados block device)"

Expand Down Expand Up @@ -691,8 +695,17 @@ static u64 rbd_get_segment(struct rbd_image_header *header,
static int rbd_get_num_segments(struct rbd_image_header *header,
u64 ofs, u64 len)
{
u64 start_seg = ofs >> header->obj_order;
u64 end_seg = (ofs + len - 1) >> header->obj_order;
u64 start_seg;
u64 end_seg;

if (!len)
return 0;
if (len - 1 > U64_MAX - ofs)
return -ERANGE;

start_seg = ofs >> header->obj_order;
end_seg = (ofs + len - 1) >> header->obj_order;

return end_seg - start_seg + 1;
}

Expand Down Expand Up @@ -1515,6 +1528,12 @@ static void rbd_rq_fn(struct request_queue *q)
size, (unsigned long long) blk_rq_pos(rq) * SECTOR_SIZE);

num_segs = rbd_get_num_segments(&rbd_dev->header, ofs, size);
if (num_segs <= 0) {
spin_lock_irq(q->queue_lock);
__blk_end_request_all(rq, num_segs);
ceph_put_snap_context(snapc);
continue;
}
coll = rbd_alloc_coll(num_segs);
if (!coll) {
spin_lock_irq(q->queue_lock);
Expand Down

0 comments on commit 8157b6c

Please sign in to comment.