summaryrefslogtreecommitdiffstats
path: root/src/tools/cephfs/DataScan.h
diff options
context:
space:
mode:
authorYan, Zheng <ukernel@gmail.com>2015-12-03 15:10:26 +0100
committerYan, Zheng <ukernel@gmail.com>2015-12-03 15:10:26 +0100
commit72691dd9a0589dfd9f02225e76ce49538d677e7b (patch)
tree568676a61bde1954896d4bfd568a4406aac21c0d /src/tools/cephfs/DataScan.h
parentMerge pull request #6777 from dillaman/wip-librbd-lockdep (diff)
parenttools: fix cephfs-data-scan scan_frags vs. nlink (diff)
downloadceph-72691dd9a0589dfd9f02225e76ce49538d677e7b.tar.xz
ceph-72691dd9a0589dfd9f02225e76ce49538d677e7b.zip
Merge pull request #5941 from jcsp/wip-12137
#12137: cephfs-data-scan scan_frags
Diffstat (limited to 'src/tools/cephfs/DataScan.h')
-rw-r--r--src/tools/cephfs/DataScan.h92
1 files changed, 56 insertions, 36 deletions
diff --git a/src/tools/cephfs/DataScan.h b/src/tools/cephfs/DataScan.h
index 03a4b64943d..cc9e39e3774 100644
--- a/src/tools/cephfs/DataScan.h
+++ b/src/tools/cephfs/DataScan.h
@@ -47,9 +47,7 @@ class RecoveryDriver {
*/
virtual int inject_with_backtrace(
const inode_backtrace_t &bt,
- uint64_t size,
- time_t mtime,
- const ceph_file_layout &layout) = 0;
+ const InodeStore &dentry) = 0;
/**
* Inject an inode + dentry into the lost+found directory,
@@ -57,9 +55,7 @@ class RecoveryDriver {
*/
virtual int inject_lost_and_found(
inodeno_t ino,
- uint64_t size,
- time_t mtime,
- const ceph_file_layout &layout) = 0;
+ const InodeStore &dentry) = 0;
/**
* Create any missing roots (i.e. mydir, strays, root inode)
@@ -120,15 +116,11 @@ class LocalFileDriver : public RecoveryDriver
int inject_with_backtrace(
const inode_backtrace_t &bt,
- uint64_t size,
- time_t mtime,
- ceph_file_layout const &layout);
+ const InodeStore &dentry);
int inject_lost_and_found(
inodeno_t ino,
- uint64_t size,
- time_t mtime,
- ceph_file_layout const &layout);
+ const InodeStore &dentry);
int init_roots(int64_t data_pool_id);
@@ -136,14 +128,51 @@ class LocalFileDriver : public RecoveryDriver
};
/**
- * A class that knows how to manipulate CephFS metadata pools
+ * A class that knows how to work with objects in a CephFS
+ * metadata pool.
*/
-class MetadataDriver : public RecoveryDriver
+class MetadataTool
{
protected:
- librados::IoCtx metadata_io;
+ librados::IoCtx metadata_io;
+
+ /**
+ * Construct a synthetic InodeStore for a normal file
+ */
+ void build_file_dentry(
+ inodeno_t ino, uint64_t file_size, time_t file_mtime,
+ const ceph_file_layout &layout,
+ InodeStore *out);
+
+ /**
+ * Construct a synthetic InodeStore for a directory
+ */
+ void build_dir_dentry(
+ inodeno_t ino, uint64_t nfiles,
+ time_t mtime,
+ const ceph_file_layout &layout,
+ InodeStore *out);
+
+ /**
+ * Try and read an fnode from a dirfrag
+ */
+ int read_fnode(inodeno_t ino, frag_t frag,
+ fnode_t *fnode, uint64_t *read_version);
+
+ /**
+ * Try and read a dentry from a dirfrag
+ */
+ int read_dentry(inodeno_t parent_ino, frag_t frag,
+ const std::string &dname, InodeStore *inode);
+};
+/**
+ * A class that knows how to manipulate CephFS metadata pools
+ */
+class MetadataDriver : public RecoveryDriver, public MetadataTool
+{
+ protected:
/**
* Create a .inode object, i.e. root or mydir
*/
@@ -154,19 +183,6 @@ class MetadataDriver : public RecoveryDriver
* trying to go ahead and inject metadata.
*/
int root_exists(inodeno_t ino, bool *result);
-
- /**
- * Try and read an fnode from a dirfrag
- */
- int read_fnode(inodeno_t ino, frag_t frag,
- fnode_t *fnode, uint64_t *read_version);
-
- /**
- * Try and read a dentry from a dirfrag
- */
- int read_dentry(inodeno_t parent_ino, frag_t frag,
- const std::string &dname, InodeStore *inode);
-
int find_or_create_dirfrag(
inodeno_t ino,
frag_t fragment,
@@ -193,27 +209,23 @@ class MetadataDriver : public RecoveryDriver
int inject_with_backtrace(
const inode_backtrace_t &bt,
- uint64_t size,
- time_t mtime,
- ceph_file_layout const &layout);
+ const InodeStore &dentry);
int inject_lost_and_found(
inodeno_t ino,
- uint64_t size,
- time_t mtime,
- ceph_file_layout const &layout);
+ const InodeStore &dentry);
int init_roots(int64_t data_pool_id);
int check_roots(bool *result);
};
-class DataScan : public MDSUtility
+class DataScan : public MDSUtility, public MetadataTool
{
protected:
RecoveryDriver *driver;
- // IoCtx for data pool (where we scrape backtraces from)
+ // IoCtx for data pool (where we scrape file backtraces from)
librados::IoCtx data_io;
// Remember the data pool ID for use in layouts
int64_t data_pool_id;
@@ -231,6 +243,12 @@ class DataScan : public MDSUtility
*/
int scan_extents();
+ /**
+ * Scan metadata pool for 0th dirfrags to link orphaned
+ * directory inodes.
+ */
+ int scan_frags();
+
// Accept pools which are not in the MDSMap
bool force_pool;
// Respond to decode errors by overwriting
@@ -256,6 +274,8 @@ class DataScan : public MDSUtility
const std::vector<const char*> &arg,
std::vector<const char *>::const_iterator &i);
+
+
public:
void usage();
int main(const std::vector<const char *> &args);