From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 2/7] libceph: clean up osd data field access functions
Date: Mon, 15 Apr 2013 22:37:47 -0500 [thread overview]
Message-ID: <516CC78B.9000608@inktank.com> (raw)
In-Reply-To: <516CC6E4.6070307@inktank.com>
There are a bunch of functions defined to encapsulate getting the
address of a data field for a particular op in an osd request.
They're all defined the same way, so create a macro to take the
place of all of them.
Two of these are used outside the osd client code, so preserve them
(but convert them to use the new macro internally). Stop exporting
the ones that aren't used elsewhere.
Signed-off-by: Alex Elder <elder@inktank.com>
---
net/ceph/osd_client.c | 48
+++++++++++++++---------------------------------
1 file changed, 15 insertions(+), 33 deletions(-)
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index b76e416..104353a 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -115,43 +115,25 @@ static void ceph_osd_data_bio_init(struct
ceph_osd_data *osd_data,
}
#endif /* CONFIG_BLOCK */
+#define osd_req_op_data(oreq, whch, typ, fld) \
+ ({ \
+ BUG_ON(whch >= (oreq)->r_num_ops); \
+ &(oreq)->r_ops[whch].typ.fld; \
+ })
+
struct ceph_osd_data *
osd_req_op_extent_osd_data(struct ceph_osd_request *osd_req,
unsigned int which)
{
- BUG_ON(which >= osd_req->r_num_ops);
-
- return &osd_req->r_ops[which].extent.osd_data;
+ return osd_req_op_data(osd_req, which, extent, osd_data);
}
EXPORT_SYMBOL(osd_req_op_extent_osd_data);
struct ceph_osd_data *
-osd_req_op_cls_request_info(struct ceph_osd_request *osd_req,
- unsigned int which)
-{
- BUG_ON(which >= osd_req->r_num_ops);
-
- return &osd_req->r_ops[which].cls.request_info;
-}
-EXPORT_SYMBOL(osd_req_op_cls_request_info); /* ??? */
-
-struct ceph_osd_data *
-osd_req_op_cls_request_data(struct ceph_osd_request *osd_req,
- unsigned int which)
-{
- BUG_ON(which >= osd_req->r_num_ops);
-
- return &osd_req->r_ops[which].cls.request_data;
-}
-EXPORT_SYMBOL(osd_req_op_cls_request_data); /* ??? */
-
-struct ceph_osd_data *
osd_req_op_cls_response_data(struct ceph_osd_request *osd_req,
unsigned int which)
{
- BUG_ON(which >= osd_req->r_num_ops);
-
- return &osd_req->r_ops[which].cls.response_data;
+ return osd_req_op_data(osd_req, which, cls, response_data);
}
EXPORT_SYMBOL(osd_req_op_cls_response_data); /* ??? */
@@ -162,7 +144,7 @@ void osd_req_op_extent_osd_data_pages(struct
ceph_osd_request *osd_req,
{
struct ceph_osd_data *osd_data;
- osd_data = osd_req_op_extent_osd_data(osd_req, which);
+ osd_data = osd_req_op_data(osd_req, which, extent, osd_data);
ceph_osd_data_pages_init(osd_data, pages, length, alignment,
pages_from_pool, own_pages);
}
@@ -173,7 +155,7 @@ void osd_req_op_extent_osd_data_pagelist(struct
ceph_osd_request *osd_req,
{
struct ceph_osd_data *osd_data;
- osd_data = osd_req_op_extent_osd_data(osd_req, which);
+ osd_data = osd_req_op_data(osd_req, which, extent, osd_data);
ceph_osd_data_pagelist_init(osd_data, pagelist);
}
EXPORT_SYMBOL(osd_req_op_extent_osd_data_pagelist);
@@ -183,7 +165,8 @@ void osd_req_op_extent_osd_data_bio(struct
ceph_osd_request *osd_req,
unsigned int which, struct bio *bio, size_t bio_length)
{
struct ceph_osd_data *osd_data;
- osd_data = osd_req_op_extent_osd_data(osd_req, which);
+
+ osd_data = osd_req_op_data(osd_req, which, extent, osd_data);
ceph_osd_data_bio_init(osd_data, bio, bio_length);
}
EXPORT_SYMBOL(osd_req_op_extent_osd_data_bio);
@@ -195,7 +178,7 @@ static void osd_req_op_cls_request_info_pagelist(
{
struct ceph_osd_data *osd_data;
- osd_data = osd_req_op_cls_request_info(osd_req, which);
+ osd_data = osd_req_op_data(osd_req, which, cls, request_info);
ceph_osd_data_pagelist_init(osd_data, pagelist);
}
@@ -205,7 +188,7 @@ void osd_req_op_cls_request_data_pagelist(
{
struct ceph_osd_data *osd_data;
- osd_data = osd_req_op_cls_request_data(osd_req, which);
+ osd_data = osd_req_op_data(osd_req, which, cls, request_data);
ceph_osd_data_pagelist_init(osd_data, pagelist);
}
EXPORT_SYMBOL(osd_req_op_cls_request_data_pagelist);
@@ -216,7 +199,7 @@ void osd_req_op_cls_response_data_pages(struct
ceph_osd_request *osd_req,
{
struct ceph_osd_data *osd_data;
- osd_data = osd_req_op_cls_response_data(osd_req, which);
+ osd_data = osd_req_op_data(osd_req, which, cls, response_data);
ceph_osd_data_pages_init(osd_data, pages, length, alignment,
pages_from_pool, own_pages);
}
@@ -241,7 +224,6 @@ static u64 ceph_osd_data_length(struct ceph_osd_data
*osd_data)
}
}
-
static void ceph_osd_data_release(struct ceph_osd_data *osd_data)
{
if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES && osd_data->own_pages) {
--
1.7.9.5
next prev parent reply other threads:[~2013-04-16 3:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-16 3:35 [PATCH 0/7] rbd: existence check or layered writes Alex Elder
2013-04-16 3:36 ` [PATCH 1/7] libceph: kill off osd data write_request parameters Alex Elder
2013-04-16 3:37 ` Alex Elder [this message]
2013-04-16 3:38 ` [PATCH 3/7] libceph: support raw data requests Alex Elder
2013-04-16 3:38 ` [PATCH 4/7] rbd: adjust image object request ref counting Alex Elder
2013-04-16 3:38 ` [PATCH 5/7] rbd: always check IMG_DATA flag Alex Elder
2013-04-16 3:38 ` [PATCH 6/7] rbd: add target object existence flags Alex Elder
2013-04-16 3:38 ` [PATCH 7/7] rbd: issue stat request before layered write Alex Elder
2013-04-18 12:44 ` [PATCH 7/7, v2] " Alex Elder
2013-04-20 3:03 ` Josh Durgin
2013-04-20 3:04 ` [PATCH 0/7] rbd: existence check or layered writes Josh Durgin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=516CC78B.9000608@inktank.com \
--to=elder@inktank.com \
--cc=ceph-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.