aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4filelayout.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/nfs4filelayout.c')
-rw-r--r--fs/nfs/nfs4filelayout.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 0efe8cbd9e3c..ed833705dcee 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -66,6 +66,40 @@ filelayout_clear_layoutdriver(struct nfs_server *nfss)
66 return 0; 66 return 0;
67} 67}
68 68
69static loff_t
70filelayout_get_dense_offset(struct nfs4_filelayout_segment *flseg,
71 loff_t offset)
72{
73 u32 stripe_width = flseg->stripe_unit * flseg->dsaddr->stripe_count;
74 u64 tmp;
75
76 offset -= flseg->pattern_offset;
77 tmp = offset;
78 do_div(tmp, stripe_width);
79
80 return tmp * flseg->stripe_unit + do_div(offset, flseg->stripe_unit);
81}
82
83/* This function is used by the layout driver to calculate the
84 * offset of the file on the dserver based on whether the
85 * layout type is STRIPE_DENSE or STRIPE_SPARSE
86 */
87static loff_t
88filelayout_get_dserver_offset(struct pnfs_layout_segment *lseg, loff_t offset)
89{
90 struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
91
92 switch (flseg->stripe_type) {
93 case STRIPE_SPARSE:
94 return offset;
95
96 case STRIPE_DENSE:
97 return filelayout_get_dense_offset(flseg, offset);
98 }
99
100 BUG();
101}
102
69/* 103/*
70 * filelayout_check_layout() 104 * filelayout_check_layout()
71 * 105 *