diff options
Diffstat (limited to 'fs/nfs/pnfs.h')
| -rw-r--r-- | fs/nfs/pnfs.h | 135 |
1 files changed, 115 insertions, 20 deletions
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 9ae5b765b073..797cd6253adf 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
| @@ -38,6 +38,25 @@ enum { | |||
| 38 | NFS_LSEG_VALID = 0, /* cleared when lseg is recalled/returned */ | 38 | NFS_LSEG_VALID = 0, /* cleared when lseg is recalled/returned */ |
| 39 | NFS_LSEG_ROC, /* roc bit received from server */ | 39 | NFS_LSEG_ROC, /* roc bit received from server */ |
| 40 | NFS_LSEG_LAYOUTCOMMIT, /* layoutcommit bit set for layoutcommit */ | 40 | NFS_LSEG_LAYOUTCOMMIT, /* layoutcommit bit set for layoutcommit */ |
| 41 | NFS_LSEG_LAYOUTRETURN, /* layoutreturn bit set for layoutreturn */ | ||
| 42 | }; | ||
| 43 | |||
| 44 | /* Individual ip address */ | ||
| 45 | struct nfs4_pnfs_ds_addr { | ||
| 46 | struct sockaddr_storage da_addr; | ||
| 47 | size_t da_addrlen; | ||
| 48 | struct list_head da_node; /* nfs4_pnfs_dev_hlist dev_dslist */ | ||
| 49 | char *da_remotestr; /* human readable addr+port */ | ||
| 50 | }; | ||
| 51 | |||
| 52 | struct nfs4_pnfs_ds { | ||
| 53 | struct list_head ds_node; /* nfs4_pnfs_dev_hlist dev_dslist */ | ||
| 54 | char *ds_remotestr; /* comma sep list of addrs */ | ||
| 55 | struct list_head ds_addrs; | ||
| 56 | struct nfs_client *ds_clp; | ||
| 57 | atomic_t ds_count; | ||
| 58 | unsigned long ds_state; | ||
| 59 | #define NFS4DS_CONNECTING 0 /* ds is establishing connection */ | ||
| 41 | }; | 60 | }; |
| 42 | 61 | ||
| 43 | struct pnfs_layout_segment { | 62 | struct pnfs_layout_segment { |
| @@ -53,19 +72,34 @@ struct pnfs_layout_segment { | |||
| 53 | enum pnfs_try_status { | 72 | enum pnfs_try_status { |
| 54 | PNFS_ATTEMPTED = 0, | 73 | PNFS_ATTEMPTED = 0, |
| 55 | PNFS_NOT_ATTEMPTED = 1, | 74 | PNFS_NOT_ATTEMPTED = 1, |
| 75 | PNFS_TRY_AGAIN = 2, | ||
| 56 | }; | 76 | }; |
| 57 | 77 | ||
| 58 | #ifdef CONFIG_NFS_V4_1 | 78 | #ifdef CONFIG_NFS_V4_1 |
| 59 | 79 | ||
| 60 | #define LAYOUT_NFSV4_1_MODULE_PREFIX "nfs-layouttype4" | 80 | #define LAYOUT_NFSV4_1_MODULE_PREFIX "nfs-layouttype4" |
| 61 | 81 | ||
| 82 | /* | ||
| 83 | * Default data server connection timeout and retrans vaules. | ||
| 84 | * Set by module parameters dataserver_timeo and dataserver_retrans. | ||
| 85 | */ | ||
| 86 | #define NFS4_DEF_DS_TIMEO 600 /* in tenths of a second */ | ||
| 87 | #define NFS4_DEF_DS_RETRANS 5 | ||
| 88 | |||
| 89 | /* error codes for internal use */ | ||
| 90 | #define NFS4ERR_RESET_TO_MDS 12001 | ||
| 91 | #define NFS4ERR_RESET_TO_PNFS 12002 | ||
| 92 | |||
| 62 | enum { | 93 | enum { |
| 63 | NFS_LAYOUT_RO_FAILED = 0, /* get ro layout failed stop trying */ | 94 | NFS_LAYOUT_RO_FAILED = 0, /* get ro layout failed stop trying */ |
| 64 | NFS_LAYOUT_RW_FAILED, /* get rw layout failed stop trying */ | 95 | NFS_LAYOUT_RW_FAILED, /* get rw layout failed stop trying */ |
| 65 | NFS_LAYOUT_BULK_RECALL, /* bulk recall affecting layout */ | 96 | NFS_LAYOUT_BULK_RECALL, /* bulk recall affecting layout */ |
| 66 | NFS_LAYOUT_ROC, /* some lseg had roc bit set */ | 97 | NFS_LAYOUT_ROC, /* some lseg had roc bit set */ |
| 67 | NFS_LAYOUT_RETURN, /* Return this layout ASAP */ | 98 | NFS_LAYOUT_RETURN, /* Return this layout ASAP */ |
| 99 | NFS_LAYOUT_RETURN_BEFORE_CLOSE, /* Return this layout before close */ | ||
| 68 | NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */ | 100 | NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */ |
| 101 | NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */ | ||
| 102 | NFS_LAYOUT_RETRY_LAYOUTGET, /* Retry layoutget */ | ||
| 69 | }; | 103 | }; |
| 70 | 104 | ||
| 71 | enum layoutdriver_policy_flags { | 105 | enum layoutdriver_policy_flags { |
| @@ -106,7 +140,8 @@ struct pnfs_layoutdriver_type { | |||
| 106 | struct pnfs_ds_commit_info *(*get_ds_info) (struct inode *inode); | 140 | struct pnfs_ds_commit_info *(*get_ds_info) (struct inode *inode); |
| 107 | void (*mark_request_commit) (struct nfs_page *req, | 141 | void (*mark_request_commit) (struct nfs_page *req, |
| 108 | struct pnfs_layout_segment *lseg, | 142 | struct pnfs_layout_segment *lseg, |
| 109 | struct nfs_commit_info *cinfo); | 143 | struct nfs_commit_info *cinfo, |
| 144 | u32 ds_commit_idx); | ||
| 110 | void (*clear_request_commit) (struct nfs_page *req, | 145 | void (*clear_request_commit) (struct nfs_page *req, |
| 111 | struct nfs_commit_info *cinfo); | 146 | struct nfs_commit_info *cinfo); |
| 112 | int (*scan_commit_lists) (struct nfs_commit_info *cinfo, | 147 | int (*scan_commit_lists) (struct nfs_commit_info *cinfo, |
| @@ -154,6 +189,7 @@ struct pnfs_layout_hdr { | |||
| 154 | u32 plh_barrier; /* ignore lower seqids */ | 189 | u32 plh_barrier; /* ignore lower seqids */ |
| 155 | unsigned long plh_retry_timestamp; | 190 | unsigned long plh_retry_timestamp; |
| 156 | unsigned long plh_flags; | 191 | unsigned long plh_flags; |
| 192 | enum pnfs_iomode plh_return_iomode; | ||
| 157 | loff_t plh_lwb; /* last write byte for layoutcommit */ | 193 | loff_t plh_lwb; /* last write byte for layoutcommit */ |
| 158 | struct rpc_cred *plh_lc_cred; /* layoutcommit cred */ | 194 | struct rpc_cred *plh_lc_cred; /* layoutcommit cred */ |
| 159 | struct inode *plh_inode; | 195 | struct inode *plh_inode; |
| @@ -185,7 +221,7 @@ extern int nfs4_proc_getdeviceinfo(struct nfs_server *server, | |||
| 185 | struct pnfs_device *dev, | 221 | struct pnfs_device *dev, |
| 186 | struct rpc_cred *cred); | 222 | struct rpc_cred *cred); |
| 187 | extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags); | 223 | extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags); |
| 188 | extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp); | 224 | extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync); |
| 189 | 225 | ||
| 190 | /* pnfs.c */ | 226 | /* pnfs.c */ |
| 191 | void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo); | 227 | void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo); |
| @@ -198,6 +234,7 @@ void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page * | |||
| 198 | int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc); | 234 | int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc); |
| 199 | void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, | 235 | void pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, |
| 200 | struct nfs_page *req, u64 wb_size); | 236 | struct nfs_page *req, u64 wb_size); |
| 237 | void pnfs_generic_pg_cleanup(struct nfs_pageio_descriptor *); | ||
| 201 | int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc); | 238 | int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc); |
| 202 | size_t pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, | 239 | size_t pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, |
| 203 | struct nfs_page *prev, struct nfs_page *req); | 240 | struct nfs_page *prev, struct nfs_page *req); |
| @@ -217,6 +254,7 @@ void pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, | |||
| 217 | bool update_barrier); | 254 | bool update_barrier); |
| 218 | int pnfs_choose_layoutget_stateid(nfs4_stateid *dst, | 255 | int pnfs_choose_layoutget_stateid(nfs4_stateid *dst, |
| 219 | struct pnfs_layout_hdr *lo, | 256 | struct pnfs_layout_hdr *lo, |
| 257 | struct pnfs_layout_range *range, | ||
| 220 | struct nfs4_state *open_state); | 258 | struct nfs4_state *open_state); |
| 221 | int pnfs_mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo, | 259 | int pnfs_mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo, |
| 222 | struct list_head *tmp_list, | 260 | struct list_head *tmp_list, |
| @@ -233,17 +271,21 @@ int _pnfs_return_layout(struct inode *); | |||
| 233 | int pnfs_commit_and_return_layout(struct inode *); | 271 | int pnfs_commit_and_return_layout(struct inode *); |
| 234 | void pnfs_ld_write_done(struct nfs_pgio_header *); | 272 | void pnfs_ld_write_done(struct nfs_pgio_header *); |
| 235 | void pnfs_ld_read_done(struct nfs_pgio_header *); | 273 | void pnfs_ld_read_done(struct nfs_pgio_header *); |
| 274 | int pnfs_read_resend_pnfs(struct nfs_pgio_header *); | ||
| 236 | struct pnfs_layout_segment *pnfs_update_layout(struct inode *ino, | 275 | struct pnfs_layout_segment *pnfs_update_layout(struct inode *ino, |
| 237 | struct nfs_open_context *ctx, | 276 | struct nfs_open_context *ctx, |
| 238 | loff_t pos, | 277 | loff_t pos, |
| 239 | u64 count, | 278 | u64 count, |
| 240 | enum pnfs_iomode iomode, | 279 | enum pnfs_iomode iomode, |
| 241 | gfp_t gfp_flags); | 280 | gfp_t gfp_flags); |
| 281 | void pnfs_clear_layoutreturn_waitbit(struct pnfs_layout_hdr *lo); | ||
| 242 | 282 | ||
| 243 | void nfs4_deviceid_mark_client_invalid(struct nfs_client *clp); | 283 | void nfs4_deviceid_mark_client_invalid(struct nfs_client *clp); |
| 244 | int pnfs_read_done_resend_to_mds(struct nfs_pgio_header *); | 284 | int pnfs_read_done_resend_to_mds(struct nfs_pgio_header *); |
| 245 | int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *); | 285 | int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *); |
| 246 | struct nfs4_threshold *pnfs_mdsthreshold_alloc(void); | 286 | struct nfs4_threshold *pnfs_mdsthreshold_alloc(void); |
| 287 | void pnfs_error_mark_layout_for_return(struct inode *inode, | ||
| 288 | struct pnfs_layout_segment *lseg); | ||
| 247 | 289 | ||
| 248 | /* nfs4_deviceid_flags */ | 290 | /* nfs4_deviceid_flags */ |
| 249 | enum { | 291 | enum { |
| @@ -275,6 +317,39 @@ void nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node); | |||
| 275 | bool nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node); | 317 | bool nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node); |
| 276 | void nfs4_deviceid_purge_client(const struct nfs_client *); | 318 | void nfs4_deviceid_purge_client(const struct nfs_client *); |
| 277 | 319 | ||
| 320 | /* pnfs_nfs.c */ | ||
| 321 | void pnfs_generic_clear_request_commit(struct nfs_page *req, | ||
| 322 | struct nfs_commit_info *cinfo); | ||
| 323 | void pnfs_generic_commit_release(void *calldata); | ||
| 324 | void pnfs_generic_prepare_to_resend_writes(struct nfs_commit_data *data); | ||
| 325 | void pnfs_generic_rw_release(void *data); | ||
| 326 | void pnfs_generic_recover_commit_reqs(struct list_head *dst, | ||
| 327 | struct nfs_commit_info *cinfo); | ||
| 328 | int pnfs_generic_commit_pagelist(struct inode *inode, | ||
| 329 | struct list_head *mds_pages, | ||
| 330 | int how, | ||
| 331 | struct nfs_commit_info *cinfo, | ||
| 332 | int (*initiate_commit)(struct nfs_commit_data *data, | ||
| 333 | int how)); | ||
| 334 | int pnfs_generic_scan_commit_lists(struct nfs_commit_info *cinfo, int max); | ||
| 335 | void pnfs_generic_write_commit_done(struct rpc_task *task, void *data); | ||
| 336 | void nfs4_pnfs_ds_put(struct nfs4_pnfs_ds *ds); | ||
| 337 | struct nfs4_pnfs_ds *nfs4_pnfs_ds_add(struct list_head *dsaddrs, | ||
| 338 | gfp_t gfp_flags); | ||
| 339 | void nfs4_pnfs_v3_ds_connect_unload(void); | ||
| 340 | void nfs4_pnfs_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds, | ||
| 341 | struct nfs4_deviceid_node *devid, unsigned int timeo, | ||
| 342 | unsigned int retrans, u32 version, u32 minor_version, | ||
| 343 | rpc_authflavor_t au_flavor); | ||
| 344 | struct nfs4_pnfs_ds_addr *nfs4_decode_mp_ds_addr(struct net *net, | ||
| 345 | struct xdr_stream *xdr, | ||
| 346 | gfp_t gfp_flags); | ||
| 347 | |||
| 348 | static inline bool nfs_have_layout(struct inode *inode) | ||
| 349 | { | ||
| 350 | return NFS_I(inode)->layout != NULL; | ||
| 351 | } | ||
| 352 | |||
| 278 | static inline struct nfs4_deviceid_node * | 353 | static inline struct nfs4_deviceid_node * |
| 279 | nfs4_get_deviceid(struct nfs4_deviceid_node *d) | 354 | nfs4_get_deviceid(struct nfs4_deviceid_node *d) |
| 280 | { | 355 | { |
| @@ -282,6 +357,26 @@ nfs4_get_deviceid(struct nfs4_deviceid_node *d) | |||
| 282 | return d; | 357 | return d; |
| 283 | } | 358 | } |
| 284 | 359 | ||
| 360 | static inline void pnfs_set_retry_layoutget(struct pnfs_layout_hdr *lo) | ||
| 361 | { | ||
| 362 | if (!test_and_set_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags)) | ||
| 363 | atomic_inc(&lo->plh_refcount); | ||
| 364 | } | ||
| 365 | |||
| 366 | static inline void pnfs_clear_retry_layoutget(struct pnfs_layout_hdr *lo) | ||
| 367 | { | ||
| 368 | if (test_and_clear_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags)) { | ||
| 369 | atomic_dec(&lo->plh_refcount); | ||
| 370 | /* wake up waiters for LAYOUTRETURN as that is not needed */ | ||
| 371 | wake_up_bit(&lo->plh_flags, NFS_LAYOUT_RETURN); | ||
| 372 | } | ||
| 373 | } | ||
| 374 | |||
| 375 | static inline bool pnfs_should_retry_layoutget(struct pnfs_layout_hdr *lo) | ||
| 376 | { | ||
| 377 | return test_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags); | ||
| 378 | } | ||
| 379 | |||
| 285 | static inline struct pnfs_layout_segment * | 380 | static inline struct pnfs_layout_segment * |
| 286 | pnfs_get_lseg(struct pnfs_layout_segment *lseg) | 381 | pnfs_get_lseg(struct pnfs_layout_segment *lseg) |
| 287 | { | 382 | { |
| @@ -317,16 +412,22 @@ pnfs_get_ds_info(struct inode *inode) | |||
| 317 | return ld->get_ds_info(inode); | 412 | return ld->get_ds_info(inode); |
| 318 | } | 413 | } |
| 319 | 414 | ||
| 415 | static inline void | ||
| 416 | pnfs_generic_mark_devid_invalid(struct nfs4_deviceid_node *node) | ||
| 417 | { | ||
| 418 | set_bit(NFS_DEVICEID_INVALID, &node->flags); | ||
| 419 | } | ||
| 420 | |||
| 320 | static inline bool | 421 | static inline bool |
| 321 | pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, | 422 | pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, |
| 322 | struct nfs_commit_info *cinfo) | 423 | struct nfs_commit_info *cinfo, u32 ds_commit_idx) |
| 323 | { | 424 | { |
| 324 | struct inode *inode = req->wb_context->dentry->d_inode; | 425 | struct inode *inode = req->wb_context->dentry->d_inode; |
| 325 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; | 426 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; |
| 326 | 427 | ||
| 327 | if (lseg == NULL || ld->mark_request_commit == NULL) | 428 | if (lseg == NULL || ld->mark_request_commit == NULL) |
| 328 | return false; | 429 | return false; |
| 329 | ld->mark_request_commit(req, lseg, cinfo); | 430 | ld->mark_request_commit(req, lseg, cinfo, ds_commit_idx); |
| 330 | return true; | 431 | return true; |
| 331 | } | 432 | } |
| 332 | 433 | ||
| @@ -352,15 +453,6 @@ pnfs_scan_commit_lists(struct inode *inode, struct nfs_commit_info *cinfo, | |||
| 352 | return NFS_SERVER(inode)->pnfs_curr_ld->scan_commit_lists(cinfo, max); | 453 | return NFS_SERVER(inode)->pnfs_curr_ld->scan_commit_lists(cinfo, max); |
| 353 | } | 454 | } |
| 354 | 455 | ||
| 355 | static inline void | ||
| 356 | pnfs_recover_commit_reqs(struct inode *inode, struct list_head *list, | ||
| 357 | struct nfs_commit_info *cinfo) | ||
| 358 | { | ||
| 359 | if (cinfo->ds == NULL || cinfo->ds->nwritten == 0) | ||
| 360 | return; | ||
| 361 | NFS_SERVER(inode)->pnfs_curr_ld->recover_commit_reqs(list, cinfo); | ||
| 362 | } | ||
| 363 | |||
| 364 | static inline struct nfs_page * | 456 | static inline struct nfs_page * |
| 365 | pnfs_search_commit_reqs(struct inode *inode, struct nfs_commit_info *cinfo, | 457 | pnfs_search_commit_reqs(struct inode *inode, struct nfs_commit_info *cinfo, |
| 366 | struct page *page) | 458 | struct page *page) |
| @@ -427,6 +519,11 @@ static inline void nfs4_print_deviceid(const struct nfs4_deviceid *dev_id) | |||
| 427 | #endif /* NFS_DEBUG */ | 519 | #endif /* NFS_DEBUG */ |
| 428 | #else /* CONFIG_NFS_V4_1 */ | 520 | #else /* CONFIG_NFS_V4_1 */ |
| 429 | 521 | ||
| 522 | static inline bool nfs_have_layout(struct inode *inode) | ||
| 523 | { | ||
| 524 | return false; | ||
| 525 | } | ||
| 526 | |||
| 430 | static inline void pnfs_destroy_all_layouts(struct nfs_client *clp) | 527 | static inline void pnfs_destroy_all_layouts(struct nfs_client *clp) |
| 431 | { | 528 | { |
| 432 | } | 529 | } |
| @@ -513,7 +610,7 @@ pnfs_get_ds_info(struct inode *inode) | |||
| 513 | 610 | ||
| 514 | static inline bool | 611 | static inline bool |
| 515 | pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, | 612 | pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, |
| 516 | struct nfs_commit_info *cinfo) | 613 | struct nfs_commit_info *cinfo, u32 ds_commit_idx) |
| 517 | { | 614 | { |
| 518 | return false; | 615 | return false; |
| 519 | } | 616 | } |
| @@ -531,12 +628,6 @@ pnfs_scan_commit_lists(struct inode *inode, struct nfs_commit_info *cinfo, | |||
| 531 | return 0; | 628 | return 0; |
| 532 | } | 629 | } |
| 533 | 630 | ||
| 534 | static inline void | ||
| 535 | pnfs_recover_commit_reqs(struct inode *inode, struct list_head *list, | ||
| 536 | struct nfs_commit_info *cinfo) | ||
| 537 | { | ||
| 538 | } | ||
| 539 | |||
| 540 | static inline struct nfs_page * | 631 | static inline struct nfs_page * |
| 541 | pnfs_search_commit_reqs(struct inode *inode, struct nfs_commit_info *cinfo, | 632 | pnfs_search_commit_reqs(struct inode *inode, struct nfs_commit_info *cinfo, |
| 542 | struct page *page) | 633 | struct page *page) |
| @@ -568,6 +659,10 @@ static inline struct nfs4_threshold *pnfs_mdsthreshold_alloc(void) | |||
| 568 | return NULL; | 659 | return NULL; |
| 569 | } | 660 | } |
| 570 | 661 | ||
| 662 | static inline void nfs4_pnfs_v3_ds_connect_unload(void) | ||
| 663 | { | ||
| 664 | } | ||
| 665 | |||
| 571 | #endif /* CONFIG_NFS_V4_1 */ | 666 | #endif /* CONFIG_NFS_V4_1 */ |
| 572 | 667 | ||
| 573 | #endif /* FS_NFS_PNFS_H */ | 668 | #endif /* FS_NFS_PNFS_H */ |
