| 1856 | } |
| 1857 | |
| 1858 | int ObjectStoreTool::dump_export(Formatter *formatter, |
| 1859 | const std::string &dump_data_dir) |
| 1860 | { |
| 1861 | bufferlist ebl; |
| 1862 | pg_info_t info; |
| 1863 | PGLog::IndexedLog log; |
| 1864 | //bool skipped_objects = false; |
| 1865 | |
| 1866 | int ret = read_super(); |
| 1867 | if (ret) |
| 1868 | return ret; |
| 1869 | |
| 1870 | if (sh.magic != super_header::super_magic) { |
| 1871 | cerr << "Invalid magic number" << std::endl; |
| 1872 | return -EFAULT; |
| 1873 | } |
| 1874 | |
| 1875 | if (sh.version > super_header::super_ver) { |
| 1876 | cerr << "Can't handle export format version=" << sh.version << std::endl; |
| 1877 | return -EINVAL; |
| 1878 | } |
| 1879 | |
| 1880 | formatter->open_object_section("Export"); |
| 1881 | |
| 1882 | //First section must be TYPE_PG_BEGIN |
| 1883 | sectiontype_t type; |
| 1884 | ret = read_section(&type, &ebl); |
| 1885 | if (ret) |
| 1886 | return ret; |
| 1887 | if (type == TYPE_POOL_BEGIN) { |
| 1888 | cerr << "Dump of pool exports not supported" << std::endl; |
| 1889 | return -EINVAL; |
| 1890 | } else if (type != TYPE_PG_BEGIN) { |
| 1891 | cerr << "Invalid first section type " << std::to_string(type) << std::endl; |
| 1892 | return -EFAULT; |
| 1893 | } |
| 1894 | |
| 1895 | auto ebliter = ebl.cbegin(); |
| 1896 | pg_begin pgb; |
| 1897 | pgb.decode(ebliter); |
| 1898 | spg_t pgid = pgb.pgid; |
| 1899 | |
| 1900 | formatter->dump_string("pgid", stringify(pgid)); |
| 1901 | formatter->dump_string("cluster_fsid", stringify(pgb.superblock.cluster_fsid)); |
| 1902 | formatter->dump_string("features", stringify(pgb.superblock.compat_features)); |
| 1903 | |
| 1904 | bool done = false; |
| 1905 | bool found_metadata = false; |
| 1906 | metadata_section ms; |
| 1907 | bool objects_started = false; |
| 1908 | while(!done) { |
| 1909 | ret = read_section(&type, &ebl); |
| 1910 | if (ret) |
| 1911 | return ret; |
| 1912 | |
| 1913 | if (debug) { |
| 1914 | cerr << "dump_export: Section type " << std::to_string(type) << std::endl; |
| 1915 | } |
no test coverage detected