Skip to content

Commit e28eded

Browse files
committed
rbd: factor out __rbd_osd_req_create()
Allow passing a custom snapshot context: NULL for read and an empty snapshot context for deep-copyup. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 356889c commit e28eded

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

drivers/block/rbd.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,18 +1486,16 @@ static void rbd_osd_req_format_write(struct rbd_obj_request *obj_request)
14861486
}
14871487

14881488
static struct ceph_osd_request *
1489-
rbd_osd_req_create(struct rbd_obj_request *obj_req, unsigned int num_ops)
1489+
__rbd_osd_req_create(struct rbd_obj_request *obj_req,
1490+
struct ceph_snap_context *snapc, unsigned int num_ops)
14901491
{
1491-
struct rbd_img_request *img_req = obj_req->img_request;
1492-
struct rbd_device *rbd_dev = img_req->rbd_dev;
1492+
struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev;
14931493
struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc;
14941494
struct ceph_osd_request *req;
14951495
const char *name_format = rbd_dev->image_format == 1 ?
14961496
RBD_V1_DATA_FORMAT : RBD_V2_DATA_FORMAT;
14971497

1498-
req = ceph_osdc_alloc_request(osdc,
1499-
(rbd_img_is_write(img_req) ? img_req->snapc : NULL),
1500-
num_ops, false, GFP_NOIO);
1498+
req = ceph_osdc_alloc_request(osdc, snapc, num_ops, false, GFP_NOIO);
15011499
if (!req)
15021500
return NULL;
15031501

@@ -1522,6 +1520,13 @@ rbd_osd_req_create(struct rbd_obj_request *obj_req, unsigned int num_ops)
15221520
return NULL;
15231521
}
15241522

1523+
static struct ceph_osd_request *
1524+
rbd_osd_req_create(struct rbd_obj_request *obj_req, unsigned int num_ops)
1525+
{
1526+
return __rbd_osd_req_create(obj_req, obj_req->img_request->snapc,
1527+
num_ops);
1528+
}
1529+
15251530
static void rbd_osd_req_destroy(struct ceph_osd_request *osd_req)
15261531
{
15271532
ceph_osdc_put_request(osd_req);
@@ -1769,7 +1774,7 @@ static void rbd_osd_req_setup_data(struct rbd_obj_request *obj_req, u32 which)
17691774

17701775
static int rbd_obj_setup_read(struct rbd_obj_request *obj_req)
17711776
{
1772-
obj_req->osd_req = rbd_osd_req_create(obj_req, 1);
1777+
obj_req->osd_req = __rbd_osd_req_create(obj_req, NULL, 1);
17731778
if (!obj_req->osd_req)
17741779
return -ENOMEM;
17751780

0 commit comments

Comments
 (0)