mds: Return EINVAL for parent lookup on root ino

This was the behaviour before 8d6b25a1, and distinguishes
the general failure to find a parent (ESTALE) from the specific
case of a node being present but being the base (EINVAL)

Signed-off-by: John Spray <john.spray@inktank.com>
client: Add lookup_parent & lookup_name

Exposing the CEPH_MDS_OP_LOOKUPPARENT and
recently added CEPH_MDS_OP_LOOKUPNAME operations.

lookup_ino and lookup_parent optionally take an Inode**
which will be populated with a reference to the
resulting inode.

Fixes: #3863

Signed-off-by: John Spray <john.spray@inktank.com>
libcephfs: add ceph_ll_lookup_inode

This is a wrapper to lookup_ino, lookup_parent
and lookup_name, to provide the
caller with the requested inode and its
dentry.  The result is suitable for traversing
the inode's path.

Fixes: #3863

Signed-off-by: John Spray <john.spray@inktank.com>
tools: Create ceph-client-debug

For exposing test/dev functionality which uses
the cephfs client interface.

Initially just provides lookup-by-ino.

Fixes: #3863

Signed-off-by: John Spray <john.spray@inktank.com>
ReplicatedPG: disallow trans which atomically create and remove an object

There are a few problems with such a transaction:
1) We don't really have a way to represent it in the log
2) How does it affect snaps?
3) In finish_ctx, it means we cannot assume that if we are saving snaps
on a snapdir we must be creating the snapdir.

For now, we'll just disallow such a transaction.

Signed-off-by: Samuel Just <sam.just@inktank.com>
ReplicatedPG: if !obc->obs->exists, lock snapdir obc if exists

Otherwise, backfill might slip in during a copyfrom.

Fixes: #7728
Signed-off-by: Samuel Just <sam.just@inktank.com>
common/PrioritizedQueue: fix remove_by_class() corner case

If i is the first entry, then setting cur = begin() sets us up to point at
something that we are about to delete.  Move the check to the end to avoid
this.

Backport: emperor, dumpling
Signed-off-by: Sage Weil <sage@inktank.com>
common/PrioritizedQueue: constify a few things

Signed-off-by: Sage Weil <sage@inktank.com>
common/PrioritizedQueue: include first item's cost in dump

Signed-off-by: Sage Weil <sage@inktank.com>
osd: fix OpWQ dump locking

The pqueue is protected by the wq lock, not by qlock; for example, see
OpWQ::_enqueue.  qlock protects the pg_for_processing map only.

Fixes: #7735
Signed-off-by: Sage Weil <sage@inktank.com>
osd: dump priority queue state on dequeue at level 30

Signed-off-by: Sage Weil <sage@inktank.com>
mds: treat flushing as dirty when rejoining scattered locks

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: rollback slave request after slave prepare is journalled

Resolve ack message can abort slave requests that are being journalled.
The slave rollback does not handle this case properly. The fix is mark
slave request aborted in this case. The slave rollback code is executed
after slave prepare is safely journalled.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: fix stack overflow caused by nested dispatch

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: drop auth pins before waiting for dir unfreeze

Otherwise deadlock can happen

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: avoid issuing zero caps to client

make sure CEPH_CAP_PIN exists in stale caps.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: properly initialize MDCache::fragment_info_t

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: fix open remote dirfrag deadlock

During subtree migration, the importer may need to open subtree
bound dirfrags. Opening subtree bound dirfrags happens after the
exporter freeze the exporting subtee. So the discover message for
opening subtree bound dirfrags should not wait for any freezing
tree/directory, otherwise deadlock can happen.

In MDCache::handle_discover(), there are two cases can cause
discover messages wait for freezing tree/directory. One case is
fetching bare-bone dirfrags. Another case is, when merging dirfrags,
some of the dirfrags are frozen, some are freezing.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: re-issue caps after importing caps (rename)

After importing inode, the issued caps can be less than the caps
client wants. So re-issue caps after importing inode.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: export file locks together with inode

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>