Skip to contentSkip to conversation

rbd: drop some unneeded parameters

PATCH In review Alex Elder 2 participants 7 messages Jan 3, 2013 – Jan 16, 2013

Subsystems (3)
lore
Share & tools
lore

Alex Elder

author
#0 lore raw

cover rbd: drop some unneeded parameters

This series cleans up some parameter lists, eliminating parameters that don't need to be used.

-Alex

[PATCH REPOST 1/5] rbd: drop oid parameters from ceph_osdc_build_request() [PATCH REPOST 2/5] rbd: drop snapid parameter from rbd_req_sync_read() [PATCH REPOST 3/5] rbd: drop flags parameter from rbd_req_sync_exec() [PATCH REPOST 4/5] rbd: kill rbd_req_sync_op() snapc and snapid parameters [PATCH REPOST 5/5] rbd: don't bother setting snapid in rbd_do_request()

author
#1 lore raw

PATCH 1/5 rbd: drop oid parameters from ceph_osdc_build_request()

The last two parameters to ceph_osd_build_request() describe the object id, but the values passed always come from the osd request structure whose address is also provided. Get rid of those last two parameters.

---
 drivers/block/rbd.c             |    6 +-----
 include/linux/ceph/osd_client.h |    4 +---
 net/ceph/osd_client.c           |   13 +++++--------
 3 files changed, 7 insertions(+), 16 deletions(-)
drivers/block/rbd.c +1 -5
index 8e030d1..5bca129 100644
@@ -1176,11 +1176,7 @@ static int rbd_do_request(struct request *rq,
 				snapid, ofs, &len, &bno, osd_req, ops);
 	rbd_assert(ret == 0);
 
-	ceph_osdc_build_request(osd_req, ofs, &len,
-				ops,
-				snapc,
-				&mtime,
-				osd_req->r_oid, osd_req->r_oid_len);
+	ceph_osdc_build_request(osd_req, ofs, &len, ops, snapc, &mtime);
 
 	if (linger_req) {
 		ceph_osdc_set_request_linger(osdc, osd_req);
(quoted diff) +0 -0

b/include/linux/ceph/osd_client.h
index d9b880e..f2e5d2c 100644

include/linux/ceph/osd_client.h +0 -0
@@ -227,9 +227,7 @@ extern void ceph_osdc_build_request(struct

ceph_osd_request *req,
u64 off, u64 *plen, struct ceph_osd_req_op *src_ops, struct ceph_snap_context *snapc,

-				    struct timespec *mtime,
-				    const char *oid,
-				    int oid_len);
+				    struct timespec *mtime);

extern struct ceph_osd_request *ceph_osdc_new_request(struct
ceph_osd_client *,
struct ceph_file_layout *layout,

net/ceph/osd_client.c +0 -0
index 5f9f65a..89e7587 100644
@@ -368,9 +368,7 @@ void ceph_osdc_build_request(struct ceph_osd_request

*req,
u64 off, u64 *plen, struct ceph_osd_req_op *src_ops, struct ceph_snap_context *snapc,

-			     struct timespec *mtime,
-			     const char *oid,
-			     int oid_len)
+			     struct timespec *mtime)

