reset: Add the clear command to the usage

The command was documented in the examples but not in the usage line.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
reset: Improve error message when command is missing

If some options were specified without any positional arguments, this
confusing error message was displayed:

    $ sanlk-reset -i 42
    lockspace_name is required

Now more correct message is displayed:

    command is required

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
reset: Calling with too many lockspaces is a usage error

Previously we complained about ignoring lockspaces, but continue the
operation as usaual, so another program running the sanlk-reset tool
cannot detect the usage error.

Now this will fail with exit code 2 and this message:

    too many lockspaces (max 64)

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
reset: Normalize exit codes

Previously some usage error were treated as failures, and some failures
caused the program to exit with strange exit codes (e.g. 255).  This
patch normalizes the exit code to make sanlk-reset easier to consume by
other programs.

Exit codes:

  0  program succeeded
  1  program failed
  2  program used incorrectly

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
sanlock: print better names in direct read -s

sanlock direct read -s LOCKSPACE
was printing "write_id, write_generation, write_timestamp"
field names which are relevant only for paxos leases.
Print "extra1, extra2, extra3" as the field names when
reading a lockspace.

Signed-off-by: David Teigland <teigland@redhat.com>
sanlock: log bad delta leases and delta lease owners

Other delta leases in a lockspace are monitored for liveness,
which includes checking and saving the delta lease timestamp.
This adds a check of the delta lease's magic number and
lockspace name, and logs an error if they are not correct.
This will help debugging if a delta lease is corrupted.

This also adds an entry to sanlock.log that shows the owner
information for each delta lease.  This is logged whenever
the sanlock daemon encounters new owner information for a
host in a lockspace.

Signed-off-by: David Teigland <teigland@redhat.com>
sanlock: direct write_leader

Add a command to write a leader record directly to disk.
This is useful for testing, and to fix corrupted leases.

Signed-off-by: David Teigland <teigland@redhat.com>
release 3.2.1

Signed-off-by: David Teigland <teigland@redhat.com>