~ubuntu-branches/ubuntu/wily/glusterfs/wily

« back to all changes in this revision

Viewing changes to xlators/cluster/afr/src/afr-dir-read.c

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2011-06-26 21:00:42 UTC
  • mfrom: (1.3.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20110626210042-ps1aim0cwz06tkx1
Tags: 3.2.1-1
* New upstream release.
  - Refresh patch 02-spelling-error.
* Wrap dependencies.
* Merge libglusterfs0 and libglusterfs-dev package to glusterfs-common.
  Closes: #630147
* Use python-module.mk and remove useless python bytecode files.
  Closes: #630146

Show diffs side-by-side

added added

removed removed

Lines of Context:
522
522
        xlator_t **      children    = NULL;
523
523
        ino_t            inum        = 0;
524
524
        int              call_child  = 0;
 
525
        int              first_call_child  = 0;
525
526
        int              ret         = 0;
526
527
        gf_dirent_t *    entry       = NULL;
527
528
        gf_dirent_t *    tmp         = NULL;
528
 
        int              child_index = -1;
529
529
        uint64_t         ctx         = 0;
530
530
        afr_fd_ctx_t    *fd_ctx      = NULL;
531
531
        off_t            offset      = 0;
535
535
 
536
536
        local = frame->local;
537
537
 
538
 
        child_index = (long) cookie;
 
538
        first_call_child = (long) cookie;
 
539
        if (local->cont.readdir.last_tried == -1) {
 
540
                call_child = (long) cookie;
 
541
        } else {
 
542
                call_child = local->cont.readdir.last_tried;
 
543
        }
539
544
 
540
545
        if (priv->strict_readdir) {
541
546
                ret = fd_ctx_get (local->fd, this, &ctx);
550
555
                fd_ctx = (afr_fd_ctx_t *)(long) ctx;
551
556
 
552
557
                if (child_went_down (op_ret, op_errno)) {
553
 
                        if (all_tried (child_index, priv->child_count)) {
 
558
                        if ((call_child + 1) % priv->child_count
 
559
                                       == first_call_child) {
554
560
                                gf_log (this->name, GF_LOG_INFO,
555
561
                                        "all options tried going out");
556
562
                                goto out;
557
563
                        }
558
564
 
559
 
                        call_child = ++child_index;
 
565
                        call_child = (call_child + 1) % priv->child_count;
 
566
                        local->cont.readdir.last_tried = call_child;
560
567
 
561
568
                        gf_log (this->name, GF_LOG_TRACE,
562
569
                                "starting readdir afresh on child %d, offset %"PRId64,
565
572
                        fd_ctx->failed_over = _gf_true;
566
573
 
567
574
                        STACK_WIND_COOKIE (frame, afr_readdirp_cbk,
568
 
                                           (void *) (long) call_child,
 
575
                                           (void *) (long) first_call_child,
569
576
                                           children[call_child],
570
577
                                           children[call_child]->fops->readdirp, local->fd,
571
578
                                           local->cont.readdir.size, 0);
576
583
        if (op_ret != -1) {
577
584
                list_for_each_entry_safe (entry, tmp, &entries->list, list) {
578
585
                        inum = afr_itransform (entry->d_ino, priv->child_count,
579
 
                                               child_index);
 
586
                                               call_child);
580
587
                        entry->d_ino = inum;
581
588
                        inum  = afr_itransform (entry->d_stat.ia_ino,
582
 
                                                priv->child_count, child_index);
 
589
                                                priv->child_count, call_child);
583
590
                        entry->d_stat.ia_ino = inum;
584
591
 
585
592
                        if ((local->fd->inode == local->fd->inode->table->root)
611
618
                                gf_log (this->name, GF_LOG_TRACE,
612
619
                                        "trying to fetch non-duplicate entries "
613
620
                                        "from offset %"PRId64", child %s",
614
 
                                        offset, children[child_index]->name);
 
621
                                        offset, children[call_child]->name);
615
622
 
616
623
                                STACK_WIND_COOKIE (frame, afr_readdirp_cbk,
617
 
                                                   (void *) (long) child_index,
618
 
                                                   children[child_index],
619
 
                                                   children[child_index]->fops->readdirp,
 
624
                                                   (void *) (long) first_call_child,
 
625
                                                   children[call_child],
 
626
                                                   children[call_child]->fops->readdirp,
620
627
                                                   local->fd, local->cont.readdir.size, offset);
621
628
                                return 0;
622
629
                        }
645
652
        int              ret        = -1;
646
653
        int32_t          op_ret     = -1;
647
654
        int32_t          op_errno   = 0;
 
655
        int32_t          read_child = -1;
648
656
 
649
657
        VALIDATE_OR_GOTO (frame, out);
650
658
        VALIDATE_OR_GOTO (this, out);
662
670
 
663
671
        frame->local = local;
664
672
 
665
 
        call_child = afr_first_up_child (priv);
666
 
        if (call_child == -1) {
667
 
                op_errno = ENOTCONN;
668
 
                gf_log (this->name, GF_LOG_INFO,
669
 
                        "no child is up");
670
 
                goto out;
 
673
        read_child = afr_read_child (this, fd->inode);
 
674
 
 
675
        if ((read_child >= 0) && (priv->child_up[read_child])) {
 
676
                call_child = read_child;
 
677
                local->cont.readdir.last_tried = -1;
 
678
        } else {
 
679
                call_child = afr_first_up_child (priv);
 
680
                if (call_child == -1) {
 
681
                        op_errno = ENOTCONN;
 
682
                        gf_log (this->name, GF_LOG_INFO,
 
683
                                "no child is up");
 
684
                        goto out;
 
685
                }
 
686
                local->cont.readdir.last_tried = call_child;
671
687
        }
672
688
 
673
689
        local->fd                  = fd_ref (fd);