OCFS2 Volume Detect
mounted.ocfs2 is used to detect OCFS2 volume(s) on a system. This tools collect the information and show the OCFS2 volume is active or not.
But the information is gathered using dirty-read by reading //slot_map on each OCFS2 volume, the information may be stale. And this tools may report inconsonant/mistaken results, when the OCFS2 volume is off-line, and the last node did not umount this volume cleanly.
To fix this problem, the mounted.ocfs2 should check file //heartbeat before read file //slot_map, to determine whether the //slot_map is valid or not.
Add detect code that reads the content of file //heartbeat before reads //slot_map, waits 10 secs, reads it again. Then compare the two readings.
- The content of the two readings are same
- No heartbeat write to the disk. Non of the nodes in cluster are live. This OCFS2 volume is not active.
- The content of the two readings are different
- At least one node in the cluster is live. Contiune reading //slot_map, and resolve it.
The heartbeat file is maintained by the heartbeat kernel thread, [kthread]. And it is update timely.
Find the block number of //heartbeat by ocfs2_lookup() and read the whole file by ocfs2_read_whole_file()