[Cluster-devel] [PATCH v2 4/4] gfs2: Defer deleting inodes under memory pressure

Steven Whitehouse swhiteho at redhat.com
Tue Jul 4 12:17:23 UTC 2017


Hi,


On 03/07/17 15:56, Andreas Gruenbacher wrote:
> When under memory pressure and an inode's link count has dropped to
> zero, defer deleting the inode to the delete workqueue.  This avoids
> calling into DLM under memory pressure which can deadlock.
Yes, that looks like a good solution to me,

Steve.

>
> Signed-off-by: Andreas Gruenbacher <agruenba at redhat.com>
> ---
>   fs/gfs2/super.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>
> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
> index d53364e..f54af47 100644
> --- a/fs/gfs2/super.c
> +++ b/fs/gfs2/super.c
> @@ -1317,6 +1317,21 @@ static int gfs2_drop_inode(struct inode *inode)
>   		if (test_bit(GLF_DEMOTE, &gl->gl_flags))
>   			clear_nlink(inode);
>   	}
> +
> +	/*
> +	 * When under memory pressure when an inode's link count has dropped to
> +	 * zero, defer deleting the inode to the delete workqueue.  This avoids
> +	 * calling into DLM under memory pressure, which can deadlock.
> +	 */
> +	if (!inode->i_nlink &&
> +	    unlikely(current->flags & PF_MEMALLOC) &&
> +	    gfs2_holder_initialized(&ip->i_iopen_gh)) {
> +		struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
> +
> +		queue_work(gfs2_delete_workqueue, &gl->gl_delete);
> +		return false;
> +	}
> +
>   	return generic_drop_inode(inode);
>   }
>   
> @@ -1544,6 +1559,10 @@ static void gfs2_evict_inode(struct inode *inode)
>   		goto alloc_failed;
>   	}
>   
> +	/* Deletes should never happen under memory pressure anymore.  */
> +	if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
> +		goto out;
> +
>   	/* Must not read inode block until block type has been verified */
>   	error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, &gh);
>   	if (unlikely(error)) {




More information about the Cluster-devel mailing list