diff options
author | Fred Isaman <iisaman@netapp.com> | 2011-02-28 20:34:18 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-03-11 15:38:42 -0500 |
commit | cfe7f4120f8b1b9465c333d1e42efd4669b1799f (patch) | |
tree | a55e5fc7dbafdf43588a480a0348da0ad8e1eb9e /fs/nfs/nfs4filelayout.c | |
parent | d83217c13531fd59730d77b5c2284e90e56c0a50 (diff) |
NFSv4.1: filelayout i/o helpers
Prepare for filelayout_read_pagelist with helper functions that find the correct
data server, filehandle, and offset.
Signed-off-by: Andy Adamson <andros@citi.umich.edu>
Signed-off-by: Dean Hildebrand <dhildeb@us.ibm.com>
Signed-off-by: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Marc Eshel <eshel@almaden.ibm.com>
Signed-off-by: Mike Sager <sager@netapp.com>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Tao Guo <guotao@nrchpc.ac.cn>
Signed-off-by: Tigran Mkrtchyan <tigran@anahit.desy.de>
Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4filelayout.c')
-rw-r--r-- | fs/nfs/nfs4filelayout.c | 34 |
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 | ||
69 | static loff_t | ||
70 | filelayout_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 | */ | ||
87 | static loff_t | ||
88 | filelayout_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 | * |