diff options
Diffstat (limited to 'fs/nfs/nfs4filelayout.c')
-rw-r--r-- | fs/nfs/nfs4filelayout.c | 80 |
1 files changed, 72 insertions, 8 deletions
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c index f9d03abcd04c..be93a622872c 100644 --- a/fs/nfs/nfs4filelayout.c +++ b/fs/nfs/nfs4filelayout.c | |||
@@ -334,6 +334,9 @@ filelayout_read_pagelist(struct nfs_read_data *data) | |||
334 | __func__, data->inode->i_ino, | 334 | __func__, data->inode->i_ino, |
335 | data->args.pgbase, (size_t)data->args.count, offset); | 335 | data->args.pgbase, (size_t)data->args.count, offset); |
336 | 336 | ||
337 | if (test_bit(NFS_DEVICEID_INVALID, &FILELAYOUT_DEVID_NODE(lseg)->flags)) | ||
338 | return PNFS_NOT_ATTEMPTED; | ||
339 | |||
337 | /* Retrieve the correct rpc_client for the byte range */ | 340 | /* Retrieve the correct rpc_client for the byte range */ |
338 | j = nfs4_fl_calc_j_index(lseg, offset); | 341 | j = nfs4_fl_calc_j_index(lseg, offset); |
339 | idx = nfs4_fl_calc_ds_index(lseg, j); | 342 | idx = nfs4_fl_calc_ds_index(lseg, j); |
@@ -344,8 +347,7 @@ filelayout_read_pagelist(struct nfs_read_data *data) | |||
344 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); | 347 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); |
345 | return PNFS_NOT_ATTEMPTED; | 348 | return PNFS_NOT_ATTEMPTED; |
346 | } | 349 | } |
347 | dprintk("%s USE DS:ip %x %hu\n", __func__, | 350 | dprintk("%s USE DS: %s\n", __func__, ds->ds_remotestr); |
348 | ntohl(ds->ds_ip_addr), ntohs(ds->ds_port)); | ||
349 | 351 | ||
350 | /* No multipath support. Use first DS */ | 352 | /* No multipath support. Use first DS */ |
351 | data->ds_clp = ds->ds_clp; | 353 | data->ds_clp = ds->ds_clp; |
@@ -374,6 +376,9 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync) | |||
374 | struct nfs_fh *fh; | 376 | struct nfs_fh *fh; |
375 | int status; | 377 | int status; |
376 | 378 | ||
379 | if (test_bit(NFS_DEVICEID_INVALID, &FILELAYOUT_DEVID_NODE(lseg)->flags)) | ||
380 | return PNFS_NOT_ATTEMPTED; | ||
381 | |||
377 | /* Retrieve the correct rpc_client for the byte range */ | 382 | /* Retrieve the correct rpc_client for the byte range */ |
378 | j = nfs4_fl_calc_j_index(lseg, offset); | 383 | j = nfs4_fl_calc_j_index(lseg, offset); |
379 | idx = nfs4_fl_calc_ds_index(lseg, j); | 384 | idx = nfs4_fl_calc_ds_index(lseg, j); |
@@ -384,9 +389,9 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync) | |||
384 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); | 389 | set_bit(lo_fail_bit(IOMODE_READ), &lseg->pls_layout->plh_flags); |
385 | return PNFS_NOT_ATTEMPTED; | 390 | return PNFS_NOT_ATTEMPTED; |
386 | } | 391 | } |
387 | dprintk("%s ino %lu sync %d req %Zu@%llu DS:%x:%hu\n", __func__, | 392 | dprintk("%s ino %lu sync %d req %Zu@%llu DS: %s\n", __func__, |
388 | data->inode->i_ino, sync, (size_t) data->args.count, offset, | 393 | data->inode->i_ino, sync, (size_t) data->args.count, offset, |
389 | ntohl(ds->ds_ip_addr), ntohs(ds->ds_port)); | 394 | ds->ds_remotestr); |
390 | 395 | ||
391 | data->write_done_cb = filelayout_write_done_cb; | 396 | data->write_done_cb = filelayout_write_done_cb; |
392 | data->ds_clp = ds->ds_clp; | 397 | data->ds_clp = ds->ds_clp; |
@@ -428,6 +433,14 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo, | |||
428 | 433 | ||
429 | dprintk("--> %s\n", __func__); | 434 | dprintk("--> %s\n", __func__); |
430 | 435 | ||
436 | /* FIXME: remove this check when layout segment support is added */ | ||
437 | if (lgr->range.offset != 0 || | ||
438 | lgr->range.length != NFS4_MAX_UINT64) { | ||
439 | dprintk("%s Only whole file layouts supported. Use MDS i/o\n", | ||
440 | __func__); | ||
441 | goto out; | ||
442 | } | ||
443 | |||
431 | if (fl->pattern_offset > lgr->range.offset) { | 444 | if (fl->pattern_offset > lgr->range.offset) { |
432 | dprintk("%s pattern_offset %lld too large\n", | 445 | dprintk("%s pattern_offset %lld too large\n", |
433 | __func__, fl->pattern_offset); | 446 | __func__, fl->pattern_offset); |
@@ -449,6 +462,10 @@ filelayout_check_layout(struct pnfs_layout_hdr *lo, | |||
449 | goto out; | 462 | goto out; |
450 | } else | 463 | } else |
451 | dsaddr = container_of(d, struct nfs4_file_layout_dsaddr, id_node); | 464 | dsaddr = container_of(d, struct nfs4_file_layout_dsaddr, id_node); |
465 | /* Found deviceid is being reaped */ | ||
466 | if (test_bit(NFS_DEVICEID_INVALID, &dsaddr->id_node.flags)) | ||
467 | goto out_put; | ||
468 | |||
452 | fl->dsaddr = dsaddr; | 469 | fl->dsaddr = dsaddr; |
453 | 470 | ||
454 | if (fl->first_stripe_index < 0 || | 471 | if (fl->first_stripe_index < 0 || |
@@ -659,7 +676,7 @@ filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid, | |||
659 | * return true : coalesce page | 676 | * return true : coalesce page |
660 | * return false : don't coalesce page | 677 | * return false : don't coalesce page |
661 | */ | 678 | */ |
662 | bool | 679 | static bool |
663 | filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, | 680 | filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, |
664 | struct nfs_page *req) | 681 | struct nfs_page *req) |
665 | { | 682 | { |
@@ -670,8 +687,6 @@ filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, | |||
670 | !nfs_generic_pg_test(pgio, prev, req)) | 687 | !nfs_generic_pg_test(pgio, prev, req)) |
671 | return false; | 688 | return false; |
672 | 689 | ||
673 | if (!pgio->pg_lseg) | ||
674 | return 1; | ||
675 | p_stripe = (u64)prev->wb_index << PAGE_CACHE_SHIFT; | 690 | p_stripe = (u64)prev->wb_index << PAGE_CACHE_SHIFT; |
676 | r_stripe = (u64)req->wb_index << PAGE_CACHE_SHIFT; | 691 | r_stripe = (u64)req->wb_index << PAGE_CACHE_SHIFT; |
677 | stripe_unit = FILELAYOUT_LSEG(pgio->pg_lseg)->stripe_unit; | 692 | stripe_unit = FILELAYOUT_LSEG(pgio->pg_lseg)->stripe_unit; |
@@ -682,6 +697,52 @@ filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, | |||
682 | return (p_stripe == r_stripe); | 697 | return (p_stripe == r_stripe); |
683 | } | 698 | } |
684 | 699 | ||
700 | void | ||
701 | filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio, | ||
702 | struct nfs_page *req) | ||
703 | { | ||
704 | BUG_ON(pgio->pg_lseg != NULL); | ||
705 | |||
706 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | ||
707 | req->wb_context, | ||
708 | 0, | ||
709 | NFS4_MAX_UINT64, | ||
710 | IOMODE_READ, | ||
711 | GFP_KERNEL); | ||
712 | /* If no lseg, fall back to read through mds */ | ||
713 | if (pgio->pg_lseg == NULL) | ||
714 | nfs_pageio_reset_read_mds(pgio); | ||
715 | } | ||
716 | |||
717 | void | ||
718 | filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio, | ||
719 | struct nfs_page *req) | ||
720 | { | ||
721 | BUG_ON(pgio->pg_lseg != NULL); | ||
722 | |||
723 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | ||
724 | req->wb_context, | ||
725 | 0, | ||
726 | NFS4_MAX_UINT64, | ||
727 | IOMODE_RW, | ||
728 | GFP_NOFS); | ||
729 | /* If no lseg, fall back to write through mds */ | ||
730 | if (pgio->pg_lseg == NULL) | ||
731 | nfs_pageio_reset_write_mds(pgio); | ||
732 | } | ||
733 | |||
734 | static const struct nfs_pageio_ops filelayout_pg_read_ops = { | ||
735 | .pg_init = filelayout_pg_init_read, | ||
736 | .pg_test = filelayout_pg_test, | ||
737 | .pg_doio = pnfs_generic_pg_readpages, | ||
738 | }; | ||
739 | |||
740 | static const struct nfs_pageio_ops filelayout_pg_write_ops = { | ||
741 | .pg_init = filelayout_pg_init_write, | ||
742 | .pg_test = filelayout_pg_test, | ||
743 | .pg_doio = pnfs_generic_pg_writepages, | ||
744 | }; | ||
745 | |||
685 | static bool filelayout_mark_pnfs_commit(struct pnfs_layout_segment *lseg) | 746 | static bool filelayout_mark_pnfs_commit(struct pnfs_layout_segment *lseg) |
686 | { | 747 | { |
687 | return !FILELAYOUT_LSEG(lseg)->commit_through_mds; | 748 | return !FILELAYOUT_LSEG(lseg)->commit_through_mds; |
@@ -879,7 +940,8 @@ static struct pnfs_layoutdriver_type filelayout_type = { | |||
879 | .owner = THIS_MODULE, | 940 | .owner = THIS_MODULE, |
880 | .alloc_lseg = filelayout_alloc_lseg, | 941 | .alloc_lseg = filelayout_alloc_lseg, |
881 | .free_lseg = filelayout_free_lseg, | 942 | .free_lseg = filelayout_free_lseg, |
882 | .pg_test = filelayout_pg_test, | 943 | .pg_read_ops = &filelayout_pg_read_ops, |
944 | .pg_write_ops = &filelayout_pg_write_ops, | ||
883 | .mark_pnfs_commit = filelayout_mark_pnfs_commit, | 945 | .mark_pnfs_commit = filelayout_mark_pnfs_commit, |
884 | .choose_commit_list = filelayout_choose_commit_list, | 946 | .choose_commit_list = filelayout_choose_commit_list, |
885 | .commit_pagelist = filelayout_commit_pagelist, | 947 | .commit_pagelist = filelayout_commit_pagelist, |
@@ -902,5 +964,7 @@ static void __exit nfs4filelayout_exit(void) | |||
902 | pnfs_unregister_layoutdriver(&filelayout_type); | 964 | pnfs_unregister_layoutdriver(&filelayout_type); |
903 | } | 965 | } |
904 | 966 | ||
967 | MODULE_ALIAS("nfs-layouttype4-1"); | ||
968 | |||
905 | module_init(nfs4filelayout_init); | 969 | module_init(nfs4filelayout_init); |
906 | module_exit(nfs4filelayout_exit); | 970 | module_exit(nfs4filelayout_exit); |