diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2011-10-31 18:16:15 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-11-02 23:56:08 -0400 |
commit | 04291b628c450ab6fdb606836585f16336662a4e (patch) | |
tree | 2b0e17d8e774c9188437fd04cc97a2bc50312bab | |
parent | eecfc6312a24e6d0d2883de0a9a6ccf8e993f472 (diff) |
pnfs-obj: move to ore 03: Remove old raid engine
Finally remove all the old raid engine, which is by now
dead code.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/objlayout/objio_osd.c | 504 |
1 files changed, 0 insertions, 504 deletions
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c index 00b384934c32..3161da654a9b 100644 --- a/fs/nfs/objlayout/objio_osd.c +++ b/fs/nfs/objlayout/objio_osd.c | |||
@@ -188,48 +188,6 @@ out: | |||
188 | return err; | 188 | return err; |
189 | } | 189 | } |
190 | 190 | ||
191 | #if 0 | ||
192 | static int _verify_data_map(struct pnfs_osd_layout *layout) | ||
193 | { | ||
194 | struct pnfs_osd_data_map *data_map = &layout->olo_map; | ||
195 | u64 stripe_length; | ||
196 | u32 group_width; | ||
197 | |||
198 | /* FIXME: Only raid0 for now. if not go through MDS */ | ||
199 | if (data_map->odm_raid_algorithm != PNFS_OSD_RAID_0) { | ||
200 | printk(KERN_ERR "Only RAID_0 for now\n"); | ||
201 | return -ENOTSUPP; | ||
202 | } | ||
203 | if (0 != (data_map->odm_num_comps % (data_map->odm_mirror_cnt + 1))) { | ||
204 | printk(KERN_ERR "Data Map wrong, num_comps=%u mirrors=%u\n", | ||
205 | data_map->odm_num_comps, data_map->odm_mirror_cnt); | ||
206 | return -EINVAL; | ||
207 | } | ||
208 | |||
209 | if (data_map->odm_group_width) | ||
210 | group_width = data_map->odm_group_width; | ||
211 | else | ||
212 | group_width = data_map->odm_num_comps / | ||
213 | (data_map->odm_mirror_cnt + 1); | ||
214 | |||
215 | stripe_length = (u64)data_map->odm_stripe_unit * group_width; | ||
216 | if (stripe_length >= (1ULL << 32)) { | ||
217 | printk(KERN_ERR "Total Stripe length(0x%llx)" | ||
218 | " >= 32bit is not supported\n", _LLU(stripe_length)); | ||
219 | return -ENOTSUPP; | ||
220 | } | ||
221 | |||
222 | if (0 != (data_map->odm_stripe_unit & ~PAGE_MASK)) { | ||
223 | printk(KERN_ERR "Stripe Unit(0x%llx)" | ||
224 | " must be Multples of PAGE_SIZE(0x%lx)\n", | ||
225 | _LLU(data_map->odm_stripe_unit), PAGE_SIZE); | ||
226 | return -ENOTSUPP; | ||
227 | } | ||
228 | |||
229 | return 0; | ||
230 | } | ||
231 | #endif | ||
232 | |||
233 | static void copy_single_comp(struct ore_components *oc, unsigned c, | 191 | static void copy_single_comp(struct ore_components *oc, unsigned c, |
234 | struct pnfs_osd_object_cred *src_comp) | 192 | struct pnfs_osd_object_cred *src_comp) |
235 | { | 193 | { |
@@ -441,327 +399,6 @@ static void __on_dev_error(struct ore_io_state *ios, | |||
441 | dev_offset, dev_len, !ios->reading); | 399 | dev_offset, dev_len, !ios->reading); |
442 | } | 400 | } |
443 | 401 | ||
444 | #if 0 | ||
445 | static void _clear_bio(struct bio *bio) | ||
446 | { | ||
447 | struct bio_vec *bv; | ||
448 | unsigned i; | ||
449 | |||
450 | __bio_for_each_segment(bv, bio, i, 0) { | ||
451 | unsigned this_count = bv->bv_len; | ||
452 | |||
453 | if (likely(PAGE_SIZE == this_count)) | ||
454 | clear_highpage(bv->bv_page); | ||
455 | else | ||
456 | zero_user(bv->bv_page, bv->bv_offset, this_count); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | static int _io_check(struct objio_state *ios, bool is_write) | ||
461 | { | ||
462 | enum osd_err_priority oep = OSD_ERR_PRI_NO_ERROR; | ||
463 | int lin_ret = 0; | ||
464 | int i; | ||
465 | |||
466 | for (i = 0; i < ios->numdevs; i++) { | ||
467 | struct osd_sense_info osi; | ||
468 | struct osd_request *or = ios->per_dev[i].or; | ||
469 | int ret; | ||
470 | |||
471 | if (!or) | ||
472 | continue; | ||
473 | |||
474 | ret = osd_req_decode_sense(or, &osi); | ||
475 | if (likely(!ret)) | ||
476 | continue; | ||
477 | |||
478 | if (OSD_ERR_PRI_CLEAR_PAGES == osi.osd_err_pri) { | ||
479 | /* start read offset passed endof file */ | ||
480 | BUG_ON(is_write); | ||
481 | _clear_bio(ios->per_dev[i].bio); | ||
482 | dprintk("%s: start read offset passed end of file " | ||
483 | "offset=0x%llx, length=0x%lx\n", __func__, | ||
484 | _LLU(ios->per_dev[i].offset), | ||
485 | ios->per_dev[i].length); | ||
486 | |||
487 | continue; /* we recovered */ | ||
488 | } | ||
489 | __on_dev_error(ios, is_write, ios->oc->ods[i], | ||
490 | ios->per_dev[i].dev, osi.osd_err_pri, | ||
491 | ios->per_dev[i].offset, ios->per_dev[i].length); | ||
492 | |||
493 | if (osi.osd_err_pri >= oep) { | ||
494 | oep = osi.osd_err_pri; | ||
495 | lin_ret = ret; | ||
496 | } | ||
497 | } | ||
498 | |||
499 | return lin_ret; | ||
500 | } | ||
501 | |||
502 | /* | ||
503 | * Common IO state helpers. | ||
504 | */ | ||
505 | static void _io_free(struct objio_state *ios) | ||
506 | { | ||
507 | unsigned i; | ||
508 | |||
509 | for (i = 0; i < ios->numdevs; i++) { | ||
510 | struct _objio_per_comp *per_dev = &ios->per_dev[i]; | ||
511 | |||
512 | if (per_dev->or) { | ||
513 | osd_end_request(per_dev->or); | ||
514 | per_dev->or = NULL; | ||
515 | } | ||
516 | |||
517 | if (per_dev->bio) { | ||
518 | bio_put(per_dev->bio); | ||
519 | per_dev->bio = NULL; | ||
520 | } | ||
521 | } | ||
522 | } | ||
523 | |||
524 | struct osd_dev *_io_od(struct objio_state *ios, unsigned dev) | ||
525 | { | ||
526 | unsigned min_dev = ios->oc->first_dev; | ||
527 | unsigned max_dev = min_dev + ios->oc->numdevs; | ||
528 | |||
529 | BUG_ON(dev < min_dev || max_dev <= dev); | ||
530 | return ios->oc->ods[dev - min_dev]->od; | ||
531 | } | ||
532 | |||
533 | struct _striping_info { | ||
534 | u64 obj_offset; | ||
535 | u64 group_length; | ||
536 | unsigned dev; | ||
537 | unsigned unit_off; | ||
538 | }; | ||
539 | |||
540 | static void _calc_stripe_info(struct objio_state *ios, u64 file_offset, | ||
541 | struct _striping_info *si) | ||
542 | { | ||
543 | u32 stripe_unit = ios->layout->stripe_unit; | ||
544 | u32 group_width = ios->layout->group_width; | ||
545 | u64 group_depth = ios->layout->group_depth; | ||
546 | u32 U = stripe_unit * group_width; | ||
547 | |||
548 | u64 T = U * group_depth; | ||
549 | u64 S = T * ios->layout->group_count; | ||
550 | u64 M = div64_u64(file_offset, S); | ||
551 | |||
552 | /* | ||
553 | G = (L - (M * S)) / T | ||
554 | H = (L - (M * S)) % T | ||
555 | */ | ||
556 | u64 LmodU = file_offset - M * S; | ||
557 | u32 G = div64_u64(LmodU, T); | ||
558 | u64 H = LmodU - G * T; | ||
559 | |||
560 | u32 N = div_u64(H, U); | ||
561 | |||
562 | div_u64_rem(file_offset, stripe_unit, &si->unit_off); | ||
563 | si->obj_offset = si->unit_off + (N * stripe_unit) + | ||
564 | (M * group_depth * stripe_unit); | ||
565 | |||
566 | /* "H - (N * U)" is just "H % U" so it's bound to u32 */ | ||
567 | si->dev = (u32)(H - (N * U)) / stripe_unit + G * group_width; | ||
568 | si->dev *= ios->layout->mirrors_p1; | ||
569 | |||
570 | si->group_length = T - H; | ||
571 | } | ||
572 | |||
573 | static int _add_stripe_unit(struct objio_state *ios, unsigned *cur_pg, | ||
574 | unsigned pgbase, struct _objio_per_comp *per_dev, int len, | ||
575 | gfp_t gfp_flags) | ||
576 | { | ||
577 | unsigned pg = *cur_pg; | ||
578 | int cur_len = len; | ||
579 | struct request_queue *q = | ||
580 | osd_request_queue(_io_od(ios, per_dev->dev)); | ||
581 | |||
582 | if (per_dev->bio == NULL) { | ||
583 | unsigned pages_in_stripe = ios->layout->group_width * | ||
584 | (ios->layout->stripe_unit / PAGE_SIZE); | ||
585 | unsigned bio_size = (ios->nr_pages + pages_in_stripe) / | ||
586 | ios->layout->group_width; | ||
587 | |||
588 | if (BIO_MAX_PAGES_KMALLOC < bio_size) | ||
589 | bio_size = BIO_MAX_PAGES_KMALLOC; | ||
590 | |||
591 | per_dev->bio = bio_kmalloc(gfp_flags, bio_size); | ||
592 | if (unlikely(!per_dev->bio)) { | ||
593 | dprintk("Faild to allocate BIO size=%u\n", bio_size); | ||
594 | return -ENOMEM; | ||
595 | } | ||
596 | } | ||
597 | |||
598 | while (cur_len > 0) { | ||
599 | unsigned pglen = min_t(unsigned, PAGE_SIZE - pgbase, cur_len); | ||
600 | unsigned added_len; | ||
601 | |||
602 | BUG_ON(ios->nr_pages <= pg); | ||
603 | cur_len -= pglen; | ||
604 | |||
605 | added_len = bio_add_pc_page(q, per_dev->bio, | ||
606 | ios->pages[pg], pglen, pgbase); | ||
607 | if (unlikely(pglen != added_len)) | ||
608 | return -ENOMEM; | ||
609 | pgbase = 0; | ||
610 | ++pg; | ||
611 | } | ||
612 | BUG_ON(cur_len); | ||
613 | |||
614 | per_dev->length += len; | ||
615 | *cur_pg = pg; | ||
616 | return 0; | ||
617 | } | ||
618 | |||
619 | static int _prepare_one_group(struct objio_state *ios, u64 length, | ||
620 | struct _striping_info *si, unsigned *last_pg, | ||
621 | gfp_t gfp_flags) | ||
622 | { | ||
623 | unsigned stripe_unit = ios->layout->stripe_unit; | ||
624 | unsigned mirrors_p1 = ios->layout->mirrors_p1; | ||
625 | unsigned devs_in_group = ios->layout->group_width * mirrors_p1; | ||
626 | unsigned dev = si->dev; | ||
627 | unsigned first_dev = dev - (dev % devs_in_group); | ||
628 | unsigned max_comp = ios->numdevs ? ios->numdevs - mirrors_p1 : 0; | ||
629 | unsigned cur_pg = *last_pg; | ||
630 | int ret = 0; | ||
631 | |||
632 | while (length) { | ||
633 | struct _objio_per_comp *per_dev = &ios->per_dev[dev - first_dev]; | ||
634 | unsigned cur_len, page_off = 0; | ||
635 | |||
636 | if (!per_dev->length) { | ||
637 | per_dev->dev = dev; | ||
638 | if (dev < si->dev) { | ||
639 | per_dev->offset = si->obj_offset + stripe_unit - | ||
640 | si->unit_off; | ||
641 | cur_len = stripe_unit; | ||
642 | } else if (dev == si->dev) { | ||
643 | per_dev->offset = si->obj_offset; | ||
644 | cur_len = stripe_unit - si->unit_off; | ||
645 | page_off = si->unit_off & ~PAGE_MASK; | ||
646 | BUG_ON(page_off && | ||
647 | (page_off != ios->pgbase)); | ||
648 | } else { /* dev > si->dev */ | ||
649 | per_dev->offset = si->obj_offset - si->unit_off; | ||
650 | cur_len = stripe_unit; | ||
651 | } | ||
652 | |||
653 | if (max_comp < dev - first_dev) | ||
654 | max_comp = dev - first_dev; | ||
655 | } else { | ||
656 | cur_len = stripe_unit; | ||
657 | } | ||
658 | if (cur_len >= length) | ||
659 | cur_len = length; | ||
660 | |||
661 | ret = _add_stripe_unit(ios, &cur_pg, page_off , per_dev, | ||
662 | cur_len, gfp_flags); | ||
663 | if (unlikely(ret)) | ||
664 | goto out; | ||
665 | |||
666 | dev += mirrors_p1; | ||
667 | dev = (dev % devs_in_group) + first_dev; | ||
668 | |||
669 | length -= cur_len; | ||
670 | ios->length += cur_len; | ||
671 | } | ||
672 | out: | ||
673 | ios->numdevs = max_comp + mirrors_p1; | ||
674 | *last_pg = cur_pg; | ||
675 | return ret; | ||
676 | } | ||
677 | |||
678 | static int _io_rw_pagelist(struct objio_state *ios, gfp_t gfp_flags) | ||
679 | { | ||
680 | u64 length = ios->count; | ||
681 | u64 offset = ios->offset; | ||
682 | struct _striping_info si; | ||
683 | unsigned last_pg = 0; | ||
684 | int ret = 0; | ||
685 | |||
686 | while (length) { | ||
687 | _calc_stripe_info(ios, offset, &si); | ||
688 | |||
689 | if (length < si.group_length) | ||
690 | si.group_length = length; | ||
691 | |||
692 | ret = _prepare_one_group(ios, si.group_length, &si, &last_pg, gfp_flags); | ||
693 | if (unlikely(ret)) | ||
694 | goto out; | ||
695 | |||
696 | offset += si.group_length; | ||
697 | length -= si.group_length; | ||
698 | } | ||
699 | |||
700 | out: | ||
701 | if (!ios->length) | ||
702 | return ret; | ||
703 | |||
704 | return 0; | ||
705 | } | ||
706 | |||
707 | static int _sync_done(struct objio_state *ios) | ||
708 | { | ||
709 | struct completion *waiting = ios->private; | ||
710 | |||
711 | complete(waiting); | ||
712 | return 0; | ||
713 | } | ||
714 | |||
715 | static void _last_io(struct kref *kref) | ||
716 | { | ||
717 | struct objio_state *ios = container_of(kref, struct objio_state, kref); | ||
718 | |||
719 | ios->done(ios); | ||
720 | } | ||
721 | |||
722 | static void _done_io(struct osd_request *or, void *p) | ||
723 | { | ||
724 | struct objio_state *ios = p; | ||
725 | |||
726 | kref_put(&ios->kref, _last_io); | ||
727 | } | ||
728 | |||
729 | static int _io_exec(struct objio_state *ios) | ||
730 | { | ||
731 | DECLARE_COMPLETION_ONSTACK(wait); | ||
732 | int ret = 0; | ||
733 | unsigned i; | ||
734 | objio_done_fn saved_done_fn = ios->done; | ||
735 | bool sync = ios->sync; | ||
736 | |||
737 | if (sync) { | ||
738 | ios->done = _sync_done; | ||
739 | ios->private = &wait; | ||
740 | } | ||
741 | |||
742 | kref_init(&ios->kref); | ||
743 | |||
744 | for (i = 0; i < ios->numdevs; i++) { | ||
745 | struct osd_request *or = ios->per_dev[i].or; | ||
746 | |||
747 | if (!or) | ||
748 | continue; | ||
749 | |||
750 | kref_get(&ios->kref); | ||
751 | osd_execute_request_async(or, _done_io, ios); | ||
752 | } | ||
753 | |||
754 | kref_put(&ios->kref, _last_io); | ||
755 | |||
756 | if (sync) { | ||
757 | wait_for_completion(&wait); | ||
758 | ret = saved_done_fn(ios); | ||
759 | } | ||
760 | |||
761 | return ret; | ||
762 | } | ||
763 | #endif | ||
764 | |||
765 | /* | 402 | /* |
766 | * read | 403 | * read |
767 | */ | 404 | */ |
@@ -781,63 +418,6 @@ static void _read_done(struct ore_io_state *ios, void *private) | |||
781 | objlayout_read_done(&objios->oir, status, objios->sync); | 418 | objlayout_read_done(&objios->oir, status, objios->sync); |
782 | } | 419 | } |
783 | 420 | ||
784 | #if 0 | ||
785 | static int _read_mirrors(struct objio_state *ios, unsigned cur_comp) | ||
786 | { | ||
787 | struct osd_request *or = NULL; | ||
788 | struct _objio_per_comp *per_dev = &ios->per_dev[cur_comp]; | ||
789 | unsigned dev = per_dev->dev; | ||
790 | struct ore_comp *cred = | ||
791 | &ios->oc->comps[cur_comp]; | ||
792 | struct osd_obj_id obj = cred->obj; | ||
793 | int ret; | ||
794 | |||
795 | or = osd_start_request(_io_od(ios, dev), GFP_KERNEL); | ||
796 | if (unlikely(!or)) { | ||
797 | ret = -ENOMEM; | ||
798 | goto err; | ||
799 | } | ||
800 | per_dev->or = or; | ||
801 | |||
802 | osd_req_read(or, &obj, per_dev->offset, per_dev->bio, per_dev->length); | ||
803 | |||
804 | ret = osd_finalize_request(or, 0, cred->cred, NULL); | ||
805 | if (ret) { | ||
806 | dprintk("%s: Faild to osd_finalize_request() => %d\n", | ||
807 | __func__, ret); | ||
808 | goto err; | ||
809 | } | ||
810 | |||
811 | dprintk("%s:[%d] dev=%d obj=0x%llx start=0x%llx length=0x%lx\n", | ||
812 | __func__, cur_comp, dev, obj.id, _LLU(per_dev->offset), | ||
813 | per_dev->length); | ||
814 | |||
815 | err: | ||
816 | return ret; | ||
817 | } | ||
818 | |||
819 | static int _read_exec(struct objio_state *ios) | ||
820 | { | ||
821 | unsigned i; | ||
822 | int ret; | ||
823 | |||
824 | for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) { | ||
825 | if (!ios->per_dev[i].length) | ||
826 | continue; | ||
827 | ret = _read_mirrors(ios, i); | ||
828 | if (unlikely(ret)) | ||
829 | goto err; | ||
830 | } | ||
831 | |||
832 | ios->done = _read_done; | ||
833 | return _io_exec(ios); | ||
834 | |||
835 | err: | ||
836 | _io_free(ios); | ||
837 | return ret; | ||
838 | } | ||
839 | #endif | ||
840 | |||
841 | int objio_read_pagelist(struct nfs_read_data *rdata) | 421 | int objio_read_pagelist(struct nfs_read_data *rdata) |
842 | { | 422 | { |
843 | struct objio_state *objios; | 423 | struct objio_state *objios; |
@@ -879,90 +459,6 @@ static void _write_done(struct ore_io_state *ios, void *private) | |||
879 | objlayout_write_done(&objios->oir, status, objios->sync); | 459 | objlayout_write_done(&objios->oir, status, objios->sync); |
880 | } | 460 | } |
881 | 461 | ||
882 | #if 0 | ||
883 | static int _write_mirrors(struct objio_state *ios, unsigned cur_comp) | ||
884 | { | ||
885 | struct _objio_per_comp *master_dev = &ios->per_dev[cur_comp]; | ||
886 | unsigned dev = ios->per_dev[cur_comp].dev; | ||
887 | unsigned last_comp = cur_comp + ios->layout->mirrors_p1; | ||
888 | int ret; | ||
889 | |||
890 | for (; cur_comp < last_comp; ++cur_comp, ++dev) { | ||
891 | struct osd_request *or = NULL; | ||
892 | struct ore_comp *cred = &ios->oc->comps[cur_comp]; | ||
893 | struct osd_obj_id obj = cred->obj; | ||
894 | struct _objio_per_comp *per_dev = &ios->per_dev[cur_comp]; | ||
895 | struct bio *bio; | ||
896 | |||
897 | or = osd_start_request(_io_od(ios, dev), GFP_NOFS); | ||
898 | if (unlikely(!or)) { | ||
899 | ret = -ENOMEM; | ||
900 | goto err; | ||
901 | } | ||
902 | per_dev->or = or; | ||
903 | |||
904 | if (per_dev != master_dev) { | ||
905 | bio = bio_kmalloc(GFP_NOFS, | ||
906 | master_dev->bio->bi_max_vecs); | ||
907 | if (unlikely(!bio)) { | ||
908 | dprintk("Faild to allocate BIO size=%u\n", | ||
909 | master_dev->bio->bi_max_vecs); | ||
910 | ret = -ENOMEM; | ||
911 | goto err; | ||
912 | } | ||
913 | |||
914 | __bio_clone(bio, master_dev->bio); | ||
915 | bio->bi_bdev = NULL; | ||
916 | bio->bi_next = NULL; | ||
917 | per_dev->bio = bio; | ||
918 | per_dev->dev = dev; | ||
919 | per_dev->length = master_dev->length; | ||
920 | per_dev->offset = master_dev->offset; | ||
921 | } else { | ||
922 | bio = master_dev->bio; | ||
923 | bio->bi_rw |= REQ_WRITE; | ||
924 | } | ||
925 | |||
926 | osd_req_write(or, &obj, per_dev->offset, bio, per_dev->length); | ||
927 | |||
928 | ret = osd_finalize_request(or, 0, cred->cred, NULL); | ||
929 | if (ret) { | ||
930 | dprintk("%s: Faild to osd_finalize_request() => %d\n", | ||
931 | __func__, ret); | ||
932 | goto err; | ||
933 | } | ||
934 | |||
935 | dprintk("%s:[%d] dev=%d obj=0x%llx start=0x%llx length=0x%lx\n", | ||
936 | __func__, cur_comp, dev, obj.id, _LLU(per_dev->offset), | ||
937 | per_dev->length); | ||
938 | } | ||
939 | |||
940 | err: | ||
941 | return ret; | ||
942 | } | ||
943 | |||
944 | static int _write_exec(struct objio_state *ios) | ||
945 | { | ||
946 | unsigned i; | ||
947 | int ret; | ||
948 | |||
949 | for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) { | ||
950 | if (!ios->per_dev[i].length) | ||
951 | continue; | ||
952 | ret = _write_mirrors(ios, i); | ||
953 | if (unlikely(ret)) | ||
954 | goto err; | ||
955 | } | ||
956 | |||
957 | ios->done = _write_done; | ||
958 | return _io_exec(ios); | ||
959 | |||
960 | err: | ||
961 | _io_free(ios); | ||
962 | return ret; | ||
963 | } | ||
964 | #endif | ||
965 | |||
966 | int objio_write_pagelist(struct nfs_write_data *wdata, int how) | 462 | int objio_write_pagelist(struct nfs_write_data *wdata, int how) |
967 | { | 463 | { |
968 | struct objio_state *objios; | 464 | struct objio_state *objios; |