From: John Spray Date: Mon, 3 Aug 2015 12:57:33 +0000 (+0100) Subject: tools/cephfs: pass layouts around in DataScan X-Git-Tag: v9.1.0~341^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bde85b7190ca76293c0715a61c4be5c68311e9ce;p=ceph.git tools/cephfs: pass layouts around in DataScan ...instead of chunk_size+data_pool arguments. This is a precursor to using the 0th-object xattr stashed layouts during recovery. Signed-off-by: John Spray --- diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index c6fc64dfbcc98..8269c0880036a 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -521,6 +521,12 @@ int DataScan::scan_inodes() file_size = accum_res.ceiling_obj_size; } + ceph_file_layout guessed_layout; + guessed_layout = g_default_file_layout; + guessed_layout.fl_object_size = chunk_size; + guessed_layout.fl_stripe_unit = chunk_size; + guessed_layout.fl_pg_pool = data_pool_id; + // Santity checking backtrace ino against object name if (have_backtrace && backtrace.ino != obj_name_ino) { dout(4) << "Backtrace ino 0x" << std::hex << backtrace.ino @@ -537,7 +543,7 @@ int DataScan::scan_inodes() * don't put it in the stray dir, because while that would technically * give it linkage it would still be invisible to the user */ r = driver->inject_lost_and_found( - obj_name_ino, file_size, file_mtime, chunk_size, data_pool_id); + obj_name_ino, file_size, file_mtime, guessed_layout); if (r < 0) { dout(4) << "Error injecting 0x" << std::hex << backtrace.ino << std::dec << " into lost+found: " << cpp_strerror(r) << dendl; @@ -549,7 +555,7 @@ int DataScan::scan_inodes() } else { /* Happy case: we will inject a named dentry for this inode */ r = driver->inject_with_backtrace( - backtrace, file_size, file_mtime, chunk_size, data_pool_id); + backtrace, file_size, file_mtime, guessed_layout); if (r < 0) { dout(4) << "Error injecting 0x" << std::hex << backtrace.ino << std::dec << " with backtrace: " << cpp_strerror(r) << dendl; @@ -562,7 +568,7 @@ int DataScan::scan_inodes() } else { /* Backtrace-less case: we will inject a lost+found dentry */ r = driver->inject_lost_and_found( - obj_name_ino, file_size, file_mtime, chunk_size, data_pool_id); + obj_name_ino, file_size, file_mtime, guessed_layout); if (r < 0) { dout(4) << "Error injecting 0x" << std::hex << obj_name_ino << std::dec << " into lost+found: " << cpp_strerror(r) << dendl; @@ -653,7 +659,7 @@ int MetadataDriver::read_dentry(inodeno_t parent_ino, frag_t frag, } int MetadataDriver::inject_lost_and_found(inodeno_t ino, uint64_t file_size, - time_t file_mtime, uint32_t chunk_size, int64_t data_pool_id) + time_t file_mtime, const ceph_file_layout &layout) { // Create lost+found if doesn't exist bool created = false; @@ -706,10 +712,7 @@ int MetadataDriver::inject_lost_and_found(inodeno_t ino, uint64_t file_size, recovered_ino.inode.atime.tv.tv_sec = file_mtime; recovered_ino.inode.ctime.tv.tv_sec = file_mtime; - recovered_ino.inode.layout = g_default_file_layout; - recovered_ino.inode.layout.fl_object_size = chunk_size; - recovered_ino.inode.layout.fl_stripe_unit = chunk_size; - recovered_ino.inode.layout.fl_pg_pool = data_pool_id; + recovered_ino.inode.layout = layout; recovered_ino.inode.truncate_seq = 1; recovered_ino.inode.truncate_size = -1ull; @@ -839,7 +842,7 @@ int MetadataDriver::get_frag_of( int MetadataDriver::inject_with_backtrace( const inode_backtrace_t &backtrace, uint64_t file_size, time_t file_mtime, - uint32_t chunk_size, int64_t data_pool_id) + const ceph_file_layout &layout) { @@ -949,7 +952,7 @@ int MetadataDriver::inject_with_backtrace( << std::hex << existing_dentry.inode.ino << std::dec << dendl; // Fall back to lost+found! return inject_lost_and_found(backtrace.ino, file_size, file_mtime, - chunk_size, data_pool_id); + layout); } } @@ -971,10 +974,7 @@ int MetadataDriver::inject_with_backtrace( dentry.inode.atime.tv.tv_sec = file_mtime; dentry.inode.ctime.tv.tv_sec = file_mtime; - dentry.inode.layout = g_default_file_layout; - dentry.inode.layout.fl_object_size = chunk_size; - dentry.inode.layout.fl_stripe_unit = chunk_size; - dentry.inode.layout.fl_pg_pool = data_pool_id; + dentry.inode.layout = layout; dentry.inode.truncate_seq = 1; dentry.inode.truncate_size = -1ull; @@ -1198,8 +1198,7 @@ int LocalFileDriver::inject_with_backtrace( const inode_backtrace_t &bt, uint64_t size, time_t mtime, - uint32_t chunk_size, - int64_t data_pool_id) + const ceph_file_layout &layout) { std::string path_builder = path; @@ -1215,7 +1214,9 @@ int LocalFileDriver::inject_with_backtrace( // Last entry is the filename itself bool is_file = (i + 1 == bt.ancestors.rend()); if (is_file) { - inject_data(path_builder, size, chunk_size, bt.ino); + // FIXME: inject_data won't cope with interesting (i.e. striped) + // layouts (need a librados-compatible Filer to read these) + inject_data(path_builder, size, layout.fl_object_size, bt.ino); } else { int r = mkdir(path_builder.c_str(), 0755); if (r != 0 && r != -EPERM) { @@ -1233,8 +1234,7 @@ int LocalFileDriver::inject_lost_and_found( inodeno_t ino, uint64_t size, time_t mtime, - uint32_t chunk_size, - int64_t data_pool_id) + const ceph_file_layout &layout) { std::string lf_path = path + "/lost+found"; int r = mkdir(lf_path.c_str(), 0755); @@ -1245,7 +1245,7 @@ int LocalFileDriver::inject_lost_and_found( } std::string file_path = lf_path + "/" + lost_found_dname(ino); - return inject_data(file_path, size, chunk_size, ino); + return inject_data(file_path, size, layout.fl_object_size, ino); } int LocalFileDriver::init_roots(int64_t data_pool_id) diff --git a/src/tools/cephfs/DataScan.h b/src/tools/cephfs/DataScan.h index 054ce81edce66..252e6e3284e0c 100644 --- a/src/tools/cephfs/DataScan.h +++ b/src/tools/cephfs/DataScan.h @@ -49,8 +49,7 @@ class RecoveryDriver { const inode_backtrace_t &bt, uint64_t size, time_t mtime, - uint32_t chunk_size, - int64_t data_pool_id) = 0; + const ceph_file_layout &layout) = 0; /** * Inject an inode + dentry into the lost+found directory, @@ -60,8 +59,7 @@ class RecoveryDriver { inodeno_t ino, uint64_t size, time_t mtime, - uint32_t chunk_size, - int64_t data_pool_id) = 0; + const ceph_file_layout &layout) = 0; /** * Create any missing roots (i.e. mydir, strays, root inode) @@ -124,15 +122,13 @@ class LocalFileDriver : public RecoveryDriver const inode_backtrace_t &bt, uint64_t size, time_t mtime, - uint32_t chunk_size, - int64_t data_pool_id); + ceph_file_layout const &layout); int inject_lost_and_found( inodeno_t ino, uint64_t size, time_t mtime, - uint32_t chunk_size, - int64_t data_pool_id); + ceph_file_layout const &layout); int init_roots(int64_t data_pool_id); @@ -199,15 +195,13 @@ class MetadataDriver : public RecoveryDriver const inode_backtrace_t &bt, uint64_t size, time_t mtime, - uint32_t chunk_size, - int64_t data_pool_id); + ceph_file_layout const &layout); int inject_lost_and_found( inodeno_t ino, uint64_t size, time_t mtime, - uint32_t chunk_size, - int64_t data_pool_id); + ceph_file_layout const &layout); int init_roots(int64_t data_pool_id);