33 #include <linux/nfs_fs.h>
56 #ifdef CONFIG_NFS_V4_1
58 #define LAYOUT_NFSV4_1_MODULE_PREFIX "nfs-layouttype4"
61 NFS_LAYOUT_RO_FAILED = 0,
63 NFS_LAYOUT_BULK_RECALL,
68 enum layoutdriver_policy_flags {
70 PNFS_LAYOUTRET_ON_SETATTR = 1 << 0,
71 PNFS_LAYOUTRET_ON_ERROR = 1 << 1,
74 struct nfs4_deviceid_node;
77 struct pnfs_layoutdriver_type {
87 struct pnfs_layout_hdr * (*alloc_layout_hdr) (
struct inode *
inode,
gfp_t gfp_flags);
88 void (*free_layout_hdr) (
struct pnfs_layout_hdr *);
119 void (*free_deviceid_node) (
struct nfs4_deviceid_node *);
121 void (*encode_layoutreturn) (
struct pnfs_layout_hdr *layoutid,
122 struct xdr_stream *xdr,
127 void (*encode_layoutcommit) (
struct pnfs_layout_hdr *layoutid,
128 struct xdr_stream *xdr,
132 struct pnfs_layout_hdr {
139 unsigned long plh_block_lgets;
141 unsigned long plh_retry_timestamp;
142 unsigned long plh_flags;
144 struct rpc_cred *plh_lc_cred;
145 struct inode *plh_inode;
150 unsigned int layout_type;
151 unsigned int mincount;
157 #define NFS4_PNFS_GETDEVLIST_MAXNUM 16
159 struct pnfs_devicelist {
161 unsigned int num_devs;
169 extern int nfs4_proc_getdevicelist(
struct nfs_server *server,
171 struct pnfs_devicelist *
devlist);
172 extern int nfs4_proc_getdeviceinfo(
struct nfs_server *server,
173 struct pnfs_device *
dev);
202 bool update_barrier);
204 struct pnfs_layout_hdr *lo,
205 struct nfs4_state *open_state);
235 NFS_DEVICEID_INVALID = 0,
236 NFS_DEVICEID_UNAVAILABLE,
240 struct nfs4_deviceid_node {
243 const struct pnfs_layoutdriver_type *
ld;
246 unsigned long timestamp_unavailable;
254 const struct pnfs_layoutdriver_type *,
274 static inline int pnfs_enabled_sb(
struct nfs_server *nfss)
276 return nfss->pnfs_curr_ld !=
NULL;
283 if (cinfo->
ds ==
NULL || cinfo->
ds->ncommitting == 0)
285 return NFS_SERVER(inode)->pnfs_curr_ld->commit_pagelist(inode, mds_pages, how, cinfo);
289 pnfs_get_ds_info(
struct inode *inode)
291 struct pnfs_layoutdriver_type *
ld = NFS_SERVER(inode)->pnfs_curr_ld;
293 if (ld ==
NULL || ld->get_ds_info ==
NULL)
295 return ld->get_ds_info(inode);
302 struct inode *inode = req->
wb_context->dentry->d_inode;
303 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
305 if (lseg ==
NULL || ld->mark_request_commit ==
NULL)
307 ld->mark_request_commit(req, lseg, cinfo);
314 struct inode *inode = req->
wb_context->dentry->d_inode;
315 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
317 if (ld ==
NULL || ld->clear_request_commit ==
NULL)
319 ld->clear_request_commit(req, cinfo);
324 pnfs_scan_commit_lists(
struct inode *inode,
struct nfs_commit_info *cinfo,
327 if (cinfo->
ds ==
NULL || cinfo->
ds->nwritten == 0)
330 return NFS_SERVER(inode)->pnfs_curr_ld->scan_commit_lists(cinfo, max);
334 pnfs_recover_commit_reqs(
struct inode *inode,
struct list_head *
list,
337 if (cinfo->
ds ==
NULL || cinfo->
ds->nwritten == 0)
339 NFS_SERVER(inode)->pnfs_curr_ld->recover_commit_reqs(list, cinfo);
344 pnfs_ld_layoutret_on_setattr(
struct inode *inode)
346 if (!pnfs_enabled_sb(NFS_SERVER(inode)))
348 return NFS_SERVER(inode)->pnfs_curr_ld->flags &
349 PNFS_LAYOUTRET_ON_SETATTR;
352 static inline int pnfs_return_layout(
struct inode *
ino)
357 if (pnfs_enabled_sb(nfss) && nfsi->layout)
367 return (dst && src && src->
bm != 0 && nfss->pnfs_curr_ld &&
368 nfss->pnfs_curr_ld->id == src->
l_type);
398 static inline int pnfs_return_layout(
struct inode *ino)
404 pnfs_ld_layoutret_on_setattr(
struct inode *inode)
453 pnfs_commit_list(
struct inode *inode,
struct list_head *mds_pages,
int how,
460 pnfs_get_ds_info(
struct inode *inode)
479 pnfs_scan_commit_lists(
struct inode *inode,
struct nfs_commit_info *cinfo,
486 pnfs_recover_commit_reqs(
struct inode *inode,
struct list_head *list,