diff mbox series

ceph: use ceph_evict_inode to cleanup inode's resource

Message ID 20190702013254.21028-1-zyan@redhat.com (mailing list archive)
State New, archived
Headers show
Series ceph: use ceph_evict_inode to cleanup inode's resource | expand

Commit Message

Yan, Zheng July 2, 2019, 1:32 a.m. UTC
remove_session_caps() relies on __wait_on_freeing_inode(), to wait for
freeing inode to remove its caps. But VFS wakes freeing inode waiters
before calling destroy_inode().

Link: https://tracker.ceph.com/issues/40102
Cc: stable@vger.kernel.org
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
---
 fs/ceph/inode.c | 7 +++++--
 fs/ceph/super.c | 2 +-
 fs/ceph/super.h | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

Comments

Jeff Layton July 2, 2019, 11:15 a.m. UTC | #1
On Tue, 2019-07-02 at 09:32 +0800, Yan, Zheng wrote:
> remove_session_caps() relies on __wait_on_freeing_inode(), to wait for
> freeing inode to remove its caps. But VFS wakes freeing inode waiters
> before calling destroy_inode().
> 
> Link: https://tracker.ceph.com/issues/40102
> Cc: stable@vger.kernel.org
> Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
> ---
>  fs/ceph/inode.c | 7 +++++--
>  fs/ceph/super.c | 2 +-
>  fs/ceph/super.h | 2 +-
>  3 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 2c49eb831c6f..a565ab124282 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -526,13 +526,16 @@ void ceph_free_inode(struct inode *inode)
>  	kmem_cache_free(ceph_inode_cachep, ci);
>  }
>  
> -void ceph_destroy_inode(struct inode *inode)
> +void ceph_evict_inode(struct inode *inode)
>  {
>  	struct ceph_inode_info *ci = ceph_inode(inode);
>  	struct ceph_inode_frag *frag;
>  	struct rb_node *n;
>  
> -	dout("destroy_inode %p ino %llx.%llx\n", inode, ceph_vinop(inode));
> +	dout("evict_inode %p ino %llx.%llx\n", inode, ceph_vinop(inode));
> +
> +	truncate_inode_pages_final(&inode->i_data);
> +	clear_inode(inode);
>  
>  	ceph_fscache_unregister_inode_cookie(ci);
>  
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index c21201a951ce..5f0c950ca966 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -840,10 +840,10 @@ static int ceph_remount(struct super_block *sb, int *flags, char *data)
>  
>  static const struct super_operations ceph_super_ops = {
>  	.alloc_inode	= ceph_alloc_inode,
> -	.destroy_inode	= ceph_destroy_inode,
>  	.free_inode	= ceph_free_inode,
>  	.write_inode    = ceph_write_inode,
>  	.drop_inode	= ceph_drop_inode,
> +	.evict_inode	= ceph_evict_inode,
>  	.sync_fs        = ceph_sync_fs,
>  	.put_super	= ceph_put_super,
>  	.remount_fs	= ceph_remount,
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index a592d4a8266c..30e9a4e415cc 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -884,7 +884,7 @@ static inline bool __ceph_have_pending_cap_snap(struct ceph_inode_info *ci)
>  extern const struct inode_operations ceph_file_iops;
>  
>  extern struct inode *ceph_alloc_inode(struct super_block *sb);
> -extern void ceph_destroy_inode(struct inode *inode);
> +extern void ceph_evict_inode(struct inode *inode);
>  extern void ceph_free_inode(struct inode *inode);
>  extern int ceph_drop_inode(struct inode *inode);
>  

Looks good.

Reviewed-by: Jeff Layton <jlayton@redhat.com>
diff mbox series

Patch

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 2c49eb831c6f..a565ab124282 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -526,13 +526,16 @@  void ceph_free_inode(struct inode *inode)
 	kmem_cache_free(ceph_inode_cachep, ci);
 }
 
-void ceph_destroy_inode(struct inode *inode)
+void ceph_evict_inode(struct inode *inode)
 {
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	struct ceph_inode_frag *frag;
 	struct rb_node *n;
 
-	dout("destroy_inode %p ino %llx.%llx\n", inode, ceph_vinop(inode));
+	dout("evict_inode %p ino %llx.%llx\n", inode, ceph_vinop(inode));
+
+	truncate_inode_pages_final(&inode->i_data);
+	clear_inode(inode);
 
 	ceph_fscache_unregister_inode_cookie(ci);
 
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index c21201a951ce..5f0c950ca966 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -840,10 +840,10 @@  static int ceph_remount(struct super_block *sb, int *flags, char *data)
 
 static const struct super_operations ceph_super_ops = {
 	.alloc_inode	= ceph_alloc_inode,
-	.destroy_inode	= ceph_destroy_inode,
 	.free_inode	= ceph_free_inode,
 	.write_inode    = ceph_write_inode,
 	.drop_inode	= ceph_drop_inode,
+	.evict_inode	= ceph_evict_inode,
 	.sync_fs        = ceph_sync_fs,
 	.put_super	= ceph_put_super,
 	.remount_fs	= ceph_remount,
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index a592d4a8266c..30e9a4e415cc 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -884,7 +884,7 @@  static inline bool __ceph_have_pending_cap_snap(struct ceph_inode_info *ci)
 extern const struct inode_operations ceph_file_iops;
 
 extern struct inode *ceph_alloc_inode(struct super_block *sb);
-extern void ceph_destroy_inode(struct inode *inode);
+extern void ceph_evict_inode(struct inode *inode);
 extern void ceph_free_inode(struct inode *inode);
 extern int ceph_drop_inode(struct inode *inode);