]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - fs/nfs/pnfs.c
Merge tag 'dax-fixes-5.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdim...
[mirror_ubuntu-jammy-kernel.git] / fs / nfs / pnfs.c
index 102b66e0bdeff9377257a43944f8286beb5a39ce..03e0b34c4a64cc7a7299866ed13c99b417ade0aa 100644 (file)
@@ -1344,7 +1344,7 @@ _pnfs_return_layout(struct inode *ino)
        }
        valid_layout = pnfs_layout_is_valid(lo);
        pnfs_clear_layoutcommit(ino, &tmp_list);
-       pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL, 0);
+       pnfs_mark_matching_lsegs_return(lo, &tmp_list, NULL, 0);
 
        if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
                struct pnfs_layout_range range = {
@@ -2410,9 +2410,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)
                        .iomode = IOMODE_ANY,
                        .length = NFS4_MAX_UINT64,
                };
-               pnfs_set_plh_return_info(lo, IOMODE_ANY, 0);
-               pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
-                                               &range, 0);
+               pnfs_mark_matching_lsegs_return(lo, &free_me, &range, 0);
                goto out_forget;
        } else {
                /* We have a completely new layout */
@@ -2468,6 +2466,9 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
 
        assert_spin_locked(&lo->plh_inode->i_lock);
 
+       if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags))
+               tmp_list = &lo->plh_return_segs;
+
        list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list)
                if (pnfs_match_lseg_recall(lseg, return_range, seq)) {
                        dprintk("%s: marking lseg %p iomode %d "
@@ -2475,6 +2476,8 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
                                lseg, lseg->pls_range.iomode,
                                lseg->pls_range.offset,
                                lseg->pls_range.length);
+                       if (test_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags))
+                               tmp_list = &lo->plh_return_segs;
                        if (mark_lseg_invalid(lseg, tmp_list))
                                continue;
                        remaining++;