From: Jeff Layton Date: Wed, 9 Jun 2021 18:09:52 +0000 (-0400) Subject: ceph: allow ceph_put_mds_session to take NULL or ERR_PTR X-Git-Tag: accepted/tizen/unified/20230118.172025~6860^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e65624d32b6e0429b1d3559e5585657f34f74a1;p=platform%2Fkernel%2Flinux-rpi.git ceph: allow ceph_put_mds_session to take NULL or ERR_PTR ...to simplify some error paths. Signed-off-by: Jeff Layton Reviewed-by: Luis Henriques Signed-off-by: Ilya Dryomov --- diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 9ba79b6..973489d 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1809,8 +1809,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 df0c8a7..6f43542 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1154,8 +1154,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); } /* @@ -1200,8 +1199,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 e5af591..ec66963 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -664,6 +664,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)) { @@ -1438,8 +1441,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 9577c71..5ac151e 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -311,8 +311,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); } #define METRIC_UPDATE_MIN_MAX(min, max, new) \