]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
NFSv4/pNFS: Clear NFS_INO_LAYOUTCOMMIT in pnfs_mark_layout_stateid_invalid
authorJonathan Curley <jcurley@purestorage.com>
Wed, 12 Nov 2025 18:02:42 +0000 (18:02 +0000)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 23 Nov 2025 20:33:33 +0000 (15:33 -0500)
Fixes a crash when layout is null during this call stack:

write_inode
    -> nfs4_write_inode
        -> pnfs_layoutcommit_inode

pnfs_set_layoutcommit relies on the lseg refcount to keep the layout
around. Need to clear NFS_INO_LAYOUTCOMMIT otherwise we might attempt
to reference a null layout.

Fixes: fe1cf9469d7bc ("pNFS: Clear all layout segment state in pnfs_mark_layout_stateid_invalid")
Signed-off-by: Jonathan Curley <jcurley@purestorage.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/pnfs.c

index a3135b5af7eeca201e5a6e6e3c7f692ad9e0b250..7ce2e840217cfc008ebc90bf2b0eb2c8cb4a4f39 100644 (file)
@@ -464,6 +464,7 @@ pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo,
        struct pnfs_layout_segment *lseg, *next;
 
        set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags);
+       clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(lo->plh_inode)->flags);
        list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list)
                pnfs_clear_lseg_state(lseg, lseg_list);
        pnfs_clear_layoutreturn_info(lo);