void set_snap(rados_pool_t pool, snapid_t seq);
int write(rados_pool_t pool, const object_t& oid, off_t off, bufferlist& bl, size_t len);
+ int write_full(rados_pool_t pool, const object_t& oid, bufferlist& bl);
int read(rados_pool_t pool, const object_t& oid, off_t off, bufferlist& bl, size_t len);
int remove(rados_pool_t pool, const object_t& oid);
// io
int write(PoolCtx& pool, const object_t& oid, off_t off, bufferlist& bl, size_t len);
+ int write_full(PoolCtx& pool, const object_t& oid, bufferlist& bl);
int read(PoolCtx& pool, const object_t& oid, off_t off, bufferlist& bl, size_t len);
int remove(PoolCtx& pool, const object_t& oid);
return len;
}
+int RadosClient::write_full(PoolCtx& pool, const object_t& oid, bufferlist& bl)
+{
+ utime_t ut = g_clock.now();
+
+ /* can't write to a snapshot */
+ if (pool.snap_seq != CEPH_NOSNAP)
+ return -EINVAL;
+
+ Mutex mylock("RadosClient::write_full::mylock");
+ Cond cond;
+ bool done;
+ int r;
+
+ Context *onack = new C_SafeCond(&mylock, &cond, &done, &r);
+
+ dout(0) << "going to write_full" << dendl;
+
+ lock.Lock();
+ ceph_object_layout layout = objecter->osdmap->make_object_layout(oid, pool.poolid);
+ objecter->write_full(oid, layout,
+ pool.snapc, bl, ut, 0,
+ onack, NULL);
+ lock.Unlock();
+
+ mylock.Lock();
+ while (!done)
+ cond.Wait(mylock);
+ mylock.Unlock();
+
+ dout(0) << "did write_full" << dendl;
+
+ return r;
+}
+
int RadosClient::aio_read(PoolCtx& pool, const object_t oid, off_t off, bufferlist *pbl, size_t len,
AioCompletion **pc)
{
return client->write(*(RadosClient::PoolCtx *)pool, oid, off, bl, len);
}
+int Rados::write_full(rados_pool_t pool, const object_t& oid, bufferlist& bl)
+{
+ if (!client)
+ return -EINVAL;
+
+ return client->write_full(*(RadosClient::PoolCtx *)pool, oid, bl);
+}
+
int Rados::remove(rados_pool_t pool, const object_t& oid)
{
if (!client)
return op_submit(o);
}
tid_t write_full(const object_t& oid, ceph_object_layout ol,
- const SnapContext& snapc, bufferlist &bl, utime_t mtime, int flags,
+ const SnapContext& snapc, const bufferlist &bl, utime_t mtime, int flags,
Context *onack, Context *oncommit) {
vector<OSDOp> ops(1);
ops[0].op.op = CEPH_OSD_OP_WRITEFULL;
usage();
}
object_t oid(nargs[1]);
- int r = rados.write(p, oid, 0, indata, indata.length());
+ int r = rados.write_full(p, oid, indata);
if (r < 0) {
cerr << "error writing " << oid << " to pool " << pool << ": " << strerror(-r) << std::endl;
exit(0);