Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFSv4/pNFS: Clear NFS_INO_LAYOUTCOMMIT in pnfs_mark_layout_stateid_invalid

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>

authored by

Jonathan Curley and committed by
Trond Myklebust
e0f8058f 9e9fdd0a

+1
+1
fs/nfs/pnfs.c
··· 464 464 struct pnfs_layout_segment *lseg, *next; 465 465 466 466 set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); 467 + clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(lo->plh_inode)->flags); 467 468 list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list) 468 469 pnfs_clear_lseg_state(lseg, lseg_list); 469 470 pnfs_clear_layoutreturn_info(lo);