From: Bob Peterson Date: Thu, 10 Sep 2020 11:26:34 -0400 (EDT) Subject: [Cluster-devel] [GFS2 PATCH] gfs2: truncate glock address space pages during evict In-Reply-To: <454279735.16583317.1599751575623.JavaMail.zimbra@redhat.com> Message-ID: <883057823.16586032.1599751594154.JavaMail.zimbra@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, Before this patch, function gfs2_evict_inode would truncate the pages for the inode's address space, but the address space associated with its glock was only truncated if the inode was deleted. In that case, it needs to do the truncate within a transaction because of this calling sequence: truncate_inode_pages truncate_inode_pages_range gfs2_invalidatepage gfs2_discard gfs2_remove_from_journal gfs2_trans_add_revoke <------- Needs a transaction If, however, the inode is not deleted, it might still have pages for the glock's address space because gfs2_getbuf() reads them in that way. This may happen, for example, if a file is unlinked by another node and this node discovers that fact by reading the dinode using its glock during the process of doing delete_work_func -> create -> put -> evict. But if the inode is not deleted, the truncate_inode_pages for the glock address space was bypassed. The problem is, in some circumstances (such as the system quota file during unmount) an inode can have pages still queued to its glock's address space. That causes a kernel panic when __gfs2_glock_put for the inode glock does: GLOCK_BUG_ON(gl, mapping && mapping->nrpages && !gfs2_withdrawn(sdp)); At that point, it is too late to start a transaction for the truncate because the file system is then read-only, so trans_begin will return an error. When we free the glock, the pages shouldn't be dirty anyway, so this patch adds truncate_inode_pages_final for the glock's address space, metamapping. Signed-off-by: Bob Peterson --- fs/gfs2/super.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 19add2da1013..3ced8d895eca 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -1456,6 +1456,10 @@ static void gfs2_evict_inode(struct inode *inode) fs_warn(sdp, "gfs2_evict_inode: %d\n", error); out: truncate_inode_pages_final(&inode->i_data); + if (ip->i_gl) { + metamapping = gfs2_glock2aspace(ip->i_gl); + truncate_inode_pages_final(metamapping); + } if (ip->i_qadata) gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0); gfs2_rs_delete(ip, NULL);