gfs2: Only defer deletes when we have an iopen glock
authorAndreas Gruenbacher <agruenba@redhat.com>
Tue, 19 Nov 2024 09:44:56 +0000 (10:44 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Tue, 19 Nov 2024 11:33:20 +0000 (12:33 +0100)
The mechanism to defer deleting unlinked inodes is tied to
delete_work_func(), which is tied to iopen glocks.  When we don't have
an iopen glock, we must carry out deletes immediately instead.

Fixes a NULL pointer dereference in gfs2_evict_inode().

Fixes: 8c21c2c71e66 ("gfs2: Call gfs2_queue_verify_delete from gfs2_evict_inode")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/super.c

index aadb83e..92a3b6d 100644 (file)
@@ -1503,10 +1503,13 @@ static void gfs2_evict_inode(struct inode *inode)
            !test_bit(SDF_KILL, &sdp->sd_flags)) {
                struct gfs2_glock *io_gl = ip->i_iopen_gh.gh_gl;
 
-               gfs2_glock_hold(io_gl);
-               if (!gfs2_queue_verify_delete(io_gl, true))
-                       gfs2_glock_put(io_gl);
-               goto out;
+               if (io_gl) {
+                       gfs2_glock_hold(io_gl);
+                       if (!gfs2_queue_verify_delete(io_gl, true))
+                               gfs2_glock_put(io_gl);
+                       goto out;
+               }
+               behavior = EVICT_SHOULD_DELETE;
        }
        if (behavior == EVICT_SHOULD_DELETE)
                ret = evict_unlinked_inode(inode);