From patchwork Thu Apr 25 15:28:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 10917317 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 ED8001515 for ; Thu, 25 Apr 2019 15:28:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA8228BE1 for ; Thu, 25 Apr 2019 15:28:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D430D28BE5; Thu, 25 Apr 2019 15:28:53 +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 8DBD428BE8 for ; Thu, 25 Apr 2019 15:28:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729026AbfDYP2v (ORCPT ); Thu, 25 Apr 2019 11:28:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:38408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726964AbfDYP2u (ORCPT ); Thu, 25 Apr 2019 11:28:50 -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 408B52081C; Thu, 25 Apr 2019 15:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556206130; bh=kQ/FZzHXQOwIE19noyWMCLdcLeVmj3JkO9m4B9MEcBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DKvoSrygjGZFxgwnFlpsXYaU1tfmPNeRzWVDUUWlom0QOe80Nc9MaUiA9z1dyBDqn nDSqs51q6TziKzVRV+DglChV5F50st1s9NSoF3aAcYFCJqz5/YfChQ5HLZSbE+rkj8 E+0RLPQGnscXnzPniTFVG3yEuYe2VqfHHscnXr7s= From: Jeff Layton To: zyan@redhat.com, sage@redhat.com, idryomov@gmail.com Cc: ceph-devel@vger.kernel.org Subject: [PATCH 7/7] ceph: just call get_session in __ceph_lookup_mds_session Date: Thu, 25 Apr 2019 11:28:43 -0400 Message-Id: <20190425152843.14351-8-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 I originally thought there was a potential race here, but the fact that this is called with the mdsc->mutex held, ensures that the last reference to the session can't be put here. Still, it's clearer to just return the value from get_session here, and may prevent a bug later if we ever rework this code to be less reliant on mutexes. Signed-off-by: Jeff Layton --- fs/ceph/mds_client.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index a6b52e5935ae..a7e17383de23 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -550,13 +550,9 @@ void ceph_put_mds_session(struct ceph_mds_session *s) struct ceph_mds_session *__ceph_lookup_mds_session(struct ceph_mds_client *mdsc, int mds) { - struct ceph_mds_session *session; - if (mds >= mdsc->max_sessions || !mdsc->sessions[mds]) return NULL; - session = mdsc->sessions[mds]; - get_session(session); - return session; + return get_session(mdsc->sessions[mds]); } static bool __have_session(struct ceph_mds_client *mdsc, int mds)