Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1839657pxb; Fri, 24 Sep 2021 13:12:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcxS+AF9ORqKaqVyrQjh+k4omXyFGjVtS4s7utvgrdD7iuRgrzF/d2PQ+ryA8e93FMCsAq X-Received: by 2002:a17:906:a01:: with SMTP id w1mr13658139ejf.117.1632514370834; Fri, 24 Sep 2021 13:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632514370; cv=none; d=google.com; s=arc-20160816; b=Rm1sDQAsDpgac/Cv4rYQxP4Y2rBXlyA6ju13P5KieOpgp/xUrPx8/GCl58VugJOYlo k5z9mcycNZYL9yuBScAdQ7DfRCeZtYaM5m0Y5mtC/Ht+OV203UxKZdVq9mqG1nu5TnDu 4Pm+26b4p3rLTSRHM8YSD1z/GNM0Fn0qFdz4KqoMDzgiKjGsFI8A90C87+mNkQtUpa0F dve1YTZSnLKVlvCeaDBsedygcLdMkpLvBq9kxJHMOWU7rGSS0Z6J8AB0OP3DHThYePeF Ep0ocULpBlB9MJJ856WUOXLfkh+AS5k+oag6IoNrxXpOI40zQ/TQ6FfEfltUP1KSwP8D w6cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=67KRRl2EXwuyph2Nm47hdB1RDAm4pszZTpNXa4GX39A=; b=soMYgie6oMK56Z6fmUvVYmled1NaJ8GkkL4ttAqc6XYh49b73/qj67Emn5XYf/kk5d AJq+uG37nPxTzzWGbVl1R93zTDN2NaXMuPIbL4J1MUYgQOVMTDKVuiWUBEZ9gOYKNIE5 kK9VnDOMEK64yo+z/7Q0gxYRE2KB7bckThkM3cM3J3HZkbrMgr/ctweFpsjhhrO41o0e x//i9NPqQAWsSW8cKQYw0cGowpCaBO+4azR2wb1Tjq7/swDSs6ZSBaxM4H6HU1UttSTb dsIqMGDIevTk58l5uAQoK3ciZmUSGFpqh0ucnqxD9gHxzBhPwgSXi7uDIutXQbi16ovT ZDNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VqXkgiMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si9357772edb.199.2021.09.24.13.12.25; Fri, 24 Sep 2021 13:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VqXkgiMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346754AbhIXNLh (ORCPT + 99 others); Fri, 24 Sep 2021 09:11:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:38838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346845AbhIXNIM (ORCPT ); Fri, 24 Sep 2021 09:08:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A514260E8B; Fri, 24 Sep 2021 12:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632488224; bh=KpzRXMMsCQNA6qb0p+e5qdjuYKUNlRmHo44BN4oz6zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VqXkgiMa//ZAwC1U9rMLJ1CaKXhxAgv94kQa8PVHgARocX5WbZg0iTD39efQQPL7w lFsWGKvsP2fWF4VGH8txIjmZqE4L1Aqglgf5R9GL8X6O09YZlAMxcvRtkgjjAwspGg +m7UadsTJBAmI3OQkvTXHJqwWC+HsVR0SmxN816Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Layton , Luis Henriques , Ilya Dryomov , Sasha Levin Subject: [PATCH 5.10 30/63] ceph: allow ceph_put_mds_session to take NULL or ERR_PTR Date: Fri, 24 Sep 2021 14:44:30 +0200 Message-Id: <20210924124335.307657262@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210924124334.228235870@linuxfoundation.org> References: <20210924124334.228235870@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeff Layton [ Upstream commit 7e65624d32b6e0429b1d3559e5585657f34f74a1 ] ...to simplify some error paths. Signed-off-by: Jeff Layton Reviewed-by: Luis Henriques Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/dir.c | 3 +-- fs/ceph/inode.c | 6 ++---- fs/ceph/mds_client.c | 6 ++++-- fs/ceph/metric.c | 3 +-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index a4d48370b2b3..f63c1a090139 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1797,8 +1797,7 @@ static void ceph_d_release(struct dentry *dentry) dentry->d_fsdata = NULL; spin_unlock(&dentry->d_lock); - if (di->lease_session) - ceph_put_mds_session(di->lease_session); + ceph_put_mds_session(di->lease_session); kmem_cache_free(ceph_dentry_cachep, di); } diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 57cd78e942c0..63e781e4f7e4 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1121,8 +1121,7 @@ static inline void update_dentry_lease(struct inode *dir, struct dentry *dentry, __update_dentry_lease(dir, dentry, lease, session, from_time, &old_lease_session); spin_unlock(&dentry->d_lock); - if (old_lease_session) - ceph_put_mds_session(old_lease_session); + ceph_put_mds_session(old_lease_session); } /* @@ -1167,8 +1166,7 @@ static void update_dentry_lease_careful(struct dentry *dentry, from_time, &old_lease_session); out_unlock: spin_unlock(&dentry->d_lock); - if (old_lease_session) - ceph_put_mds_session(old_lease_session); + ceph_put_mds_session(old_lease_session); } /* diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 816cea497537..8cbbb611e0ca 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -661,6 +661,9 @@ struct ceph_mds_session *ceph_get_mds_session(struct ceph_mds_session *s) void ceph_put_mds_session(struct ceph_mds_session *s) { + if (IS_ERR_OR_NULL(s)) + return; + dout("mdsc put_session %p %d -> %d\n", s, refcount_read(&s->s_ref), refcount_read(&s->s_ref)-1); if (refcount_dec_and_test(&s->s_ref)) { @@ -1435,8 +1438,7 @@ static void __open_export_target_sessions(struct ceph_mds_client *mdsc, for (i = 0; i < mi->num_export_targets; i++) { ts = __open_export_target_session(mdsc, mi->export_targets[i]); - if (!IS_ERR(ts)) - ceph_put_mds_session(ts); + ceph_put_mds_session(ts); } } diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index fee4c4778313..3b2ef8ee544e 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -233,8 +233,7 @@ void ceph_metric_destroy(struct ceph_client_metric *m) cancel_delayed_work_sync(&m->delayed_work); - if (m->session) - ceph_put_mds_session(m->session); + ceph_put_mds_session(m->session); } static inline void __update_latency(ktime_t *totalp, ktime_t *lsump, -- 2.33.0