aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-09-10 11:23:31 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-09-10 15:47:03 -0400
commitc88953d87f5c8cd95bebcbd6d15f2f0cdd348136 (patch)
tree6805b3c8feb934404205d5e79a2cf37dde87647f
parent612aa983a041056c3368aacfdc9febd406d245a8 (diff)
pnfs: add return_range method
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>
-rw-r--r--fs/nfs/callback_proc.c12
-rw-r--r--fs/nfs/pnfs.c10
-rw-r--r--fs/nfs/pnfs.h3
3 files changed, 22 insertions, 3 deletions
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 0d269515c64d..56bd0eaf645e 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -181,10 +181,16 @@ static u32 initiate_file_draining(struct nfs_client *clp,
181 spin_lock(&ino->i_lock); 181 spin_lock(&ino->i_lock);
182 if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags) || 182 if (test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags) ||
183 pnfs_mark_matching_lsegs_invalid(lo, &free_me_list, 183 pnfs_mark_matching_lsegs_invalid(lo, &free_me_list,
184 &args->cbl_range)) 184 &args->cbl_range)) {
185 rv = NFS4ERR_DELAY; 185 rv = NFS4ERR_DELAY;
186 else 186 goto unlock;
187 rv = NFS4ERR_NOMATCHING_LAYOUT; 187 }
188
189 if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
190 NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo,
191 &args->cbl_range);
192 }
193unlock:
188 spin_unlock(&ino->i_lock); 194 spin_unlock(&ino->i_lock);
189 pnfs_free_lseg_list(&free_me_list); 195 pnfs_free_lseg_list(&free_me_list);
190 pnfs_put_layout_hdr(lo); 196 pnfs_put_layout_hdr(lo);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index ce5d1ea695d1..76de7f568119 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -857,6 +857,16 @@ _pnfs_return_layout(struct inode *ino)
857 empty = list_empty(&lo->plh_segs); 857 empty = list_empty(&lo->plh_segs);
858 pnfs_clear_layoutcommit(ino, &tmp_list); 858 pnfs_clear_layoutcommit(ino, &tmp_list);
859 pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL); 859 pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL);
860
861 if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
862 struct pnfs_layout_range range = {
863 .iomode = IOMODE_ANY,
864 .offset = 0,
865 .length = NFS4_MAX_UINT64,
866 };
867 NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo, &range);
868 }
869
860 /* Don't send a LAYOUTRETURN if list was initially empty */ 870 /* Don't send a LAYOUTRETURN if list was initially empty */
861 if (empty) { 871 if (empty) {
862 spin_unlock(&ino->i_lock); 872 spin_unlock(&ino->i_lock);
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index a4c530e52149..2c2494225930 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -94,6 +94,9 @@ struct pnfs_layoutdriver_type {
94 struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags); 94 struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags);
95 void (*free_lseg) (struct pnfs_layout_segment *lseg); 95 void (*free_lseg) (struct pnfs_layout_segment *lseg);
96 96
97 void (*return_range) (struct pnfs_layout_hdr *lo,
98 struct pnfs_layout_range *range);
99
97 /* test for nfs page cache coalescing */ 100 /* test for nfs page cache coalescing */
98 const struct nfs_pageio_ops *pg_read_ops; 101 const struct nfs_pageio_ops *pg_read_ops;
99 const struct nfs_pageio_ops *pg_write_ops; 102 const struct nfs_pageio_ops *pg_write_ops;