MCPcopy Create free account
hub / github.com/ceph/ceph / export_file

Method export_file

src/tools/ceph_objectstore_tool.cc:846–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

844}
845
846int ObjectStoreTool::export_file(ObjectStore *store, coll_t cid, ghobject_t &obj, bool force)
847{
848 struct stat st;
849 mysize_t total;
850 footer ft;
851
852 auto ch = store->open_collection(cid);
853 if (!ch) {
854 cerr << "Collection " << cid << " does not exist" << std::endl;
855 return -ENOENT;
856 }
857 int ret = store->stat(ch, obj, &st);
858 if (ret < 0)
859 return ret;
860
861 cerr << "Read " << obj << std::endl;
862
863 total = st.st_size;
864 if (debug)
865 cerr << "size=" << total << std::endl;
866
867 object_begin objb(obj);
868
869 {
870 bufferptr bp;
871 bufferlist bl;
872 ret = store->getattr(ch, obj, OI_ATTR, bp);
873 if (ret < 0) {
874 cerr << "getattr failure: " << cpp_strerror(ret)
875 << " at obj:" << obj
876 << (force ? " IGNORED" : "")
877 << std::endl;
878 if (!force) {
879 return ret;
880 }
881 } else {
882 bl.push_back(bp);
883 decode(objb.oi, bl);
884 if (debug)
885 cerr << "object_info: " << objb.oi << std::endl;
886 }
887 }
888
889 // NOTE: we include whiteouts, lost, etc.
890
891 ret = write_section(TYPE_OBJECT_BEGIN, objb, file_fd);
892 if (ret < 0)
893 return ret;
894
895 uint64_t offset = 0;
896 bufferlist rawdatabl;
897 while(total > 0) {
898 rawdatabl.clear();
899 mysize_t len = max_read;
900 if (len > total)
901 len = total;
902
903 ret = store->read(ch, obj, offset, len, rawdatabl);

Callers

nothing calls this directly

Calls 15

cpp_strerrorFunction · 0.85
fill_omap_batchFunction · 0.85
flush_omap_batchFunction · 0.85
decodeFunction · 0.50
open_collectionMethod · 0.45
statMethod · 0.45
getattrMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45
readMethod · 0.45
append_zeroMethod · 0.45
claim_appendMethod · 0.45

Tested by

no test coverage detected