All of lore.kernel.org
 help / color / mirror / Atom feed
From: Douglas Fuller <dfuller@redhat.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH RFC 4/6] osd_client: added single object method call
Date: Tue, 30 Jun 2015 13:27:59 -0700	[thread overview]
Message-ID: <06080d26bb1873f93d602df947772614551768e9.1435695881.git.dfuller@redhat.com> (raw)
In-Reply-To: <cover.1435695881.git.dfuller@redhat.com>
In-Reply-To: <cover.1435695881.git.dfuller@redhat.com>

Add a convenience function to osd_client to call class ops. The interface
assumes that request and reply data each consist of single pages.

Signed-off-by: Douglas Fuller <dfuller@redhat.com>
---
 include/linux/ceph/osd_client.h |  6 ++++++
 net/ceph/osd_client.c           | 44 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 7fbbd22..40561ff 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -362,6 +362,12 @@ extern struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *,
 				      u32 truncate_seq, u64 truncate_size,
 				      bool use_mempool);
 
+extern int ceph_osd_op_cls_call(struct ceph_osd_client *osdc, int poolid,
+				char *obj_name, char *class, char *method,
+				int flags, struct page **req_data,
+				size_t req_len, struct page **resp_data,
+				size_t *resp_len);
+
 extern void ceph_osdc_set_request_linger(struct ceph_osd_client *osdc,
 					 struct ceph_osd_request *req);
 
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index da451eb..9db3657 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -898,6 +898,50 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
 }
 EXPORT_SYMBOL(ceph_osdc_new_request);
 
+int ceph_osd_op_cls_call(struct ceph_osd_client *osdc, int poolid,
+			 char *obj_name, char *class, char *method, int flags,
+			 struct page **req_data, size_t req_len,
+			 struct page **resp_data, size_t *resp_len)
+{
+	struct ceph_osd_request *osd_req;
+	int ret = -ENOMEM;
+	struct timespec tm = CURRENT_TIME;
+
+	osd_req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO);
+	if (!osd_req)
+		return ret;
+	osd_req->r_flags = flags;
+	osd_req->r_base_oloc.pool = poolid;
+	ceph_oid_set_name(&osd_req->r_base_oid, obj_name);
+	osd_req_op_cls_init(osd_req, 0, CEPH_OSD_OP_CALL, class, method);
+
+	if (req_data)
+		osd_req_op_cls_request_data_pages(osd_req, 0, req_data,
+						  req_len, 0, false, false);
+	if (resp_data)
+		osd_req_op_cls_response_data_pages(osd_req, 0, resp_data,
+						   PAGE_SIZE, 0, false, false);
+
+	ceph_osdc_build_request(osd_req, 0, NULL, CEPH_NOSNAP, &tm);
+
+	ret = ceph_osdc_start_request(osdc, osd_req, false);
+	if (ret)
+		goto out;
+
+	ret = ceph_osdc_wait_request(osdc, osd_req);
+	if (ret < 0)
+		goto out;
+
+	if (resp_data)
+		*resp_len = osd_req->r_reply_op_len[0];
+
+	ret = osd_req->r_reply_op_result[0];
+out:
+	ceph_osdc_put_request(osd_req);
+	return ret;
+}
+EXPORT_SYMBOL(ceph_osd_op_cls_call);
+
 /*
  * We keep osd requests in an rbtree, sorted by ->r_tid.
  */
-- 
1.9.3


  parent reply	other threads:[~2015-06-30 20:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30 20:27 [PATCH RFC 0/6] Support rados locking Douglas Fuller
2015-06-30 20:27 ` [PATCH RFC 1/6] Add support for userspace ceph DECODE_START Douglas Fuller
2015-06-30 20:27 ` [PATCH RFC 2/6] ceph: add start/finish encoding helpers Douglas Fuller
2015-06-30 20:27 ` [PATCH RFC 3/6] auth.c: added ceph_entity_name_encode Douglas Fuller
2015-06-30 20:27 ` Douglas Fuller [this message]
2015-06-30 20:28 ` [PATCH RFC 5/6] cls_lock: add rados locking Douglas Fuller
2015-06-30 20:28 ` [PATCH RFC 6/6] cls_lock: add support for lock_info Douglas Fuller

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=06080d26bb1873f93d602df947772614551768e9.1435695881.git.dfuller@redhat.com \
    --to=dfuller@redhat.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.