From patchwork Wed Oct 17 19:20:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 10646013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE92F112B for ; Wed, 17 Oct 2018 19:21:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF693286AA for ; Wed, 17 Oct 2018 19:21:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3FB7287C6; Wed, 17 Oct 2018 19:21:07 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 58521286AA for ; Wed, 17 Oct 2018 19:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728415AbeJRDSN (ORCPT ); Wed, 17 Oct 2018 23:18:13 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38317 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728095AbeJRDSM (ORCPT ); Wed, 17 Oct 2018 23:18:12 -0400 Received: by mail-wm1-f68.google.com with SMTP id 193-v6so3323527wme.3 for ; Wed, 17 Oct 2018 12:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=7xc4nSyN/5sxKTKRRKBdertVQMiJbBS3YmQsTTtisiA=; b=tumQepo1Q/2e7MONMQWjoUOf8vah7ZPbidsuvK8NsKkKtqds2aI61vJ78pxjjxsd2r gC2UBQxl6UNti2W1ZQGvD2ul0j8ZlP8J3bP6Te8SysR6tNeagj0io9VEpE05qbtPYy7c SVpQdCE1rdeYQoB3ryEFmEHoeAsbJmtc8qa50pXOGn9JccI7BmDU3d2hTyJNEBmuAzWA h82tHrxiFXl5O7xlzSRAyCGrBVhfxqiNDj5Y1PJh7JwPctOxw2CuivnqsRr9fQO5x2bC qI0El1hT2+0yNGubT3Ne/7FZQB0swnpSPUT0jNHCr6RHU/x9peR3WZk7kM6uiJInKxCf Kn7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=7xc4nSyN/5sxKTKRRKBdertVQMiJbBS3YmQsTTtisiA=; b=DqrGzQp54unl34Im3njsWsGfM3dQTSh7SP2KpVRPPksYCCWhxhwiQL9cLBv+13TGaQ fou8LrGKH0OFWD34n7kKJuOoLeJyX9EHCWSEHTdqc0HuhzJzE0NridCrqFc7NswsIN7Z R830QQdzS6wN7lP/w7dtq9VyYmamdNhCwIE0+fWwKe7LVwMHy2uu6uuBnmJWKyReEDN4 j84SItJrmNVeDktX5eT2/ktsH4l1HGks3FStdNX/8jXmTtpt+wPc7uyUIMorTrbyyEvF 9qVtkbywo0/xdBSY9hz4g7Tbdsgf94iZ+bfVbeO6T4ONMLYC71HpzumAAbuihLNhFWEN DC6Q== X-Gm-Message-State: ABuFfoinvW6FW0gAEh4Ep3hbe+WEc7EeoqaTmO6MXX0tVolsQlXwU0gJ cX56usrNcoUYB+bpRoCQ28B9APia X-Google-Smtp-Source: ACcGV63770MddRxoM76jOpb/pSDc5Ivkn5XFkKf2WBaClH4iwGU+GA2I581R2VuV1caYMAo62AOBEA== X-Received: by 2002:a1c:14d1:: with SMTP id 200-v6mr4376468wmu.106.1539804063548; Wed, 17 Oct 2018 12:21:03 -0700 (PDT) Received: from orange.redhat.com ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id f7-v6sm16059501wrr.68.2018.10.17.12.21.02 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Oct 2018 12:21:02 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 06/10] libceph: assign cookies in linger_submit() Date: Wed, 17 Oct 2018 21:20:25 +0200 Message-Id: <20181017192029.23294-7-idryomov@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181017192029.23294-1-idryomov@gmail.com> References: <20181017192029.23294-1-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 Register lingers directly in linger_submit(). This avoids allocating memory for notify pagelist while holding osdc->lock and simplifies both callers of linger_submit(). Signed-off-by: Ilya Dryomov --- net/ceph/osd_client.c | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 35bc77c8c230..17d1d2a04a7a 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -2998,11 +2998,21 @@ static void linger_submit(struct ceph_osd_linger_request *lreq) struct ceph_osd_client *osdc = lreq->osdc; struct ceph_osd *osd; + down_write(&osdc->lock); + linger_register(lreq); + if (lreq->is_watch) { + lreq->reg_req->r_ops[0].watch.cookie = lreq->linger_id; + lreq->ping_req->r_ops[0].watch.cookie = lreq->linger_id; + } else { + lreq->reg_req->r_ops[0].notify.cookie = lreq->linger_id; + } + calc_target(osdc, &lreq->t, NULL, false); osd = lookup_create_osd(osdc, lreq->t.osd, true); link_linger(osd, lreq); send_linger(lreq); + up_write(&osdc->lock); } static void cancel_linger_map_check(struct ceph_osd_linger_request *lreq) @@ -4523,15 +4533,14 @@ ceph_osdc_watch(struct ceph_osd_client *osdc, goto err_put_lreq; } - down_write(&osdc->lock); - linger_register(lreq); /* before osd_req_op_* */ - osd_req_op_watch_init(lreq->reg_req, 0, lreq->linger_id, - CEPH_OSD_WATCH_OP_WATCH); - osd_req_op_watch_init(lreq->ping_req, 0, lreq->linger_id, - CEPH_OSD_WATCH_OP_PING); - linger_submit(lreq); - up_write(&osdc->lock); + /* + * Pass 0 for cookie because we don't know it yet, it will be + * filled in by linger_submit(). + */ + osd_req_op_watch_init(lreq->reg_req, 0, 0, CEPH_OSD_WATCH_OP_WATCH); + osd_req_op_watch_init(lreq->ping_req, 0, 0, CEPH_OSD_WATCH_OP_PING); + linger_submit(lreq); ret = linger_reg_commit_wait(lreq); if (ret) { linger_cancel(lreq); @@ -4728,29 +4737,26 @@ int ceph_osdc_notify(struct ceph_osd_client *osdc, goto out_put_lreq; } + /* + * Pass 0 for cookie because we don't know it yet, it will be + * filled in by linger_submit(). + */ + ret = osd_req_op_notify_init(lreq->reg_req, 0, 0, 1, timeout, + payload, payload_len); + if (ret) + goto out_put_lreq; + /* for notify_id */ pages = ceph_alloc_page_vector(1, GFP_NOIO); if (IS_ERR(pages)) { ret = PTR_ERR(pages); goto out_put_lreq; } - - down_write(&osdc->lock); - linger_register(lreq); /* before osd_req_op_* */ - ret = osd_req_op_notify_init(lreq->reg_req, 0, lreq->linger_id, 1, - timeout, payload, payload_len); - if (ret) { - linger_unregister(lreq); - up_write(&osdc->lock); - ceph_release_page_vector(pages, 1); - goto out_put_lreq; - } ceph_osd_data_pages_init(osd_req_op_data(lreq->reg_req, 0, notify, response_data), pages, PAGE_SIZE, 0, false, true); - linger_submit(lreq); - up_write(&osdc->lock); + linger_submit(lreq); ret = linger_reg_commit_wait(lreq); if (!ret) ret = linger_notify_finish_wait(lreq);