diff mbox series

ceph: switch to global cap helper

Message ID 20191203080051.13240-1-xiubli@redhat.com (mailing list archive)
State New, archived
Headers show
Series ceph: switch to global cap helper | expand

Commit Message

Xiubo Li Dec. 3, 2019, 8 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

__ceph_is_any_caps is a duplicate helper.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/caps.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

Comments

Jeff Layton Dec. 3, 2019, 6:42 p.m. UTC | #1
On Tue, 2019-12-03 at 03:00 -0500, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
> 
> __ceph_is_any_caps is a duplicate helper.
> 
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>  fs/ceph/caps.c | 24 ++++++++++--------------
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index c62e88da4fee..fafb84a2d8f5 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -1011,18 +1011,13 @@ static int __ceph_is_single_caps(struct ceph_inode_info *ci)
>  	return rb_first(&ci->i_caps) == rb_last(&ci->i_caps);
>  }
>  
> -static int __ceph_is_any_caps(struct ceph_inode_info *ci)
> -{
> -	return !RB_EMPTY_ROOT(&ci->i_caps);
> -}
> -
>  int ceph_is_any_caps(struct inode *inode)
>  {
>  	struct ceph_inode_info *ci = ceph_inode(inode);
>  	int ret;
>  
>  	spin_lock(&ci->i_ceph_lock);
> -	ret = __ceph_is_any_caps(ci);
> +	ret = __ceph_is_any_real_caps(ci);
>  	spin_unlock(&ci->i_ceph_lock);
>  
>  	return ret;
> @@ -1099,15 +1094,16 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
>  	if (removed)
>  		ceph_put_cap(mdsc, cap);
>  
> -	/* when reconnect denied, we remove session caps forcibly,
> -	 * i_wr_ref can be non-zero. If there are ongoing write,
> -	 * keep i_snap_realm.
> -	 */
> -	if (!__ceph_is_any_caps(ci) && ci->i_wr_ref == 0 && ci->i_snap_realm)
> -		drop_inode_snap_realm(ci);
> +	if (!__ceph_is_any_real_caps(ci)) {
> +		/* when reconnect denied, we remove session caps forcibly,
> +		 * i_wr_ref can be non-zero. If there are ongoing write,
> +		 * keep i_snap_realm.
> +		 */
> +		if (ci->i_wr_ref == 0 && ci->i_snap_realm)
> +			drop_inode_snap_realm(ci);
>  
> -	if (!__ceph_is_any_real_caps(ci))
>  		__cap_delay_cancel(mdsc, ci);
> +	}
>  }
>  
>  struct cap_msg_args {
> @@ -2927,7 +2923,7 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had)
>  				ci->i_head_snapc = NULL;
>  			}
>  			/* see comment in __ceph_remove_cap() */
> -			if (!__ceph_is_any_caps(ci) && ci->i_snap_realm)
> +			if (!__ceph_is_any_real_caps(ci) && ci->i_snap_realm)
>  				drop_inode_snap_realm(ci);
>  		}
>  	spin_unlock(&ci->i_ceph_lock);

Merged.
diff mbox series

Patch

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index c62e88da4fee..fafb84a2d8f5 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1011,18 +1011,13 @@  static int __ceph_is_single_caps(struct ceph_inode_info *ci)
 	return rb_first(&ci->i_caps) == rb_last(&ci->i_caps);
 }
 
-static int __ceph_is_any_caps(struct ceph_inode_info *ci)
-{
-	return !RB_EMPTY_ROOT(&ci->i_caps);
-}
-
 int ceph_is_any_caps(struct inode *inode)
 {
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	int ret;
 
 	spin_lock(&ci->i_ceph_lock);
-	ret = __ceph_is_any_caps(ci);
+	ret = __ceph_is_any_real_caps(ci);
 	spin_unlock(&ci->i_ceph_lock);
 
 	return ret;
@@ -1099,15 +1094,16 @@  void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release)
 	if (removed)
 		ceph_put_cap(mdsc, cap);
 
-	/* when reconnect denied, we remove session caps forcibly,
-	 * i_wr_ref can be non-zero. If there are ongoing write,
-	 * keep i_snap_realm.
-	 */
-	if (!__ceph_is_any_caps(ci) && ci->i_wr_ref == 0 && ci->i_snap_realm)
-		drop_inode_snap_realm(ci);
+	if (!__ceph_is_any_real_caps(ci)) {
+		/* when reconnect denied, we remove session caps forcibly,
+		 * i_wr_ref can be non-zero. If there are ongoing write,
+		 * keep i_snap_realm.
+		 */
+		if (ci->i_wr_ref == 0 && ci->i_snap_realm)
+			drop_inode_snap_realm(ci);
 
-	if (!__ceph_is_any_real_caps(ci))
 		__cap_delay_cancel(mdsc, ci);
+	}
 }
 
 struct cap_msg_args {
@@ -2927,7 +2923,7 @@  void ceph_put_cap_refs(struct ceph_inode_info *ci, int had)
 				ci->i_head_snapc = NULL;
 			}
 			/* see comment in __ceph_remove_cap() */
-			if (!__ceph_is_any_caps(ci) && ci->i_snap_realm)
+			if (!__ceph_is_any_real_caps(ci) && ci->i_snap_realm)
 				drop_inode_snap_realm(ci);
 		}
 	spin_unlock(&ci->i_ceph_lock);