nfs4.1: prevent race that allowed use of freed layout in _pnfs_return_layout
authorFred Isaman <iisaman@netapp.com>
Wed, 15 Jun 2011 16:31:02 +0000 (12:31 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 15 Jun 2011 16:39:23 +0000 (12:39 -0400)
mark_matching_lsegs_invalid could put the last ref to the layout, so
the get_layout_hdr needs to be called first.

Signed-off-by: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/pnfs.c

index 8f958228125277e66497ca50adf34274107befed..730d4dbbaf685ec0450c5a47543dde99c234af1a 100644 (file)
@@ -640,10 +640,10 @@ _pnfs_return_layout(struct inode *ino)
                return status;
        }
        stateid = nfsi->layout->plh_stateid;
-       mark_matching_lsegs_invalid(lo, &tmp_list, NULL);
-       lo->plh_block_lgets++;
        /* Reference matched in nfs4_layoutreturn_release */
        get_layout_hdr(lo);
+       mark_matching_lsegs_invalid(lo, &tmp_list, NULL);
+       lo->plh_block_lgets++;
        spin_unlock(&ino->i_lock);
        pnfs_free_lseg_list(&tmp_list);