aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-10-10 21:59:29 -0400
committerAlex Elder <elder@inktank.com>2012-10-26 18:18:08 -0400
commit4634246db8cb2e5117ef7c682efcc383fa3354f8 (patch)
treecf1e34687cad2c8058b8c6004c2f03ef8cc071cb /drivers/block
parentff2e4bb5b32f89c455979a4222a9b78007cde254 (diff)
rbd: consolidate rbd_do_op() calls
The two calls to rbd_do_op() from rbd_rq_fn() differ only in the value passed for the snapshot id and the snapshot context. For reads the snapshot always comes from the mapping, and for writes the snapshot id is always CEPH_NOSNAP. The snapshot context is always null for reads. For writes, the snapshot context always comes from the rbd header, but it is acquired under protection of header semaphore and could change thereafter, so we can't simply use what's available inside rbd_do_op(). Eliminate the snapid parameter from rbd_do_op(), and set it based on the I/O direction inside that function instead. Always pass the snapshot context acquired in the caller, but reset it to a null pointer inside rbd_do_op() if the operation is a read. As a result, there is no difference in the read and write calls to rbd_do_op() made in rbd_rq_fn(), so just call it unconditionally. 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.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index a29c6d2a49ad..d0328835bbd9 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1163,7 +1163,6 @@ done:
1163static int rbd_do_op(struct request *rq, 1163static int rbd_do_op(struct request *rq,
1164 struct rbd_device *rbd_dev, 1164 struct rbd_device *rbd_dev,
1165 struct ceph_snap_context *snapc, 1165 struct ceph_snap_context *snapc,
1166 u64 snapid,
1167 u64 ofs, u64 len, 1166 u64 ofs, u64 len,
1168 struct bio *bio, 1167 struct bio *bio,
1169 struct rbd_req_coll *coll, 1168 struct rbd_req_coll *coll,
@@ -1177,6 +1176,7 @@ static int rbd_do_op(struct request *rq,
1177 u32 payload_len; 1176 u32 payload_len;
1178 int opcode; 1177 int opcode;
1179 int flags; 1178 int flags;
1179 u64 snapid;
1180 1180
1181 seg_name = rbd_segment_name(rbd_dev, ofs); 1181 seg_name = rbd_segment_name(rbd_dev, ofs);
1182 if (!seg_name) 1182 if (!seg_name)
@@ -1187,10 +1187,13 @@ static int rbd_do_op(struct request *rq,
1187 if (rq_data_dir(rq) == WRITE) { 1187 if (rq_data_dir(rq) == WRITE) {
1188 opcode = CEPH_OSD_OP_WRITE; 1188 opcode = CEPH_OSD_OP_WRITE;
1189 flags = CEPH_OSD_FLAG_WRITE|CEPH_OSD_FLAG_ONDISK; 1189 flags = CEPH_OSD_FLAG_WRITE|CEPH_OSD_FLAG_ONDISK;
1190 snapid = CEPH_NOSNAP;
1190 payload_len = seg_len; 1191 payload_len = seg_len;
1191 } else { 1192 } else {
1192 opcode = CEPH_OSD_OP_READ; 1193 opcode = CEPH_OSD_OP_READ;
1193 flags = CEPH_OSD_FLAG_READ; 1194 flags = CEPH_OSD_FLAG_READ;
1195 snapc = NULL;
1196 snapid = rbd_dev->mapping.snap_id;
1194 payload_len = 0; 1197 payload_len = 0;
1195 } 1198 }
1196 1199
@@ -1518,24 +1521,13 @@ static void rbd_rq_fn(struct request_queue *q)
1518 kref_get(&coll->kref); 1521 kref_get(&coll->kref);
1519 bio = bio_chain_clone(&rq_bio, &next_bio, &bp, 1522 bio = bio_chain_clone(&rq_bio, &next_bio, &bp,
1520 op_size, GFP_ATOMIC); 1523 op_size, GFP_ATOMIC);
1521 if (!bio) { 1524 if (bio)
1525 (void) rbd_do_op(rq, rbd_dev, snapc,
1526 ofs, op_size,
1527 bio, coll, cur_seg);
1528 else
1522 rbd_coll_end_req_index(rq, coll, cur_seg, 1529 rbd_coll_end_req_index(rq, coll, cur_seg,
1523 -ENOMEM, op_size); 1530 -ENOMEM, op_size);
1524 goto next_seg;
1525 }
1526
1527 /* init OSD command: write or read */
1528 if (do_write)
1529 (void) rbd_do_op(rq, rbd_dev,
1530 snapc, CEPH_NOSNAP,
1531 ofs, op_size, bio,
1532 coll, cur_seg);
1533 else
1534 (void) rbd_do_op(rq, rbd_dev,
1535 NULL, rbd_dev->mapping.snap_id,
1536 ofs, op_size, bio,
1537 coll, cur_seg);
1538next_seg:
1539 size -= op_size; 1531 size -= op_size;
1540 ofs += op_size; 1532 ofs += op_size;
1541 1533