{
struct ceph_msg *msg = req->r_request;
struct ceph_osd_request_head *head;
@@ -397,9 +395,9 @@ void ceph_osdc_build_request(struct ceph_osd_request *req,

/* fill in oid */
- head->object_len = cpu_to_le32(oid_len);
- memcpy(p, oid, oid_len);
- p += oid_len;
+ head->object_len = cpu_to_le32(req->r_oid_len);
+ memcpy(p, req->r_oid, req->r_oid_len);
+ p += req->r_oid_len;

src_op = src_ops;
while (src_op->op) {
@@ -498,8 +496,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,

ceph_osdc_build_request(req, off, plen, ops,
snapc,
- mtime,
- req->r_oid, req->r_oid_len);
+ mtime);

return req;
}

Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/5 rbd: drop snapid parameter from rbd_req_sync_read()

In reply to Alex Elder

There is only one caller of rbd_req_sync_read(), and it passes CEPH_NOSNAP as the snapshot id argument. Delete that parameter and just use CEPH_NOSNAP within the function.

---
 drivers/block/rbd.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/block/rbd.c +0 -1
index 5bca129..b86289f 100644
@@ -1368,7 +1368,6 @@ done:
  * Request sync osd read
  */
 static int rbd_req_sync_read(struct rbd_device *rbd_dev,
-			  u64 snapid,
 			  const char *object_name,
 			  u64 ofs, u64 len,
 			  char *buf,
@@ -1382,7 +1381,7 @@ static int rbd_req_sync_read(struct rbd_device

*rbd_dev,
return -ENOMEM;

ret = rbd_req_sync_op(rbd_dev, NULL,
- snapid,
+ CEPH_NOSNAP,
CEPH_OSD_FLAG_READ,
ops, object_name, ofs, len, buf, NULL, ver);
rbd_destroy_ops(ops);
@@ -1797,8 +1796,7 @@ rbd_dev_v1_header_read(struct rbd_device *rbd_dev, u64 *version)
if (!ondisk)
return ERR_PTR(-ENOMEM);

- ret = rbd_req_sync_read(rbd_dev, CEPH_NOSNAP,
- rbd_dev->header_name,
+ ret = rbd_req_sync_read(rbd_dev, rbd_dev->header_name,
0, size,
(char *) ondisk, version);

Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH 3/5 rbd: drop flags parameter from rbd_req_sync_exec()

In reply to Alex Elder

All callers of rbd_req_sync_exec() pass CEPH_OSD_FLAG_READ as their flags argument. Delete that parameter and use CEPH_OSD_FLAG_READ within the function. If we find a need to support write operations we can add it back again.

---
 drivers/block/rbd.c |   27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)
drivers/block/rbd.c +0 -0
index b86289f..126d5c0 100644
@@ -1524,7 +1524,6 @@ static int rbd_req_sync_exec(struct rbd_device

*rbd_dev,
size_t outbound_size,
char *inbound,
size_t inbound_size,
- int flags,
u64 *ver)
{
struct ceph_osd_req_op *ops;
@@ -1555,8 +1554,7 @@ static int rbd_req_sync_exec(struct rbd_device *rbd_dev,
ops[0].cls.indata_len = outbound_size;

ret = rbd_req_sync_op(rbd_dev, NULL,

-			       CEPH_NOSNAP,
-			       flags, ops,
+			       CEPH_NOSNAP, CEPH_OSD_FLAG_READ, ops,

object_name, 0, inbound_size, inbound, NULL, ver);

@@ -2416,8 +2414,7 @@ static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id,
ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
"rbd", "get_size",
(char *) &snapid, sizeof (snapid),
- (char *) &size_buf, sizeof (size_buf),
- CEPH_OSD_FLAG_READ, NULL);
+ (char *) &size_buf, sizeof (size_buf), NULL);
dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); if (ret < 0)
return ret;
@@ -2452,8 +2449,7 @@ static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev)
ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
"rbd", "get_object_prefix",
NULL, 0,
- reply_buf, RBD_OBJ_PREFIX_LEN_MAX,
- CEPH_OSD_FLAG_READ, NULL);
+ reply_buf, RBD_OBJ_PREFIX_LEN_MAX, NULL);
dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); if (ret < 0)
goto out;
@@ -2492,7 +2488,7 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
"rbd", "get_features",
(char *) &snapid, sizeof (snapid), (char *) &features_buf, sizeof (features_buf),
- CEPH_OSD_FLAG_READ, NULL);
+ NULL);
dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); if (ret < 0)
return ret;
@@ -2547,8 +2543,7 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
"rbd", "get_parent",
(char *) &snapid, sizeof (snapid),
- (char *) reply_buf, size,
- CEPH_OSD_FLAG_READ, NULL);
+ (char *) reply_buf, size, NULL);
dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); if (ret < 0)
goto out_err;
@@ -2613,8 +2608,7 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
ret = rbd_req_sync_exec(rbd_dev, RBD_DIRECTORY,
"rbd", "dir_get_name",
image_id, image_id_size,
- (char *) reply_buf, size,
- CEPH_OSD_FLAG_READ, NULL);
+ (char *) reply_buf, size, NULL);
if (ret < 0)
goto out;
p = reply_buf;
@@ -2720,8 +2714,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev, u64 *ver)
ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
"rbd", "get_snapcontext",
NULL, 0,
- reply_buf, size,
- CEPH_OSD_FLAG_READ, ver);
+ reply_buf, size, ver);
dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); if (ret < 0)
goto out;
@@ -2790,8 +2783,7 @@ static char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev, u32 which)
ret = rbd_req_sync_exec(rbd_dev, rbd_dev->header_name,
"rbd", "get_snapshot_name",
(char *) &snap_id, sizeof (snap_id),
- reply_buf, size,
- CEPH_OSD_FLAG_READ, NULL);
+ reply_buf, size, NULL);
dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); if (ret < 0)
goto out;
@@ -3399,8 +3391,7 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev)
ret = rbd_req_sync_exec(rbd_dev, object_name,
"rbd", "get_id",
NULL, 0,
- response, RBD_IMAGE_ID_LEN_MAX,
- CEPH_OSD_FLAG_READ, NULL);
+ response, RBD_IMAGE_ID_LEN_MAX, NULL);
dout("%s: rbd_req_sync_exec returned %d\n", __func__, ret); if (ret < 0)
goto out;

Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH 4/5 rbd: kill rbd_req_sync_op() snapc and snapid parameters

In reply to Alex Elder

The snapc and snapid parameters to rbd_req_sync_op() always take the values NULL and CEPH_NOSNAP, respectively. So just get rid of them and use those values where needed.

---
 drivers/block/rbd.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/block/rbd.c +0 -0
