pnfs.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. /*
  2. * pNFS client data structures.
  3. *
  4. * Copyright (c) 2002
  5. * The Regents of the University of Michigan
  6. * All Rights Reserved
  7. *
  8. * Dean Hildebrand <dhildebz@umich.edu>
  9. *
  10. * Permission is granted to use, copy, create derivative works, and
  11. * redistribute this software and such derivative works for any purpose,
  12. * so long as the name of the University of Michigan is not used in
  13. * any advertising or publicity pertaining to the use or distribution
  14. * of this software without specific, written prior authorization. If
  15. * the above copyright notice or any other identification of the
  16. * University of Michigan is included in any copy of any portion of
  17. * this software, then the disclaimer below must also be included.
  18. *
  19. * This software is provided as is, without representation or warranty
  20. * of any kind either express or implied, including without limitation
  21. * the implied warranties of merchantability, fitness for a particular
  22. * purpose, or noninfringement. The Regents of the University of
  23. * Michigan shall not be liable for any damages, including special,
  24. * indirect, incidental, or consequential damages, with respect to any
  25. * claim arising out of or in connection with the use of the software,
  26. * even if it has been or is hereafter advised of the possibility of
  27. * such damages.
  28. */
  29. #ifndef FS_NFS_PNFS_H
  30. #define FS_NFS_PNFS_H
  31. #include <linux/nfs_fs.h>
  32. #include <linux/nfs_page.h>
  33. #include <linux/workqueue.h>
  34. enum {
  35. NFS_LSEG_VALID = 0, /* cleared when lseg is recalled/returned */
  36. NFS_LSEG_ROC, /* roc bit received from server */
  37. NFS_LSEG_LAYOUTCOMMIT, /* layoutcommit bit set for layoutcommit */
  38. NFS_LSEG_LAYOUTRETURN, /* layoutreturn bit set for layoutreturn */
  39. };
  40. /* Individual ip address */
  41. struct nfs4_pnfs_ds_addr {
  42. struct sockaddr_storage da_addr;
  43. size_t da_addrlen;
  44. struct list_head da_node; /* nfs4_pnfs_dev_hlist dev_dslist */
  45. char *da_remotestr; /* human readable addr+port */
  46. };
  47. struct nfs4_pnfs_ds {
  48. struct list_head ds_node; /* nfs4_pnfs_dev_hlist dev_dslist */
  49. char *ds_remotestr; /* comma sep list of addrs */
  50. struct list_head ds_addrs;
  51. struct nfs_client *ds_clp;
  52. atomic_t ds_count;
  53. unsigned long ds_state;
  54. #define NFS4DS_CONNECTING 0 /* ds is establishing connection */
  55. };
  56. struct pnfs_layout_segment {
  57. struct list_head pls_list;
  58. struct list_head pls_lc_list;
  59. struct pnfs_layout_range pls_range;
  60. atomic_t pls_refcount;
  61. unsigned long pls_flags;
  62. struct pnfs_layout_hdr *pls_layout;
  63. struct work_struct pls_work;
  64. };
  65. enum pnfs_try_status {
  66. PNFS_ATTEMPTED = 0,
  67. PNFS_NOT_ATTEMPTED = 1,
  68. PNFS_TRY_AGAIN = 2,
  69. };
  70. #ifdef CONFIG_NFS_V4_1
  71. #define LAYOUT_NFSV4_1_MODULE_PREFIX "nfs-layouttype4"
  72. /*
  73. * Default data server connection timeout and retrans vaules.
  74. * Set by module parameters dataserver_timeo and dataserver_retrans.
  75. */
  76. #define NFS4_DEF_DS_TIMEO 600 /* in tenths of a second */
  77. #define NFS4_DEF_DS_RETRANS 5
  78. /* error codes for internal use */
  79. #define NFS4ERR_RESET_TO_MDS 12001
  80. #define NFS4ERR_RESET_TO_PNFS 12002
  81. enum {
  82. NFS_LAYOUT_RO_FAILED = 0, /* get ro layout failed stop trying */
  83. NFS_LAYOUT_RW_FAILED, /* get rw layout failed stop trying */
  84. NFS_LAYOUT_BULK_RECALL, /* bulk recall affecting layout */
  85. NFS_LAYOUT_ROC, /* some lseg had roc bit set */
  86. NFS_LAYOUT_RETURN, /* Return this layout ASAP */
  87. NFS_LAYOUT_RETURN_BEFORE_CLOSE, /* Return this layout before close */
  88. NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */
  89. NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */
  90. NFS_LAYOUT_RETRY_LAYOUTGET, /* Retry layoutget */
  91. };
  92. enum layoutdriver_policy_flags {
  93. /* Should the pNFS client commit and return the layout upon truncate to
  94. * a smaller size */
  95. PNFS_LAYOUTRET_ON_SETATTR = 1 << 0,
  96. PNFS_LAYOUTRET_ON_ERROR = 1 << 1,
  97. PNFS_READ_WHOLE_PAGE = 1 << 2,
  98. };
  99. struct nfs4_deviceid_node;
  100. /* Per-layout driver specific registration structure */
  101. struct pnfs_layoutdriver_type {
  102. struct list_head pnfs_tblid;
  103. const u32 id;
  104. const char *name;
  105. struct module *owner;
  106. unsigned flags;
  107. unsigned max_deviceinfo_size;
  108. int (*set_layoutdriver) (struct nfs_server *, const struct nfs_fh *);
  109. int (*clear_layoutdriver) (struct nfs_server *);
  110. struct pnfs_layout_hdr * (*alloc_layout_hdr) (struct inode *inode, gfp_t gfp_flags);
  111. void (*free_layout_hdr) (struct pnfs_layout_hdr *);
  112. struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags);
  113. void (*free_lseg) (struct pnfs_layout_segment *lseg);
  114. void (*return_range) (struct pnfs_layout_hdr *lo,
  115. struct pnfs_layout_range *range);
  116. /* test for nfs page cache coalescing */
  117. const struct nfs_pageio_ops *pg_read_ops;
  118. const struct nfs_pageio_ops *pg_write_ops;
  119. struct pnfs_ds_commit_info *(*get_ds_info) (struct inode *inode);
  120. void (*mark_request_commit) (struct nfs_page *req,
  121. struct pnfs_layout_segment *lseg,
  122. struct nfs_commit_info *cinfo,
  123. u32 ds_commit_idx);
  124. void (*clear_request_commit) (struct nfs_page *req,
  125. struct nfs_commit_info *cinfo);
  126. int (*scan_commit_lists) (struct nfs_commit_info *cinfo,
  127. int max);
  128. void (*recover_commit_reqs) (struct list_head *list,
  129. struct nfs_commit_info *cinfo);
  130. struct nfs_page * (*search_commit_reqs)(struct nfs_commit_info *cinfo,
  131. struct page *page);
  132. int (*commit_pagelist)(struct inode *inode,
  133. struct list_head *mds_pages,
  134. int how,
  135. struct nfs_commit_info *cinfo);
  136. int (*sync)(struct inode *inode, bool datasync);
  137. /*
  138. * Return PNFS_ATTEMPTED to indicate the layout code has attempted
  139. * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS
  140. */
  141. enum pnfs_try_status (*read_pagelist)(struct nfs_pgio_header *);
  142. enum pnfs_try_status (*write_pagelist)(struct nfs_pgio_header *, int);
  143. void (*free_deviceid_node) (struct nfs4_deviceid_node *);
  144. struct nfs4_deviceid_node * (*alloc_deviceid_node)
  145. (struct nfs_server *server, struct pnfs_device *pdev,
  146. gfp_t gfp_flags);
  147. void (*encode_layoutreturn) (struct pnfs_layout_hdr *layoutid,
  148. struct xdr_stream *xdr,
  149. const struct nfs4_layoutreturn_args *args);
  150. void (*cleanup_layoutcommit) (struct nfs4_layoutcommit_data *data);
  151. int (*prepare_layoutcommit) (struct nfs4_layoutcommit_args *args);
  152. void (*encode_layoutcommit) (struct pnfs_layout_hdr *lo,
  153. struct xdr_stream *xdr,
  154. const struct nfs4_layoutcommit_args *args);
  155. };
  156. struct pnfs_layout_hdr {
  157. atomic_t plh_refcount;
  158. struct list_head plh_layouts; /* other client layouts */
  159. struct list_head plh_bulk_destroy;
  160. struct list_head plh_segs; /* layout segments list */
  161. nfs4_stateid plh_stateid;
  162. atomic_t plh_outstanding; /* number of RPCs out */
  163. unsigned long plh_block_lgets; /* block LAYOUTGET if >0 */
  164. u32 plh_barrier; /* ignore lower seqids */
  165. unsigned long plh_retry_timestamp;
  166. unsigned long plh_flags;
  167. enum pnfs_iomode plh_return_iomode;
  168. loff_t plh_lwb; /* last write byte for layoutcommit */
  169. struct rpc_cred *plh_lc_cred; /* layoutcommit cred */
  170. struct inode *plh_inode;
  171. };
  172. struct pnfs_device {
  173. struct nfs4_deviceid dev_id;
  174. unsigned int layout_type;
  175. unsigned int mincount;
  176. unsigned int maxcount; /* gdia_maxcount */
  177. struct page **pages;
  178. unsigned int pgbase;
  179. unsigned int pglen; /* reply buffer length */
  180. unsigned char nocache : 1;/* May not be cached */
  181. };
  182. #define NFS4_PNFS_GETDEVLIST_MAXNUM 16
  183. struct pnfs_devicelist {
  184. unsigned int eof;
  185. unsigned int num_devs;
  186. struct nfs4_deviceid dev_id[NFS4_PNFS_GETDEVLIST_MAXNUM];
  187. };
  188. extern int pnfs_register_layoutdriver(struct pnfs_layoutdriver_type *);
  189. extern void pnfs_unregister_layoutdriver(struct pnfs_layoutdriver_type *);
  190. /* nfs4proc.c */
  191. extern int nfs4_proc_getdeviceinfo(struct nfs_server *server,
  192. struct pnfs_device *dev,
  193. struct rpc_cred *cred);
  194. extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags);
  195. extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync);
  196. /* pnfs.c */
  197. void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo);
  198. void pnfs_put_lseg(struct pnfs_layout_segment *lseg);
  199. void pnfs_put_lseg_locked(struct pnfs_layout_segment *lseg);
  200. void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, u32);
  201. void unset_pnfs_layoutdriver(struct nfs_server *);
  202. void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *);
  203. int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc);
  204. void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
  205. struct nfs_page *req, u64 wb_size);
  206. void pnfs_generic_pg_cleanup(struct nfs_pageio_descriptor *);
  207. int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc);
  208. size_t pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio,
  209. struct nfs_page *prev, struct nfs_page *req);
  210. void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg);
  211. struct pnfs_layout_segment *pnfs_layout_process(struct nfs4_layoutget *lgp);
  212. void pnfs_free_lseg_list(struct list_head *tmp_list);
  213. void pnfs_destroy_layout(struct nfs_inode *);
  214. void pnfs_destroy_all_layouts(struct nfs_client *);
  215. int pnfs_destroy_layouts_byfsid(struct nfs_client *clp,
  216. struct nfs_fsid *fsid,
  217. bool is_recall);
  218. int pnfs_destroy_layouts_byclid(struct nfs_client *clp,
  219. bool is_recall);
  220. void pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo);
  221. void pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo,
  222. const nfs4_stateid *new,
  223. bool update_barrier);
  224. int pnfs_choose_layoutget_stateid(nfs4_stateid *dst,
  225. struct pnfs_layout_hdr *lo,
  226. struct pnfs_layout_range *range,
  227. struct nfs4_state *open_state);
  228. int pnfs_mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo,
  229. struct list_head *tmp_list,
  230. struct pnfs_layout_range *recall_range);
  231. bool pnfs_roc(struct inode *ino);
  232. void pnfs_roc_release(struct inode *ino);
  233. void pnfs_roc_set_barrier(struct inode *ino, u32 barrier);
  234. bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task);
  235. void pnfs_set_layoutcommit(struct inode *, struct pnfs_layout_segment *, loff_t);
  236. void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data);
  237. int pnfs_layoutcommit_inode(struct inode *inode, bool sync);
  238. int pnfs_generic_sync(struct inode *inode, bool datasync);
  239. int pnfs_nfs_generic_sync(struct inode *inode, bool datasync);
  240. int _pnfs_return_layout(struct inode *);
  241. int pnfs_commit_and_return_layout(struct inode *);
  242. void pnfs_ld_write_done(struct nfs_pgio_header *);
  243. void pnfs_ld_read_done(struct nfs_pgio_header *);
  244. int pnfs_read_resend_pnfs(struct nfs_pgio_header *);
  245. struct pnfs_layout_segment *pnfs_update_layout(struct inode *ino,
  246. struct nfs_open_context *ctx,
  247. loff_t pos,
  248. u64 count,
  249. enum pnfs_iomode iomode,
  250. gfp_t gfp_flags);
  251. void pnfs_clear_layoutreturn_waitbit(struct pnfs_layout_hdr *lo);
  252. void nfs4_deviceid_mark_client_invalid(struct nfs_client *clp);
  253. int pnfs_read_done_resend_to_mds(struct nfs_pgio_header *);
  254. int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *);
  255. struct nfs4_threshold *pnfs_mdsthreshold_alloc(void);
  256. void pnfs_error_mark_layout_for_return(struct inode *inode,
  257. struct pnfs_layout_segment *lseg);
  258. /* nfs4_deviceid_flags */
  259. enum {
  260. NFS_DEVICEID_INVALID = 0, /* set when MDS clientid recalled */
  261. NFS_DEVICEID_UNAVAILABLE, /* device temporarily unavailable */
  262. NFS_DEVICEID_NOCACHE, /* device may not be cached */
  263. };
  264. /* pnfs_dev.c */
  265. struct nfs4_deviceid_node {
  266. struct hlist_node node;
  267. struct hlist_node tmpnode;
  268. const struct pnfs_layoutdriver_type *ld;
  269. const struct nfs_client *nfs_client;
  270. unsigned long flags;
  271. unsigned long timestamp_unavailable;
  272. struct nfs4_deviceid deviceid;
  273. struct rcu_head rcu;
  274. atomic_t ref;
  275. };
  276. struct nfs4_deviceid_node *
  277. nfs4_find_get_deviceid(struct nfs_server *server,
  278. const struct nfs4_deviceid *id, struct rpc_cred *cred,
  279. gfp_t gfp_mask);
  280. void nfs4_delete_deviceid(const struct pnfs_layoutdriver_type *, const struct nfs_client *, const struct nfs4_deviceid *);
  281. void nfs4_init_deviceid_node(struct nfs4_deviceid_node *, struct nfs_server *,
  282. const struct nfs4_deviceid *);
  283. bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *);
  284. void nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node);
  285. bool nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node);
  286. void nfs4_deviceid_purge_client(const struct nfs_client *);
  287. /* pnfs_nfs.c */
  288. void pnfs_generic_clear_request_commit(struct nfs_page *req,
  289. struct nfs_commit_info *cinfo);
  290. void pnfs_generic_commit_release(void *calldata);
  291. void pnfs_generic_prepare_to_resend_writes(struct nfs_commit_data *data);
  292. void pnfs_generic_rw_release(void *data);
  293. void pnfs_generic_recover_commit_reqs(struct list_head *dst,
  294. struct nfs_commit_info *cinfo);
  295. int pnfs_generic_commit_pagelist(struct inode *inode,
  296. struct list_head *mds_pages,
  297. int how,
  298. struct nfs_commit_info *cinfo,
  299. int (*initiate_commit)(struct nfs_commit_data *data,
  300. int how));
  301. int pnfs_generic_scan_commit_lists(struct nfs_commit_info *cinfo, int max);
  302. void pnfs_generic_write_commit_done(struct rpc_task *task, void *data);
  303. void nfs4_pnfs_ds_put(struct nfs4_pnfs_ds *ds);
  304. struct nfs4_pnfs_ds *nfs4_pnfs_ds_add(struct list_head *dsaddrs,
  305. gfp_t gfp_flags);
  306. void nfs4_pnfs_v3_ds_connect_unload(void);
  307. void nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds,
  308. struct nfs4_deviceid_node *devid, unsigned int timeo,
  309. unsigned int retrans, u32 version, u32 minor_version,
  310. rpc_authflavor_t au_flavor);
  311. struct nfs4_pnfs_ds_addr *nfs4_decode_mp_ds_addr(struct net *net,
  312. struct xdr_stream *xdr,
  313. gfp_t gfp_flags);
  314. void pnfs_layout_mark_request_commit(struct nfs_page *req,
  315. struct pnfs_layout_segment *lseg,
  316. struct nfs_commit_info *cinfo,
  317. u32 ds_commit_idx);
  318. static inline bool nfs_have_layout(struct inode *inode)
  319. {
  320. return NFS_I(inode)->layout != NULL;
  321. }
  322. static inline struct nfs4_deviceid_node *
  323. nfs4_get_deviceid(struct nfs4_deviceid_node *d)
  324. {
  325. atomic_inc(&d->ref);
  326. return d;
  327. }
  328. static inline void pnfs_set_retry_layoutget(struct pnfs_layout_hdr *lo)
  329. {
  330. if (!test_and_set_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags))
  331. atomic_inc(&lo->plh_refcount);
  332. }
  333. static inline void pnfs_clear_retry_layoutget(struct pnfs_layout_hdr *lo)
  334. {
  335. if (test_and_clear_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags)) {
  336. atomic_dec(&lo->plh_refcount);
  337. /* wake up waiters for LAYOUTRETURN as that is not needed */
  338. wake_up_bit(&lo->plh_flags, NFS_LAYOUT_RETURN);
  339. }
  340. }
  341. static inline bool pnfs_should_retry_layoutget(struct pnfs_layout_hdr *lo)
  342. {
  343. return test_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags);
  344. }
  345. static inline struct pnfs_layout_segment *
  346. pnfs_get_lseg(struct pnfs_layout_segment *lseg)
  347. {
  348. if (lseg) {
  349. atomic_inc(&lseg->pls_refcount);
  350. smp_mb__after_atomic();
  351. }
  352. return lseg;
  353. }
  354. /* Return true if a layout driver is being used for this mountpoint */
  355. static inline int pnfs_enabled_sb(struct nfs_server *nfss)
  356. {
  357. return nfss->pnfs_curr_ld != NULL;
  358. }
  359. static inline int
  360. pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how,
  361. struct nfs_commit_info *cinfo)
  362. {
  363. if (cinfo->ds == NULL || cinfo->ds->ncommitting == 0)
  364. return PNFS_NOT_ATTEMPTED;
  365. return NFS_SERVER(inode)->pnfs_curr_ld->commit_pagelist(inode, mds_pages, how, cinfo);
  366. }
  367. static inline struct pnfs_ds_commit_info *
  368. pnfs_get_ds_info(struct inode *inode)
  369. {
  370. struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
  371. if (ld == NULL || ld->get_ds_info == NULL)
  372. return NULL;
  373. return ld->get_ds_info(inode);
  374. }
  375. static inline void
  376. pnfs_generic_mark_devid_invalid(struct nfs4_deviceid_node *node)
  377. {
  378. set_bit(NFS_DEVICEID_INVALID, &node->flags);
  379. }
  380. static inline bool
  381. pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg,
  382. struct nfs_commit_info *cinfo, u32 ds_commit_idx)
  383. {
  384. struct inode *inode = d_inode(req->wb_context->dentry);
  385. struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
  386. if (lseg == NULL || ld->mark_request_commit == NULL)
  387. return false;
  388. ld->mark_request_commit(req, lseg, cinfo, ds_commit_idx);
  389. return true;
  390. }
  391. static inline bool
  392. pnfs_clear_request_commit(struct nfs_page *req, struct nfs_commit_info *cinfo)
  393. {
  394. struct inode *inode = d_inode(req->wb_context->dentry);
  395. struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
  396. if (ld == NULL || ld->clear_request_commit == NULL)
  397. return false;
  398. ld->clear_request_commit(req, cinfo);
  399. return true;
  400. }
  401. static inline int
  402. pnfs_scan_commit_lists(struct inode *inode, struct nfs_commit_info *cinfo,
  403. int max)
  404. {
  405. if (cinfo->ds == NULL || cinfo->ds->nwritten == 0)
  406. return 0;
  407. else
  408. return NFS_SERVER(inode)->pnfs_curr_ld->scan_commit_lists(cinfo, max);
  409. }
  410. static inline struct nfs_page *
  411. pnfs_search_commit_reqs(struct inode *inode, struct nfs_commit_info *cinfo,
  412. struct page *page)
  413. {
  414. struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
  415. if (ld == NULL || ld->search_commit_reqs == NULL)
  416. return NULL;
  417. return ld->search_commit_reqs(cinfo, page);
  418. }
  419. /* Should the pNFS client commit and return the layout upon a setattr */
  420. static inline bool
  421. pnfs_ld_layoutret_on_setattr(struct inode *inode)
  422. {
  423. if (!pnfs_enabled_sb(NFS_SERVER(inode)))
  424. return false;
  425. return NFS_SERVER(inode)->pnfs_curr_ld->flags &
  426. PNFS_LAYOUTRET_ON_SETATTR;
  427. }
  428. static inline bool
  429. pnfs_ld_read_whole_page(struct inode *inode)
  430. {
  431. if (!pnfs_enabled_sb(NFS_SERVER(inode)))
  432. return false;
  433. return NFS_SERVER(inode)->pnfs_curr_ld->flags & PNFS_READ_WHOLE_PAGE;
  434. }
  435. static inline int
  436. pnfs_sync_inode(struct inode *inode, bool datasync)
  437. {
  438. if (!pnfs_enabled_sb(NFS_SERVER(inode)))
  439. return 0;
  440. return NFS_SERVER(inode)->pnfs_curr_ld->sync(inode, datasync);
  441. }
  442. static inline bool
  443. pnfs_layoutcommit_outstanding(struct inode *inode)
  444. {
  445. struct nfs_inode *nfsi = NFS_I(inode);
  446. return test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags) != 0 ||
  447. test_bit(NFS_INO_LAYOUTCOMMITTING, &nfsi->flags) != 0;
  448. }
  449. static inline int pnfs_return_layout(struct inode *ino)
  450. {
  451. struct nfs_inode *nfsi = NFS_I(ino);
  452. struct nfs_server *nfss = NFS_SERVER(ino);
  453. if (pnfs_enabled_sb(nfss) && nfsi->layout)
  454. return _pnfs_return_layout(ino);
  455. return 0;
  456. }
  457. static inline bool
  458. pnfs_use_threshold(struct nfs4_threshold **dst, struct nfs4_threshold *src,
  459. struct nfs_server *nfss)
  460. {
  461. return (dst && src && src->bm != 0 && nfss->pnfs_curr_ld &&
  462. nfss->pnfs_curr_ld->id == src->l_type);
  463. }
  464. #ifdef NFS_DEBUG
  465. void nfs4_print_deviceid(const struct nfs4_deviceid *dev_id);
  466. #else
  467. static inline void nfs4_print_deviceid(const struct nfs4_deviceid *dev_id)
  468. {
  469. }
  470. #endif /* NFS_DEBUG */
  471. #else /* CONFIG_NFS_V4_1 */
  472. static inline bool nfs_have_layout(struct inode *inode)
  473. {
  474. return false;
  475. }
  476. static inline void pnfs_destroy_all_layouts(struct nfs_client *clp)
  477. {
  478. }
  479. static inline void pnfs_destroy_layout(struct nfs_inode *nfsi)
  480. {
  481. }
  482. static inline struct pnfs_layout_segment *
  483. pnfs_get_lseg(struct pnfs_layout_segment *lseg)
  484. {
  485. return NULL;
  486. }
  487. static inline void pnfs_put_lseg(struct pnfs_layout_segment *lseg)
  488. {
  489. }
  490. static inline int pnfs_return_layout(struct inode *ino)
  491. {
  492. return 0;
  493. }
  494. static inline int pnfs_commit_and_return_layout(struct inode *inode)
  495. {
  496. return 0;
  497. }
  498. static inline bool
  499. pnfs_ld_layoutret_on_setattr(struct inode *inode)
  500. {
  501. return false;
  502. }
  503. static inline bool
  504. pnfs_ld_read_whole_page(struct inode *inode)
  505. {
  506. return false;
  507. }
  508. static inline int
  509. pnfs_sync_inode(struct inode *inode, bool datasync)
  510. {
  511. return 0;
  512. }
  513. static inline bool
  514. pnfs_roc(struct inode *ino)
  515. {
  516. return false;
  517. }
  518. static inline void
  519. pnfs_roc_release(struct inode *ino)
  520. {
  521. }
  522. static inline void
  523. pnfs_roc_set_barrier(struct inode *ino, u32 barrier)
  524. {
  525. }
  526. static inline bool
  527. pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task)
  528. {
  529. return false;
  530. }
  531. static inline void set_pnfs_layoutdriver(struct nfs_server *s,
  532. const struct nfs_fh *mntfh, u32 id)
  533. {
  534. }
  535. static inline void unset_pnfs_layoutdriver(struct nfs_server *s)
  536. {
  537. }
  538. static inline int
  539. pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how,
  540. struct nfs_commit_info *cinfo)
  541. {
  542. return PNFS_NOT_ATTEMPTED;
  543. }
  544. static inline struct pnfs_ds_commit_info *
  545. pnfs_get_ds_info(struct inode *inode)
  546. {
  547. return NULL;
  548. }
  549. static inline bool
  550. pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg,
  551. struct nfs_commit_info *cinfo, u32 ds_commit_idx)
  552. {
  553. return false;
  554. }
  555. static inline bool
  556. pnfs_clear_request_commit(struct nfs_page *req, struct nfs_commit_info *cinfo)
  557. {
  558. return false;
  559. }
  560. static inline int
  561. pnfs_scan_commit_lists(struct inode *inode, struct nfs_commit_info *cinfo,
  562. int max)
  563. {
  564. return 0;
  565. }
  566. static inline struct nfs_page *
  567. pnfs_search_commit_reqs(struct inode *inode, struct nfs_commit_info *cinfo,
  568. struct page *page)
  569. {
  570. return NULL;
  571. }
  572. static inline int pnfs_layoutcommit_inode(struct inode *inode, bool sync)
  573. {
  574. return 0;
  575. }
  576. static inline bool
  577. pnfs_use_threshold(struct nfs4_threshold **dst, struct nfs4_threshold *src,
  578. struct nfs_server *nfss)
  579. {
  580. return false;
  581. }
  582. static inline bool
  583. pnfs_layoutcommit_outstanding(struct inode *inode)
  584. {
  585. return false;
  586. }
  587. static inline struct nfs4_threshold *pnfs_mdsthreshold_alloc(void)
  588. {
  589. return NULL;
  590. }
  591. static inline void nfs4_pnfs_v3_ds_connect_unload(void)
  592. {
  593. }
  594. #endif /* CONFIG_NFS_V4_1 */
  595. #endif /* FS_NFS_PNFS_H */