我使用了类bufferlist的ceph,但在抛出“ceph::buffer::bad_alloc”what():buffer::bad_alloc的实例后调用了终止
我使用image.write()将数据上传到ceph。成功现在我使用image.read()从ceph加载数据。找到错误“抛出‘ceph::buffer::bad_alloc‘what():buffer::bad_alloc’实例后调用终止”。我的代码如下
string file_path="/root/Documents/p.txt"; char * buffer; size_t buffer_len; ret=read_file(buffer,file_path,buffer_len); ceph::bufferlist bl; string s; //ret=bl.read_file(file_path.c_str(),&s); //cout<<"read file and ret is "<<ret<<" the error string is "<<s<<endl; bl.append(buffer,buffer_len); size_t len=bl.length(); cout<<"len is "<<len<<endl; image.write2(0,len,bl,0); if (ret < 0) { std::cerr << "couldn't write to the rbd image! error " << ret << std::endl; ret = EXIT_FAILURE; goto out; } else { std::cout << "we just wrote data to our rbd image " << std::endl; /* * let's read the image and compare it to the data we wrote */ ceph::bufferlist bl_r; cout<<"int len is "<<static_cast<int>(len)<<endl; bl_r.append_zero(len);
镜头为2102341024,超过2GB。如果len为1GB,则无错误
我希望能找到bufferlist的文档。我不知道他是如何在内部实现数据存储和内存应用程序的。