~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to fs/ocfs2/cluster/heartbeat.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
367
367
static void o2hb_wait_on_io(struct o2hb_region *reg,
368
368
                            struct o2hb_bio_wait_ctxt *wc)
369
369
{
370
 
        struct address_space *mapping = reg->hr_bdev->bd_inode->i_mapping;
371
 
 
372
 
        blk_run_address_space(mapping);
373
370
        o2hb_bio_wait_dec(wc, 1);
374
 
 
375
371
        wait_for_completion(&wc->wc_io_complete);
376
372
}
377
373
 
543
539
 
544
540
/* We want to make sure that nobody is heartbeating on top of us --
545
541
 * this will help detect an invalid configuration. */
546
 
static int o2hb_check_last_timestamp(struct o2hb_region *reg)
 
542
static void o2hb_check_last_timestamp(struct o2hb_region *reg)
547
543
{
548
 
        int node_num, ret;
549
544
        struct o2hb_disk_slot *slot;
550
545
        struct o2hb_disk_heartbeat_block *hb_block;
551
 
 
552
 
        node_num = o2nm_this_node();
553
 
 
554
 
        ret = 1;
555
 
        slot = &reg->hr_slots[node_num];
 
546
        char *errstr;
 
547
 
 
548
        slot = &reg->hr_slots[o2nm_this_node()];
556
549
        /* Don't check on our 1st timestamp */
557
 
        if (slot->ds_last_time) {
558
 
                hb_block = slot->ds_raw_block;
559
 
 
560
 
                if (le64_to_cpu(hb_block->hb_seq) != slot->ds_last_time)
561
 
                        ret = 0;
562
 
        }
563
 
 
564
 
        return ret;
 
550
        if (!slot->ds_last_time)
 
551
                return;
 
552
 
 
553
        hb_block = slot->ds_raw_block;
 
554
        if (le64_to_cpu(hb_block->hb_seq) == slot->ds_last_time &&
 
555
            le64_to_cpu(hb_block->hb_generation) == slot->ds_last_generation &&
 
556
            hb_block->hb_node == slot->ds_node_num)
 
557
                return;
 
558
 
 
559
#define ERRSTR1         "Another node is heartbeating on device"
 
560
#define ERRSTR2         "Heartbeat generation mismatch on device"
 
561
#define ERRSTR3         "Heartbeat sequence mismatch on device"
 
562
 
 
563
        if (hb_block->hb_node != slot->ds_node_num)
 
564
                errstr = ERRSTR1;
 
565
        else if (le64_to_cpu(hb_block->hb_generation) !=
 
566
                 slot->ds_last_generation)
 
567
                errstr = ERRSTR2;
 
568
        else
 
569
                errstr = ERRSTR3;
 
570
 
 
571
        mlog(ML_ERROR, "%s (%s): expected(%u:0x%llx, 0x%llx), "
 
572
             "ondisk(%u:0x%llx, 0x%llx)\n", errstr, reg->hr_dev_name,
 
573
             slot->ds_node_num, (unsigned long long)slot->ds_last_generation,
 
574
             (unsigned long long)slot->ds_last_time, hb_block->hb_node,
 
575
             (unsigned long long)le64_to_cpu(hb_block->hb_generation),
 
576
             (unsigned long long)le64_to_cpu(hb_block->hb_seq));
565
577
}
566
578
 
567
579
static inline void o2hb_prepare_block(struct o2hb_region *reg,
987
999
        /* With an up to date view of the slots, we can check that no
988
1000
         * other node has been improperly configured to heartbeat in
989
1001
         * our slot. */
990
 
        if (!o2hb_check_last_timestamp(reg))
991
 
                mlog(ML_ERROR, "Device \"%s\": another node is heartbeating "
992
 
                     "in our slot!\n", reg->hr_dev_name);
 
1002
        o2hb_check_last_timestamp(reg);
993
1003
 
994
1004
        /* fill in the proper info for our next heartbeat */
995
1005
        o2hb_prepare_block(reg, reg->hr_generation);
1003
1013
        }
1004
1014
 
1005
1015
        i = -1;
1006
 
        while((i = find_next_bit(configured_nodes, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) {
1007
 
 
 
1016
        while((i = find_next_bit(configured_nodes,
 
1017
                                 O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) {
1008
1018
                change |= o2hb_check_slot(reg, &reg->hr_slots[i]);
1009
1019
        }
1010
1020
 
1658
1668
        struct o2hb_disk_slot *slot;
1659
1669
        struct o2hb_disk_heartbeat_block *hb_block;
1660
1670
 
1661
 
        mlog_entry_void();
1662
 
 
1663
1671
        ret = o2hb_read_slots(reg, reg->hr_blocks);
1664
1672
        if (ret) {
1665
1673
                mlog_errno(ret);
1681
1689
        }
1682
1690
 
1683
1691
out:
1684
 
        mlog_exit(ret);
1685
1692
        return ret;
1686
1693
}
1687
1694
 
1697
1704
        struct file *filp = NULL;
1698
1705
        struct inode *inode = NULL;
1699
1706
        ssize_t ret = -EINVAL;
 
1707
        int live_threshold;
1700
1708
 
1701
1709
        if (reg->hr_bdev)
1702
1710
                goto out;
1773
1781
         * A node is considered live after it has beat LIVE_THRESHOLD
1774
1782
         * times.  We're not steady until we've given them a chance
1775
1783
         * _after_ our first read.
 
1784
         * The default threshold is bare minimum so as to limit the delay
 
1785
         * during mounts. For global heartbeat, the threshold doubled for the
 
1786
         * first region.
1776
1787
         */
1777
 
        atomic_set(&reg->hr_steady_iterations, O2HB_LIVE_THRESHOLD + 1);
 
1788
        live_threshold = O2HB_LIVE_THRESHOLD;
 
1789
        if (o2hb_global_heartbeat_active()) {
 
1790
                spin_lock(&o2hb_live_lock);
 
1791
                if (o2hb_pop_count(&o2hb_region_bitmap, O2NM_MAX_REGIONS) == 1)
 
1792
                        live_threshold <<= 1;
 
1793
                spin_unlock(&o2hb_live_lock);
 
1794
        }
 
1795
        atomic_set(&reg->hr_steady_iterations, live_threshold + 1);
1778
1796
 
1779
1797
        hb_task = kthread_run(o2hb_thread, reg, "o2hb-%s",
1780
1798
                              reg->hr_item.ci_name);
2282
2300
        kfree(hs);
2283
2301
}
2284
2302
 
2285
 
/* hb callback registration and issueing */
 
2303
/* hb callback registration and issuing */
2286
2304
 
2287
2305
static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type)
2288
2306
{