On 2007-06-01T17:22:24, Xinwei Hu <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
>   I'm trying to write a disk based HBcomm plug-in for heartbeat. 
> 
>   My current implementation is:
>      write:
>            write to it's own slot
>            sleep 0.2s

Random comments, which I've not sorted:

Implement a circular buffer (one per node) for writes, with an
additional meta data section (one slot per node).

You can atomically update the pointer as to where the buffer currently
begins and ends - sector-sized writes (512b, on SAN arrays it's often
higher) are atomic. The slots should contain at least the uname, UUID,
liveness counter, deadtime, keepalive interval, cluster name.

A static sized buffer of a few MB per node shouldn't be too hard to
implement. Adding slots at the end shouldn't either. Resizing the
buffers dynamically is going to be hard and might not be needed.

Possible optimization: Filter out pure heartbeat packets - write the
liveness information into a counter in the slot instead, the reading
nodes can then infer the heartbeats by seeing it increase. (This is
advanced, but may be a very good idea to be able to do in the MCP anyway
- otherwise, the disk heads will be constantly moving very fast.)

>      read:
>            scan all slots for new pkt
>            if (found) {
>               do {
>                 read the slot for new pkt
>               } while (checksum of pkt is wrong)
>            } else {
>              sleep 0.1s
>            }

Write at least the current heartbeat interval of each node into its slot
- poll the slot at at least twice that frequency. 0.1s or so should be
the upper bound.

Use O_DIRECT for both reading and writing.

>  * The SHA implementation is from mozilla.
>  * TODO: reuse the code from HBauth

Why do you need SHA inside the plugin!? The packets you receive are
already authenticated and signed.

You don't need to authenticate the slot itself, I'd argue. 512b writes
are atomic - you're not going to see a half-way written one.


Regards,
    Lars

-- 
Teamlead Kernel, SuSE Labs, Research and Development
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
"Experience is the name everyone gives to their mistakes." -- Oscar Wilde

_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to