mds: preserve subtree bounds until slave commit

When replaying an operation that rename a directory inode to non-auth subtree,
if the inode has subtree bounds, we should prevent them from being trimmed
until slave commit.

This patch also fixes a bug in ESlaveUpdate::replay(). EMetaBlob::replay()
should be called before MDCache::finish_uncommitted_slave_update().

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
mds: process finished contexts in batch

If there are several unstable locks in an inode, current Locker::eval(CInode*,)
processes each lock's finished contexts seperately. This may cause very deep
call stack if finished contexts also call Locker::eval() on the same inode.
An extreme example is:

Locker::eval() wakes an open request(). Server::handle_client_open() starts
a log entry, then call Locker::issue_new_caps(). Locker::issue_new_caps()
calls Locker::eval() and wakes another request. The later request also tries
starting a log entry.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
mds: fix MDCache::adjust_bounded_subtree_auth()

There are cases that need both create new bound and swallow intervening
subtree. For example: A MDS exports subtree A with bound B and imports
subtree B with bound C at the same time. The MDS crashes, exporting
subtree A fails, but importing subtree B succeed. During recovery, the
MDS may create new bound C and swallow subtree B.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
mds: mark connection down when MDS fails

So if the MDS restarts and uses the same address, it does not get
old messages.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
client: fix use-after-free on session close and cond signals

Move the signal into the closed method, before we deallocate the
MetaSession, so that other callers catch it too.

Signed-off-by: Sage Weil <sage@inktank.com>
client: do sync read when 'client oc = false'

Signed-off-by: Sage Weil <sage@inktank.com>
strings: add 'list-watchers' to MOSDOp strings

Signed-off-by: Sage Weil <sage@inktank.com>
osd: make LIST_WATCHERS and LIST_SNAPS print nicely for OSDOp

Signed-off-by: Sage Weil <sage@inktank.com>
osd: include SnapSet seq in the list snaps response

It is important to know the latest seq that the object has seen in order
to tell if a response like

 clone 2 snaps=[1,2]
 clone head snaps=[]

was untouched before a hypothetical snap 3, or deleted prior to snap 3,
and then recreated+modified after.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: clean up some whitespace

Signed-off-by: Sage Weil <sage@inktank.com>
osd: do not include snaps with head on list_snaps()

If there is a sequence of snaps 1, 2, 3, 4, 5, and we have a clone
2 with [1,2], and the head reflects content at snap times [3,4,5], then
the snap_list should return

 clone 2 snaps [1,2]
 head snaps
 seq 2

because it never saw a write after snap 2, and therefor has the same
content currently as it did in snaps 3,4,5.  If the SnapSet on the
object lists snaps 3,4,5, and the head exists, it actually means the
object was deleted between 2 and 3, and was recreated after 5:

 clone 2 snaps [1,2]
 head snaps []
 seq 5

The key to telling the two situations apart is the seq number on the
SnapSet (now included in the list_snaps reply) that tells us when the
last update was.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: direct reads on SNAPDIR to either head or snapdir

The list_snaps operation needs to look at the SnapSet, and is logically
querying all revisions of the object.  Make requests to SNAPDIR be
read-only, and grab the head or snapdir obc transparently (whichever one
exists).  This allows us to list snaps when, say, the head does not
exist, but there are in fact snaps.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: wait for all clones on SNAPDIR requests

Wait for all clones to be present.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: fix clone snap list for list-snaps

We need to return the list of snaps that each clone is defined for, not
the list of snaps we know may or may not exist globally over a similar
interval.  This requires looking at the clone's obc, unfortunately.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: fix error codes for list-snaps

Signed-off-by: Sage Weil <sage@inktank.com>
osdc/Objecter: prval optional for listsnaps

Signed-off-by: Sage Weil <sage@inktank.com>
librados: expose snapset seq via list_snaps

Signed-off-by: Sage Weil <sage@inktank.com>
librbd: implement diff_iterate

Implement a diff_iterate() method that will iterate over an image and
report which extents vary between two snapshots (or a snapshot and the
head).  The callback gets an extent and a flag indicating whether it is
full of data or is known to be zero in the ending snapshot.

Signed-off-by: Sage Weil <sage@inktank.com>
rbd: add --io-pattern <seq|rand> option to bench-write

Write to random offsets instead of sequentially.

Signed-off-by: Sage Weil <sage@inktank.com>
rbd: implement 'export-diff' and 'import-diff' commands

Export a diff of an image from a previous snapshot to a file (or stdout).

Import a diff and apply it to an image, and then create the ending
snapshot.

Signed-off-by: Sage Weil <sage@inktank.com>