mds: add an MDSInternalContextWrapper

This lets us wrap generic function tooling up inside of the appropriate
type-checking, and verify we haven't done anything too stupid.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDS: CInode: add a fetch_backtrace() utility function

Expose MDCache::fetch_backtrace and call it from the CInode context.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDS: add operator==() and compare() for inode_backtrace_t

The compare() function checks one backtrace against another and indicates
if they're equivalent (or divergent!) and the relative freshness.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDCache: remove #if 0'd code

Signed-off-by: Greg Farnum <greg@inktank.com>
MDS: MDRequestImpl: provide filepath/filepath2 substitute for MClientRequest

Use this passthru in the Server path locking functions so that we can get
locks or auth pins without an associated MClientRequest.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDS: CInode: create a flush() function

Signed-off-by: Greg Farnum <greg@inktank.com>
Continuation: Add a new Continuation class.

TODO: documentation on how to actually use it. Add it to the Makefile.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDS: CInode::validate_disk_state()

Add a function that will validate the on-disk state of the CInode. We currently
check that the on-disk backtrace matches (or is older) and compare rstats on
dirfrags against the parent dir's inode (for directories only).

TODO: We still don't validate the actual on-disk Inode
object against what we already had in memory, though.
TODO: validate that the on-disk Inode object matches what the parent
directory holds.

It's using a sort-of new programming model, trying to stuff stack data into
a Continuation object and write everything sequentially instead of having
a function and Context per IO.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDS: CInode: implement dump_validation_results()

Signed-off-by: Greg Farnum <greg@inktank.com>
MDCache: add a scrub_dentry() function, and wire it up to the admin socket

scrub_dentry() is passed a string path, and it validates it before replying. We
hook up an admin socket command "scrub_path" to call it and dump the output.

Signed-off-by: Greg Farnum <greg@inktank.com>
Server: remove tracei and tracedn parameters from reply_request

We have members for these two parameters in the MDRequestImpl already, so
make use of them. This helps us move towards dropping the expectation of an
MClientRequest from functions like rdlock_path_pin_ref().

Signed-off-by: Greg Farnum <greg@inktank.com>
Server: do not use explicit MClientReply if we don't need to

Signed-off-by: Greg Farnum <greg@inktank.com>
Server: use mdr->reply_extra_bl instead of explicit MClientReply

Set the MClientReply::extra_bl from reply_extra_bl unconditionally in
reply_request(), instead of only in early_reply(). Further isolate
the reply_request() callers from the use of MClientReply this way.

TODO: make sure the set_extra_bl stuff is actually safe

Signed-off-by: Greg Farnum <greg@inktank.com>
Server: add snapbl to MDRequest and eliminate last explicit MClientReply

Signed-off-by: Greg Farnum <greg@inktank.com>
Server: rename reply_request -> reply_client_request; make it private

The generic reply_request(MDRequest, int) is now the only caller. It's still
just building an MClientRequest to pass along, but we can change it a lot more
easily now to support responding to non-client requests.

Signed-off-by: Greg Farnum <greg@inktank.com>
Server: rename reply_request() -> respond_to_request()

This is no longer necessarily a reply; it could turn into a Context
activation or something.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDCache: "handle" request_forward on internal ops

For now, just assert out because we can't deal with any of them. But push
the issue down to this level instead of worrying about it in path_traverse,
and consider the possibility that the MDRequest might not have a client_request
that it's wrapped around.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDCache: make scrub_dentry schedulable and reentrant

Rather than assuming that any necessary inodes are in the cache, split up
MDCache::scrub_dentry into setup and work phases. Add an internal_op_finisher()
to MDRequest. Dispatch any CEPH_MDS_OP_VALIDATE internal operations to
scrub_dentry_work(). Taken together, these make everything work properly when
path_traverse() (by way of rdlock_path_pin_ref()) needs to go to disk before
satisfying the lookup.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDCache: handle internal ops in respond_to_request()

This only works for those which have specified a finisher in the MDR.

Signed-off-by: Greg Farnum <greg@inktank.com>
MDS: add a flush_dentry() function, and wire it up to the admin socket

Signed-off-by: Greg Farnum <greg@inktank.com>