From patchwork Wed Aug 24 13:18:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9297791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 09D4360757 for ; Wed, 24 Aug 2016 13:35:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEF9D285B9 for ; Wed, 24 Aug 2016 13:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E37E428F2B; Wed, 24 Aug 2016 13:35:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86DFB285B9 for ; Wed, 24 Aug 2016 13:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755970AbcHXNey (ORCPT ); Wed, 24 Aug 2016 09:34:54 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:33011 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755202AbcHXNew (ORCPT ); Wed, 24 Aug 2016 09:34:52 -0400 Received: by mail-yw0-f196.google.com with SMTP id z8so812632ywa.0 for ; Wed, 24 Aug 2016 06:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=AX/XIhk9z3T2mGJdepTIs7YZXMM56CYaiqg++lQ6sW4=; b=ME96PnNfbmgiqkRLSFX5GqhhuT+1waRXWfmRqpQP+P7v8Hjo50AmTfQkcFmf7sMB6f PloUcZThEk/zW+sHgTqjHptzSKz5PGn70/+6pluJO0bzLNojhXWlRrwl4hu1LhzT2gzd 4nJkbEPCkGRRVZ20hwOqqIo8SGn7ND4CyOhH866A/6bX8FDt27EGdRGfxGeEm/mBesaM hs8tHUX8UgedrXfX9rwUwskOQxdFrMJw8cypwZntHlwvARyzYUf1d22dwvIigmfFdkjL nHOiMC67PTC118PQ3tWrHv/PCy39rdkb94GHyfq/MsEXhRGq2m6owiEpwNPWZDDVxsuI FoaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=AX/XIhk9z3T2mGJdepTIs7YZXMM56CYaiqg++lQ6sW4=; b=LOe0XbIDUfJnnkkPT2/nwNCfzBSB0q2onwOIWoaGLQkdM8MN1bhCKX/sWhOFCVh6p6 OxKvrBxYbepS/4VT9oQJFA8yEYBML9dvBHs9erNjOdw868FC3VDZHYmO1IRwY8jxgZTt yvPwFJaYuVQ+CsVZEYH9/ow82ogwDK/cvA/ryF50TbynXyrrKlvvINEI0IO+zGIhQDpR 9BHNJ+dA7W4Uwz/MwyjUHrFAJUfj69POFTMZpHbSeTVCeuslG5YghjLkrkqJYRaZeA6u WyGpZDkAAyhsUwqFPMyTKIx2rj+3YzCaRrOzLh/gj8rSxuyhuiXWo7h/qTVHqDsL7QGu lFiQ== X-Gm-Message-State: AE9vXwOxG5nBAiQureAVVYVtFd40OJBUu7HwqK5/g9ryIEYoGu0IO92z+aA9maxil0o34g== X-Received: by 10.13.203.200 with SMTP id n191mr2452271ywd.175.1472044735327; Wed, 24 Aug 2016 06:18:55 -0700 (PDT) Received: from dhcp-1-219.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id e197sm5371294ywa.16.2016.08.24.06.18.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2016 06:18:54 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 03/16] libceph: add ceph_osdc_call() single-page helper Date: Wed, 24 Aug 2016 15:18:27 +0200 Message-Id: <1472044720-29116-4-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1472044720-29116-1-git-send-email-idryomov@gmail.com> References: <1472044720-29116-1-git-send-email-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Douglas Fuller Add a convenience function to osd_client to send Ceph OSD 'class' ops. The interface assumes that the request and reply data each consist of single pages. Signed-off-by: Douglas Fuller Signed-off-by: Ilya Dryomov Reviewed-by: Alex Elder --- include/linux/ceph/osd_client.h | 8 +++++++ net/ceph/osd_client.c | 51 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index 19821a191732..96337b15a60d 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h @@ -397,6 +397,14 @@ extern void ceph_osdc_sync(struct ceph_osd_client *osdc); extern void ceph_osdc_flush_notifies(struct ceph_osd_client *osdc); void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc); +int ceph_osdc_call(struct ceph_osd_client *osdc, + struct ceph_object_id *oid, + struct ceph_object_locator *oloc, + const char *class, const char *method, + unsigned int flags, + struct page *req_page, size_t req_len, + struct page *resp_page, size_t *resp_len); + extern int ceph_osdc_readpages(struct ceph_osd_client *osdc, struct ceph_vino vino, struct ceph_file_layout *layout, diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index dd51ec8ce97f..fbc6b7090c65 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -4027,6 +4027,57 @@ void ceph_osdc_maybe_request_map(struct ceph_osd_client *osdc) EXPORT_SYMBOL(ceph_osdc_maybe_request_map); /* + * Execute an OSD class method on an object. + * + * @flags: CEPH_OSD_FLAG_* + * @resp_len: out param for reply length + */ +int ceph_osdc_call(struct ceph_osd_client *osdc, + struct ceph_object_id *oid, + struct ceph_object_locator *oloc, + const char *class, const char *method, + unsigned int flags, + struct page *req_page, size_t req_len, + struct page *resp_page, size_t *resp_len) +{ + struct ceph_osd_request *req; + int ret; + + req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); + if (!req) + return -ENOMEM; + + ceph_oid_copy(&req->r_base_oid, oid); + ceph_oloc_copy(&req->r_base_oloc, oloc); + req->r_flags = flags; + + ret = ceph_osdc_alloc_messages(req, GFP_NOIO); + if (ret) + goto out_put_req; + + osd_req_op_cls_init(req, 0, CEPH_OSD_OP_CALL, class, method); + if (req_page) + osd_req_op_cls_request_data_pages(req, 0, &req_page, req_len, + 0, false, false); + if (resp_page) + osd_req_op_cls_response_data_pages(req, 0, &resp_page, + PAGE_SIZE, 0, false, false); + + ceph_osdc_start_request(osdc, req, false); + ret = ceph_osdc_wait_request(osdc, req); + if (ret >= 0) { + ret = req->r_ops[0].rval; + if (resp_page) + *resp_len = req->r_ops[0].outdata_len; + } + +out_put_req: + ceph_osdc_put_request(req); + return ret; +} +EXPORT_SYMBOL(ceph_osdc_call); + +/* * init, shutdown */ int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)