pnfs: add return_range method
authorChristoph Hellwig <hch@lst.de>
Wed, 10 Sep 2014 15:23:31 +0000 (08:23 -0700)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Wed, 10 Sep 2014 19:47:03 +0000 (12:47 -0700)
If a layout driver keeps per-inode state outside of the layout segments it
needs to be notified of any layout returns or recalls on an inode, and not
just about the freeing of layout segments.  Add a method to acomplish this,
which will allow the block layout driver to handle the case of truncated
and re-expanded files properly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/callback_proc.c
fs/nfs/pnfs.c
fs/nfs/pnfs.h

index 0d269515c64db917305f79a7ebe64491dfe8a5ef..56bd0eaf645e939c460a3dfff7632dafdfa8fbac 100644 (file)
@@ -181,10 +181,16 @@ static u32 initiate_file_draining(struct nfs_client *clp,
        spin_lock(&ino->i_lock);
        if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags) ||
            pnfs_mark_matching_lsegs_invalid(lo, &free_me_list,
-                                       &args->cbl_range))
+                                       &args->cbl_range)) {
                rv = NFS4ERR_DELAY;
-       else
-               rv = NFS4ERR_NOMATCHING_LAYOUT;
+               goto unlock;
+       }
+
+       if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
+               NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo,
+                       &args->cbl_range);
+       }
+unlock:
        spin_unlock(&ino->i_lock);
        pnfs_free_lseg_list(&free_me_list);
        pnfs_put_layout_hdr(lo);
index ce5d1ea695d16678b0f7a3ddab68a1cd0ef5f385..76de7f568119c7739c2f72fea155db3ee0d1bbec 100644 (file)
@@ -857,6 +857,16 @@ _pnfs_return_layout(struct inode *ino)
        empty = list_empty(&lo->plh_segs);
        pnfs_clear_layoutcommit(ino, &tmp_list);
        pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL);
+
+       if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
+               struct pnfs_layout_range range = {
+                       .iomode         = IOMODE_ANY,
+                       .offset         = 0,
+                       .length         = NFS4_MAX_UINT64,
+               };
+               NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo, &range);
+       }
+
        /* Don't send a LAYOUTRETURN if list was initially empty */
        if (empty) {
                spin_unlock(&ino->i_lock);
index a4c530e52149432a00f08eae69579e74b3641f0f..2c2494225930fd430c89044ac20534a5cffcb053 100644 (file)
@@ -94,6 +94,9 @@ struct pnfs_layoutdriver_type {
        struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags);
        void (*free_lseg) (struct pnfs_layout_segment *lseg);
 
+       void (*return_range) (struct pnfs_layout_hdr *lo,
+                             struct pnfs_layout_range *range);
+
        /* test for nfs page cache coalescing */
        const struct nfs_pageio_ops *pg_read_ops;
        const struct nfs_pageio_ops *pg_write_ops;