* [PATCH 0/3] rbd: a few picky changes
@ 2012-11-08 14:06 Alex Elder
2012-11-08 14:08 ` [PATCH 1/3] rbd: standardize rbd_request variable names Alex Elder
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alex Elder @ 2012-11-08 14:06 UTC (permalink / raw)
To: ceph-devel@vger.kernel.org
These three changes are pretty trivial. -Alex
[PATCH 1/3] rbd: standardize rbd_request variable names
[PATCH 2/3] rbd: standardize ceph_osd_request variable names
[PATCH 3/3] rbd: be picky about osd request status type
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] rbd: standardize rbd_request variable names
2012-11-08 14:06 [PATCH 0/3] rbd: a few picky changes Alex Elder
@ 2012-11-08 14:08 ` Alex Elder
2012-11-08 14:08 ` [PATCH 2/3] rbd: standardize ceph_osd_request " Alex Elder
2012-11-08 14:08 ` [PATCH 3/3] rbd: be picky about osd request status type Alex Elder
2 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2012-11-08 14:08 UTC (permalink / raw)
To: ceph-devel@vger.kernel.org
There are two names used for items of rbd_request structure type:
"req" and "req_data". The former name is also used to represent
items of pointers to struct ceph_osd_request.
Change all variables that have these names so they are instead
called "rbd_req" consistently.
Signed-off-by: Alex Elder <elder@inktank.com>
---
drivers/block/rbd.c | 50
++++++++++++++++++++++++++------------------------
1 file changed, 26 insertions(+), 24 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 5de49a1..9d8b406 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1090,10 +1090,12 @@ static void rbd_coll_end_req_index(struct
request *rq,
spin_unlock_irq(q->queue_lock);
}
-static void rbd_coll_end_req(struct rbd_request *req,
+static void rbd_coll_end_req(struct rbd_request *rbd_req,
int ret, u64 len)
{
- rbd_coll_end_req_index(req->rq, req->coll, req->coll_index, ret, len);
+ rbd_coll_end_req_index(rbd_req->rq,
+ rbd_req->coll, rbd_req->coll_index,
+ ret, len);
}
/*
@@ -1121,12 +1123,12 @@ static int rbd_do_request(struct request *rq,
int ret;
u64 bno;
struct timespec mtime = CURRENT_TIME;
- struct rbd_request *req_data;
+ struct rbd_request *rbd_req;
struct ceph_osd_request_head *reqhead;
struct ceph_osd_client *osdc;
- req_data = kzalloc(sizeof(*req_data), GFP_NOIO);
- if (!req_data) {
+ rbd_req = kzalloc(sizeof(*rbd_req), GFP_NOIO);
+ if (!rbd_req) {
if (coll)
rbd_coll_end_req_index(rq, coll, coll_index,
-ENOMEM, len);
@@ -1134,8 +1136,8 @@ static int rbd_do_request(struct request *rq,
}
if (coll) {
- req_data->coll = coll;
- req_data->coll_index = coll_index;
+ rbd_req->coll = coll;
+ rbd_req->coll_index = coll_index;
}
dout("rbd_do_request object_name=%s ofs=%llu len=%llu coll=%p[%d]\n",
@@ -1152,12 +1154,12 @@ static int rbd_do_request(struct request *rq,
req->r_callback = rbd_cb;
- req_data->rq = rq;
- req_data->bio = bio;
- req_data->pages = pages;
- req_data->len = len;
+ rbd_req->rq = rq;
+ rbd_req->bio = bio;
+ rbd_req->pages = pages;
+ rbd_req->len = len;
- req->r_priv = req_data;
+ req->r_priv = rbd_req;
reqhead = req->r_request->front.iov_base;
reqhead->snapid = cpu_to_le64(CEPH_NOSNAP);
@@ -1202,11 +1204,11 @@ static int rbd_do_request(struct request *rq,
return ret;
done_err:
- bio_chain_put(req_data->bio);
+ bio_chain_put(rbd_req->bio);
ceph_osdc_put_request(req);
done_pages:
- rbd_coll_end_req(req_data, ret, len);
- kfree(req_data);
+ rbd_coll_end_req(rbd_req, ret, len);
+ kfree(rbd_req);
return ret;
}
@@ -1215,7 +1217,7 @@ done_pages:
*/
static void rbd_req_cb(struct ceph_osd_request *req, struct ceph_msg *msg)
{
- struct rbd_request *req_data = req->r_priv;
+ struct rbd_request *rbd_req = req->r_priv;
struct ceph_osd_reply_head *replyhead;
struct ceph_osd_op *op;
__s32 rc;
@@ -1234,20 +1236,20 @@ static void rbd_req_cb(struct ceph_osd_request
*req, struct ceph_msg *msg)
(unsigned long long) bytes, read_op, (int) rc);
if (rc == -ENOENT && read_op) {
- zero_bio_chain(req_data->bio, 0);
+ zero_bio_chain(rbd_req->bio, 0);
rc = 0;
- } else if (rc == 0 && read_op && bytes < req_data->len) {
- zero_bio_chain(req_data->bio, bytes);
- bytes = req_data->len;
+ } else if (rc == 0 && read_op && bytes < rbd_req->len) {
+ zero_bio_chain(rbd_req->bio, bytes);
+ bytes = rbd_req->len;
}
- rbd_coll_end_req(req_data, rc, bytes);
+ rbd_coll_end_req(rbd_req, rc, bytes);
- if (req_data->bio)
- bio_chain_put(req_data->bio);
+ if (rbd_req->bio)
+ bio_chain_put(rbd_req->bio);
ceph_osdc_put_request(req);
- kfree(req_data);
+ kfree(rbd_req);
}
static void rbd_simple_req_cb(struct ceph_osd_request *req, struct
ceph_msg *msg)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] rbd: standardize ceph_osd_request variable names
2012-11-08 14:06 [PATCH 0/3] rbd: a few picky changes Alex Elder
2012-11-08 14:08 ` [PATCH 1/3] rbd: standardize rbd_request variable names Alex Elder
@ 2012-11-08 14:08 ` Alex Elder
2012-11-08 14:08 ` [PATCH 3/3] rbd: be picky about osd request status type Alex Elder
2 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2012-11-08 14:08 UTC (permalink / raw)
To: ceph-devel@vger.kernel.org
There are spots where a ceph_osds_request pointer variable is given
the name "req". Since we're dealing with (at least) three types of
requests (block layer, rbd, and osd), I find this slightly
distracting.
Change such instances to use "osd_req" consistently to make the
abstraction represented a little more obvious.
Signed-off-by: Alex Elder <elder@inktank.com>
---
drivers/block/rbd.c | 60
++++++++++++++++++++++++++-------------------------
1 file changed, 31 insertions(+), 29 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 9d8b406..caff180 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1113,12 +1113,12 @@ static int rbd_do_request(struct request *rq,
struct ceph_osd_req_op *ops,
struct rbd_req_coll *coll,
int coll_index,
- void (*rbd_cb)(struct ceph_osd_request *req,
- struct ceph_msg *msg),
+ void (*rbd_cb)(struct ceph_osd_request *,
+ struct ceph_msg *),
struct ceph_osd_request **linger_req,
u64 *ver)
{
- struct ceph_osd_request *req;
+ struct ceph_osd_request *osd_req;
struct ceph_file_layout *layout;
int ret;
u64 bno;
@@ -1145,67 +1145,68 @@ static int rbd_do_request(struct request *rq,
(unsigned long long) len, coll, coll_index);
osdc = &rbd_dev->rbd_client->client->osdc;
- req = ceph_osdc_alloc_request(osdc, flags, snapc, ops,
+ osd_req = ceph_osdc_alloc_request(osdc, flags, snapc, ops,
false, GFP_NOIO, pages, bio);
- if (!req) {
+ if (!osd_req) {
ret = -ENOMEM;
goto done_pages;
}
- req->r_callback = rbd_cb;
+ osd_req->r_callback = rbd_cb;
rbd_req->rq = rq;
rbd_req->bio = bio;
rbd_req->pages = pages;
rbd_req->len = len;
- req->r_priv = rbd_req;
+ osd_req->r_priv = rbd_req;
- reqhead = req->r_request->front.iov_base;
+ reqhead = osd_req->r_request->front.iov_base;
reqhead->snapid = cpu_to_le64(CEPH_NOSNAP);
- strncpy(req->r_oid, object_name, sizeof(req->r_oid));
- req->r_oid_len = strlen(req->r_oid);
+ strncpy(osd_req->r_oid, object_name, sizeof(osd_req->r_oid));
+ osd_req->r_oid_len = strlen(osd_req->r_oid);
- layout = &req->r_file_layout;
+ layout = &osd_req->r_file_layout;
memset(layout, 0, sizeof(*layout));
layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
layout->fl_stripe_count = cpu_to_le32(1);
layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
layout->fl_pg_pool = cpu_to_le32((int) rbd_dev->spec->pool_id);
ret = ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
- req, ops);
+ osd_req, ops);
rbd_assert(ret == 0);
- ceph_osdc_build_request(req, ofs, &len,
+ ceph_osdc_build_request(osd_req, ofs, &len,
ops,
snapc,
&mtime,
- req->r_oid, req->r_oid_len);
+ osd_req->r_oid, osd_req->r_oid_len);
if (linger_req) {
- ceph_osdc_set_request_linger(osdc, req);
- *linger_req = req;
+ ceph_osdc_set_request_linger(osdc, osd_req);
+ *linger_req = osd_req;
}
- ret = ceph_osdc_start_request(osdc, req, false);
+ ret = ceph_osdc_start_request(osdc, osd_req, false);
if (ret < 0)
goto done_err;
if (!rbd_cb) {
- ret = ceph_osdc_wait_request(osdc, req);
+ u64 version;
+
+ ret = ceph_osdc_wait_request(osdc, osd_req);
+ version = le64_to_cpu(osd_req->r_reassert_version.version);
if (ver)
- *ver = le64_to_cpu(req->r_reassert_version.version);
- dout("reassert_ver=%llu\n",
- (unsigned long long)
- le64_to_cpu(req->r_reassert_version.version));
- ceph_osdc_put_request(req);
+ *ver = version;
+ dout("reassert_ver=%llu\n", (unsigned long long) version);
+ ceph_osdc_put_request(osd_req);
}
return ret;
done_err:
bio_chain_put(rbd_req->bio);
- ceph_osdc_put_request(req);
+ ceph_osdc_put_request(osd_req);
done_pages:
rbd_coll_end_req(rbd_req, ret, len);
kfree(rbd_req);
@@ -1215,9 +1216,9 @@ done_pages:
/*
* Ceph osd op callback
*/
-static void rbd_req_cb(struct ceph_osd_request *req, struct ceph_msg *msg)
+static void rbd_req_cb(struct ceph_osd_request *osd_req, struct
ceph_msg *msg)
{
- struct rbd_request *rbd_req = req->r_priv;
+ struct rbd_request *rbd_req = osd_req->r_priv;
struct ceph_osd_reply_head *replyhead;
struct ceph_osd_op *op;
__s32 rc;
@@ -1248,13 +1249,14 @@ static void rbd_req_cb(struct ceph_osd_request
*req, struct ceph_msg *msg)
if (rbd_req->bio)
bio_chain_put(rbd_req->bio);
- ceph_osdc_put_request(req);
+ ceph_osdc_put_request(osd_req);
kfree(rbd_req);
}
-static void rbd_simple_req_cb(struct ceph_osd_request *req, struct
ceph_msg *msg)
+static void rbd_simple_req_cb(struct ceph_osd_request *osd_req,
+ struct ceph_msg *msg)
{
- ceph_osdc_put_request(req);
+ ceph_osdc_put_request(osd_req);
}
/*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] rbd: be picky about osd request status type
2012-11-08 14:06 [PATCH 0/3] rbd: a few picky changes Alex Elder
2012-11-08 14:08 ` [PATCH 1/3] rbd: standardize rbd_request variable names Alex Elder
2012-11-08 14:08 ` [PATCH 2/3] rbd: standardize ceph_osd_request " Alex Elder
@ 2012-11-08 14:08 ` Alex Elder
2 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2012-11-08 14:08 UTC (permalink / raw)
To: ceph-devel@vger.kernel.org
The result field in a ceph osd reply header is a signed 32-bit type,
but rbd code often casually uses int to represent it.
The following changes the types of variables that handle this result
value to be "s32" instead of "int" to be completely explicit about
it. Only at the point we pass that result to __blk_end_request()
does the type get converted to the plain old int defined for that
interface.
There is almost certainly no binary impact of this change, but I
prefer to show the exact size and signedness of the value since we
know it.
Signed-off-by: Alex Elder <elder@inktank.com>
---
drivers/block/rbd.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index caff180..be18b5f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -171,7 +171,7 @@ struct rbd_client {
*/
struct rbd_req_status {
int done;
- int rc;
+ s32 rc;
u64 bytes;
};
@@ -1055,13 +1055,13 @@ static void rbd_destroy_ops(struct
ceph_osd_req_op *ops)
static void rbd_coll_end_req_index(struct request *rq,
struct rbd_req_coll *coll,
int index,
- int ret, u64 len)
+ s32 ret, u64 len)
{
struct request_queue *q;
int min, max, i;
dout("rbd_coll_end_req_index %p index %d ret %d len %llu\n",
- coll, index, ret, (unsigned long long) len);
+ coll, index, (int) ret, (unsigned long long) len);
if (!rq)
return;
@@ -1082,7 +1082,7 @@ static void rbd_coll_end_req_index(struct request *rq,
max++;
for (i = min; i<max; i++) {
- __blk_end_request(rq, coll->status[i].rc,
+ __blk_end_request(rq, (int) coll->status[i].rc,
coll->status[i].bytes);
coll->num_done++;
kref_put(&coll->kref, rbd_coll_release);
@@ -1091,7 +1091,7 @@ static void rbd_coll_end_req_index(struct request *rq,
}
static void rbd_coll_end_req(struct rbd_request *rbd_req,
- int ret, u64 len)
+ s32 ret, u64 len)
{
rbd_coll_end_req_index(rbd_req->rq,
rbd_req->coll, rbd_req->coll_index,
@@ -1131,7 +1131,7 @@ static int rbd_do_request(struct request *rq,
if (!rbd_req) {
if (coll)
rbd_coll_end_req_index(rq, coll, coll_index,
- -ENOMEM, len);
+ (s32) -ENOMEM, len);
return -ENOMEM;
}
@@ -1208,7 +1208,7 @@ done_err:
bio_chain_put(rbd_req->bio);
ceph_osdc_put_request(osd_req);
done_pages:
- rbd_coll_end_req(rbd_req, ret, len);
+ rbd_coll_end_req(rbd_req, (s32) ret, len);
kfree(rbd_req);
return ret;
}
@@ -1221,7 +1221,7 @@ static void rbd_req_cb(struct ceph_osd_request
*osd_req, struct ceph_msg *msg)
struct rbd_request *rbd_req = osd_req->r_priv;
struct ceph_osd_reply_head *replyhead;
struct ceph_osd_op *op;
- __s32 rc;
+ s32 rc;
u64 bytes;
int read_op;
@@ -1229,14 +1229,14 @@ static void rbd_req_cb(struct ceph_osd_request
*osd_req, struct ceph_msg *msg)
replyhead = msg->front.iov_base;
WARN_ON(le32_to_cpu(replyhead->num_ops) == 0);
op = (void *)(replyhead + 1);
- rc = le32_to_cpu(replyhead->result);
+ rc = (s32) le32_to_cpu(replyhead->result);
bytes = le64_to_cpu(op->extent.length);
read_op = (le16_to_cpu(op->op) == CEPH_OSD_OP_READ);
dout("rbd_req_cb bytes=%llu readop=%d rc=%d\n",
(unsigned long long) bytes, read_op, (int) rc);
- if (rc == -ENOENT && read_op) {
+ if (rc == (s32) -ENOENT && read_op) {
zero_bio_chain(rbd_req->bio, 0);
rc = 0;
} else if (rc == 0 && read_op && bytes < rbd_req->len) {
@@ -1681,7 +1681,8 @@ static void rbd_rq_fn(struct request_queue *q)
bio_chain, coll, cur_seg);
else
rbd_coll_end_req_index(rq, coll, cur_seg,
- -ENOMEM, chain_size);
+ (s32) -ENOMEM,
+ chain_size);
size -= chain_size;
ofs += chain_size;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-08 14:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-08 14:06 [PATCH 0/3] rbd: a few picky changes Alex Elder
2012-11-08 14:08 ` [PATCH 1/3] rbd: standardize rbd_request variable names Alex Elder
2012-11-08 14:08 ` [PATCH 2/3] rbd: standardize ceph_osd_request " Alex Elder
2012-11-08 14:08 ` [PATCH 3/3] rbd: be picky about osd request status type Alex Elder
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.