index 126d5c0..821d93c 100644
@@ -1257,8 +1257,6 @@ static void rbd_simple_req_cb(struct

ceph_osd_request *osd_req,
* Do a synchronous ceph osd operation
*/
static int rbd_req_sync_op(struct rbd_device *rbd_dev,
- struct ceph_snap_context *snapc,
- u64 snapid,
int flags,
struct ceph_osd_req_op *ops,
const char *object_name,
@@ -1278,7 +1276,7 @@ static int rbd_req_sync_op(struct rbd_device *rbd_dev,
if (IS_ERR(pages))
return PTR_ERR(pages);

- ret = rbd_do_request(NULL, rbd_dev, snapc, snapid,
+ ret = rbd_do_request(NULL, rbd_dev, NULL, CEPH_NOSNAP,
object_name, ofs, inbound_size, NULL, pages, num_pages,
flags,
@@ -1380,9 +1378,7 @@ static int rbd_req_sync_read(struct rbd_device *rbd_dev,
if (!ops)
return -ENOMEM;

- ret = rbd_req_sync_op(rbd_dev, NULL,
- CEPH_NOSNAP,
- CEPH_OSD_FLAG_READ,
+ ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ,
ops, object_name, ofs, len, buf, NULL, ver);
rbd_destroy_ops(ops);

@@ -1461,8 +1457,7 @@ static int rbd_req_sync_watch(struct rbd_device *rbd_dev)
ops[0].watch.cookie = cpu_to_le64(rbd_dev->watch_event->cookie); ops[0].watch.flag = 1;

- ret = rbd_req_sync_op(rbd_dev, NULL,
- CEPH_NOSNAP,
+ ret = rbd_req_sync_op(rbd_dev,
CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, ops,
rbd_dev->header_name,
@@ -1499,8 +1494,7 @@ static int rbd_req_sync_unwatch(struct rbd_device *rbd_dev)
ops[0].watch.cookie = cpu_to_le64(rbd_dev->watch_event->cookie); ops[0].watch.flag = 0;

- ret = rbd_req_sync_op(rbd_dev, NULL,
- CEPH_NOSNAP,
+ ret = rbd_req_sync_op(rbd_dev,
CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, ops,
rbd_dev->header_name,
@@ -1553,8 +1547,7 @@ static int rbd_req_sync_exec(struct rbd_device *rbd_dev,
ops[0].cls.indata = outbound;
ops[0].cls.indata_len = outbound_size;

- ret = rbd_req_sync_op(rbd_dev, NULL,
- CEPH_NOSNAP, CEPH_OSD_FLAG_READ, ops,
+ ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ, ops,
object_name, 0, inbound_size, inbound, NULL, ver);

Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH 5/5 rbd: don't bother setting snapid in rbd_do_request()

In reply to Alex Elder

For some reason, the snapid field of the osd request header is explicitly set to CEPH_NOSNAP in rbd_do_request(). Just a few lines later--with no code that would access this field in between--a call is made to ceph_calc_raw_layout() passing the snapid provided to rbd_do_request(), which encodes the snapid value it is provided into that field instead.

In other words, there is no need to fill in CEPH_NOSNAP, and doing so suggests it might be necessary. Don't do that any more.

---
 drivers/block/rbd.c |    4 ----
 1 file changed, 4 deletions(-)
drivers/block/rbd.c +0 -4
index 821d93c..cc12154 100644
@@ -1132,7 +1132,6 @@ static int rbd_do_request(struct request *rq,
 	u64 bno;
 	struct timespec mtime = CURRENT_TIME;
 	struct rbd_request *rbd_req;
-	struct ceph_osd_request_head *reqhead;
 	struct ceph_osd_client *osdc;
 
 	rbd_req = kzalloc(sizeof(*rbd_req), GFP_NOIO);
@@ -1165,9 +1164,6 @@ static int rbd_do_request(struct request *rq,
 
 	osd_req->r_priv = rbd_req;
 
-	reqhead = osd_req->r_request->front.iov_base;
-	reqhead->snapid = cpu_to_le64(CEPH_NOSNAP);
-
 	strncpy(osd_req->r_oid, object_name, sizeof(osd_req->r_oid));
 	osd_req->r_oid_len = strlen(osd_req->r_oid);
 
Signature · 1 line
1.7.9.5
Reviewed-by on the v1 series
#6 lore raw
In reply to Alex Elder
Quoted 10 lines · Alex Elder

This series cleans up some parameter lists, eliminating parameters that don't need to be used.

-Alex

[PATCH REPOST 1/5] rbd: drop oid parameters from ceph_osdc_build_request() [PATCH REPOST 2/5] rbd: drop snapid parameter from rbd_req_sync_read() [PATCH REPOST 3/5] rbd: drop flags parameter from rbd_req_sync_exec() [PATCH REPOST 4/5] rbd: kill rbd_req_sync_op() snapc and snapid parameters [PATCH REPOST 5/5] rbd: don't bother setting snapid in rbd_do_request()

These look good to me.