Skip to content

Commit

Permalink
Merge pull request #5662 from ceph/wip-scrub-basic
Browse files Browse the repository at this point in the history
ScrubStack and "tag path" command

Reviewed-by: John Spray <john.spray@redhat.com>
Reviewed-by: Yan, Zheng <zyan@redhat.com>
  • Loading branch information
jcsp committed Nov 18, 2015
2 parents 46249fe + b65ace2 commit 5a2d24b
Show file tree
Hide file tree
Showing 22 changed files with 1,647 additions and 62 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ if(${WITH_MDS})
mds/JournalPointer.cc
mds/MDSTableClient.cc
mds/MDSTableServer.cc
mds/ScrubStack.cc
mds/SimpleLock.cc
mds/SnapRealm.cc
mds/SnapServer.cc
Expand Down
2 changes: 2 additions & 0 deletions src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ OPTION(mds_max_purge_ops_per_pg, OPT_FLOAT, 0.5)
OPTION(mds_root_ino_uid, OPT_INT, 0) // The UID of / on new filesystems
OPTION(mds_root_ino_gid, OPT_INT, 0) // The GID of / on new filesystems

OPTION(mds_max_scrub_ops_in_progress, OPT_INT, 5) // the number of simultaneous scrubs allowed

// If true, compact leveldb store on mount
OPTION(osd_compact_leveldb_on_mount, OPT_BOOL, false)

Expand Down
3 changes: 2 additions & 1 deletion src/include/ceph_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ enum {
CEPH_MDS_OP_FRAGMENTDIR= 0x01500,
CEPH_MDS_OP_EXPORTDIR = 0x01501,
CEPH_MDS_OP_VALIDATE = 0x01502,
CEPH_MDS_OP_FLUSH = 0x01503
CEPH_MDS_OP_FLUSH = 0x01503,
CEPH_MDS_OP_ENQUEUE_SCRUB = 0x01504
};

extern const char *ceph_mds_op_name(int op);
Expand Down
53 changes: 53 additions & 0 deletions src/mds/CDentry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,3 +622,56 @@ std::string CDentry::linkage_t::get_remote_d_type_string() const
}
}

void CDentry::scrub_initialize(CDir *parent, bool recurse, bool children,
ScrubHeaderRefConst header,
Context *f)
{
if (!scrub_infop)
scrub_info_create();
else
assert(!scrub_infop->dentry_scrubbing);

scrub_infop->scrub_parent = parent;
scrub_infop->scrub_recursive = recurse;
scrub_infop->scrub_children = children;
scrub_infop->dentry_scrubbing = true;
scrub_infop->on_finish = f;
scrub_infop->header = header;

auth_pin(this);
}

void CDentry::scrub_finished(Context **c)
{
dout(10) << __func__ << dendl;
assert(scrub_info()->dentry_scrubbing);

if (scrub_infop->scrub_parent) {
scrub_infop->scrub_parent->scrub_dentry_finished(this);
}

*c = scrub_infop->on_finish;

if (scrub_infop->header && scrub_infop->header->origin == this) {
// We are at the point that a tagging scrub was initiated
LogChannelRef clog = dir->cache->mds->clog;
clog->info() << "scrub complete with tag '"
<< scrub_infop->header->tag << "'";
}

delete scrub_infop;
scrub_infop = NULL;

auth_unpin(this);
}

void CDentry::scrub_info_create() const
{
assert(!scrub_infop);

// break out of const-land to set up implicit initial state
CDentry *me = const_cast<CDentry*>(this);

// we don't need to change or set up any default parameters; assign directly
me->scrub_infop = new scrub_info_t();
}
51 changes: 51 additions & 0 deletions src/mds/CDentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "SimpleLock.h"
#include "LocalLock.h"
#include "ScrubHeader.h"

class CInode;
class CDir;
Expand Down Expand Up @@ -80,11 +81,14 @@ class CDentry : public MDSCacheObject, public LRUObject {
static const int PIN_INODEPIN = 1; // linked inode is pinned
static const int PIN_FRAGMENTING = -2; // containing dir is refragmenting
static const int PIN_PURGING = 3;
static const int PIN_SCRUBQUEUE = 4; // TODO: negative value?

const char *pin_name(int p) const {
switch (p) {
case PIN_INODEPIN: return "inodepin";
case PIN_FRAGMENTING: return "fragmenting";
case PIN_PURGING: return "purging";
case PIN_SCRUBQUEUE: return "scrub_enqueued";
default: return generic_pin_name(p);
}
}
Expand Down Expand Up @@ -137,17 +141,60 @@ class CDentry : public MDSCacheObject, public LRUObject {
void link_remote(CInode *in);
};

class scrub_info_t {
public:
CDir *scrub_parent; /// This either matches get_parent_dir() or NULL
bool scrub_recursive; /// true if we are scrubbing everything under this
bool scrub_children; /// true if we have to scrub all direct children
bool dentry_scrubbing; /// safety check
bool dentry_children_done; /// safety check
bool inode_validated; /// Has our inode's validate_disk_state run?
Context *on_finish; /// called when we finish scrubbing
ScrubHeaderRefConst header;

scrub_info_t() :
scrub_parent(NULL), scrub_recursive(false),
scrub_children(false), dentry_scrubbing(false),
dentry_children_done(false), inode_validated(false),
on_finish(NULL)
{}
};

protected:
CDir *dir; // containing dirfrag
linkage_t linkage;
list<linkage_t> projected;

version_t version; // dir version when last touched.
version_t projected_version; // what it will be when i unlock/commit.
scrub_info_t* scrub_infop;

public:
elist<CDentry*>::item item_dirty;
elist<CDentry*>::item item_stray;
elist<CDentry*>::item item_scrub;

const scrub_info_t *scrub_info() const {
if(!scrub_infop)
scrub_info_create();
return scrub_infop;
}
void scrub_initialize(CDir *parent, bool recurse, bool children,
ScrubHeaderRefConst header,
Context *f);
void scrub_finished(Context **c);
void scrub_children_finished() {
scrub_infop->dentry_children_done = true;
}
void scrub_set_finisher(Context *c) {
scrub_infop->on_finish = c;
}

private:
/**
* Create a scrub_info_t struct for the scrub_infop pointer.
*/
void scrub_info_create() const;

protected:
friend class Migrator;
Expand All @@ -174,6 +221,7 @@ class CDentry : public MDSCacheObject, public LRUObject {
first(f), last(l),
dir(0),
version(0), projected_version(0),
scrub_infop(NULL),
item_dirty(this),
lock(this, &lock_type),
versionlock(this, &versionlock_type) {
Expand All @@ -186,6 +234,7 @@ class CDentry : public MDSCacheObject, public LRUObject {
first(f), last(l),
dir(0),
version(0), projected_version(0),
scrub_infop(NULL),
item_dirty(this),
lock(this, &lock_type),
versionlock(this, &versionlock_type) {
Expand All @@ -195,6 +244,8 @@ class CDentry : public MDSCacheObject, public LRUObject {
linkage.remote_d_type = dt;
}
~CDentry() {
assert(!scrub_infop);
assert(!item_scrub.is_on_list());
g_num_dn--;
g_num_dns++;
}
Expand Down

0 comments on commit 5a2d24b

Please sign in to comment.