summaryrefslogtreecommitdiffstats
path: root/src/tools/cephfs/DataScan.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/cephfs/DataScan.h')
-rw-r--r--src/tools/cephfs/DataScan.h70
1 files changed, 48 insertions, 22 deletions
diff --git a/src/tools/cephfs/DataScan.h b/src/tools/cephfs/DataScan.h
index 7cdc2d8a096..2404d665a2d 100644
--- a/src/tools/cephfs/DataScan.h
+++ b/src/tools/cephfs/DataScan.h
@@ -128,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, uint64_t nsubdirs,
+ 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
*/
@@ -146,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,
@@ -196,12 +220,12 @@ class MetadataDriver : public RecoveryDriver
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;
@@ -219,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
@@ -242,10 +272,6 @@ class DataScan : public MDSUtility
const std::vector<const char*> &arg,
std::vector<const char *>::const_iterator &i);
- void build_file_dentry(
- inodeno_t ino, uint64_t file_size, time_t file_mtime,
- const ceph_file_layout &layout,
- InodeStore *out);
public: