/** prepare to start processing object data */
virtual int prepare(optional_yield y) = 0;
- /** Process a buffer. Called multiple times to write different buffers. */
+ /**
+ * Process a buffer. Called multiple times to write different buffers.
+ * data.length() == 0 indicates the last call and may be used to flush
+ * the data buffers.
+ */
virtual int process(bufferlist&& data, uint64_t offset) = 0;
/** complete the operation and make its result visible to clients */
// and then launch the write operations.
int MotrAtomicWriter::process(bufferlist&& data, uint64_t offset)
{
- if (data.length() == 0)
- return 0;
+ if (data.length() == 0) { // last call, flush data
+ int rc = 0;
+ if (acc_data.length() != 0)
+ rc = this->write();
+ this->cleanup();
+ return rc;
+ }
if (acc_data.length() == 0)
acc_off = offset;
{
int rc = 0;
- if (acc_data.length() != 0)
+ if (acc_data.length() != 0) { // check again, just in case
rc = this->write();
-
- this->cleanup();
-
- if (rc != 0)
- return rc;
+ this->cleanup();
+ if (rc != 0)
+ return rc;
+ }
bufferlist bl;
rgw_bucket_dir_entry ent;
// TODO: update the current version (unset the flag) and insert the new current
// version can be launched in one motr op. This requires change at do_idx_op()
// and do_idx_op_by_name().
- int rc = obj.update_version_entries(dpp);
+ rc = obj.update_version_entries(dpp);
if (rc < 0)
return rc;
}