From patchwork Thu Apr 25 15:28:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 10917311 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 799C5933 for ; Thu, 25 Apr 2019 15:28:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AF3128BE1 for ; Thu, 25 Apr 2019 15:28:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FAD228BE8; Thu, 25 Apr 2019 15:28:50 +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,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 00D0128BE1 for ; Thu, 25 Apr 2019 15:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728993AbfDYP2t (ORCPT ); Thu, 25 Apr 2019 11:28:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:38376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728970AbfDYP2s (ORCPT ); Thu, 25 Apr 2019 11:28:48 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 324C9206C0; Thu, 25 Apr 2019 15:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556206127; bh=HzQFffSiYXofivPQ1T4EKD4Bxiat1sbfnS5MNJmNa5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kTHIJpPLunAVhVc3kI+NtKgrbhacB7VxILoQUjcFCyIoZvRbn/hGV5FpBspq3JdGp NhtY0ZEVFc8sbH8rduKFlN0QPPcxeBE3B52OthZsKPet3V2Al3uTlyRPTbKYzrv+sv mzuaV6493GVCZpKOiEVVU7LyicVtDuROVj1jbPzA= From: Jeff Layton To: zyan@redhat.com, sage@redhat.com, idryomov@gmail.com Cc: ceph-devel@vger.kernel.org Subject: [PATCH 3/7] ceph: have ceph_mdsc_do_request call ceph_mdsc_submit_request Date: Thu, 25 Apr 2019 11:28:39 -0400 Message-Id: <20190425152843.14351-4-jlayton@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190425152843.14351-1-jlayton@kernel.org> References: <20190425152843.14351-1-jlayton@kernel.org> MIME-Version: 1.0 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 Nothing calls ceph_mdsc_submit_request today, but in later patches we'll need to be able to call this separately. Have the helper return an int so we can check the r_err under the mutex, and have the caller just check the error code from the submit. Also move the acquisition of CEPH_CAP_PIN references into the same function. Signed-off-by: Jeff Layton --- fs/ceph/mds_client.c | 40 +++++++++++++++++++--------------------- fs/ceph/mds_client.h | 5 +++-- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index f68de347232c..39f9f68a36ab 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2666,14 +2666,27 @@ static void kick_requests(struct ceph_mds_client *mdsc, int mds) } } -void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, +int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, struct ceph_mds_request *req) { - dout("submit_request on %p\n", req); + int err; + + /* take CAP_PIN refs for r_inode, r_parent, r_old_dentry */ + if (req->r_inode) + ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN); + if (req->r_parent) + ceph_get_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN); + if (req->r_old_dentry_dir) + ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir), + CEPH_CAP_PIN); + + dout("submit_request on %p for inode %p\n", req, dir); mutex_lock(&mdsc->mutex); - __register_request(mdsc, req, NULL); + __register_request(mdsc, req, dir); __do_request(mdsc, req); + err = req->r_err; mutex_unlock(&mdsc->mutex); + return err; } /* @@ -2688,27 +2701,12 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, dout("do_request on %p\n", req); - /* take CAP_PIN refs for r_inode, r_parent, r_old_dentry */ - if (req->r_inode) - ceph_get_cap_refs(ceph_inode(req->r_inode), CEPH_CAP_PIN); - if (req->r_parent) - ceph_get_cap_refs(ceph_inode(req->r_parent), CEPH_CAP_PIN); - if (req->r_old_dentry_dir) - ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir), - CEPH_CAP_PIN); - /* issue */ - mutex_lock(&mdsc->mutex); - __register_request(mdsc, req, dir); - __do_request(mdsc, req); - - if (req->r_err) { - err = req->r_err; + err = ceph_mdsc_submit_request(mdsc, dir, req); + if (err) goto out; - } /* wait */ - mutex_unlock(&mdsc->mutex); dout("do_request waiting\n"); if (!req->r_timeout && req->r_wait_for_completion) { err = req->r_wait_for_completion(mdsc, req); @@ -2749,8 +2747,8 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, err = req->r_err; } -out: mutex_unlock(&mdsc->mutex); +out: dout("do_request %p done, result %d\n", req, err); return err; } diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 0d1f673a5689..1291f47cca2d 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -465,8 +465,9 @@ extern int ceph_alloc_readdir_reply_buffer(struct ceph_mds_request *req, struct inode *dir); extern struct ceph_mds_request * ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode); -extern void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, - struct ceph_mds_request *req); +extern int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, + struct inode *dir, + struct ceph_mds_request *req); extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, struct inode *dir, struct ceph_mds_request *req);