Skip to content

Commit

Permalink
librbd: move object create before set alloc hint
Browse files Browse the repository at this point in the history
This commit fixes the order of ops in write requests to have create before set alloc hint, so that exclusive create will not falsely fail

Signed-off-by: Or Ozeri <[email protected]>
  • Loading branch information
orozery committed Jan 10, 2021
1 parent 2ab05ea commit 285ba2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/librbd/io/ObjectRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,17 @@ void AbstractObjectWriteRequest<I>::handle_post_write_object_map_update(int r) {
}

template <typename I>
void ObjectWriteRequest<I>::add_write_ops(neorados::WriteOp* wr) {
void ObjectWriteRequest<I>::add_write_hint(neorados::WriteOp* wr) {
if ((m_write_flags & OBJECT_WRITE_FLAG_CREATE_EXCLUSIVE) != 0) {
wr->create(true);
} else if (m_assert_version.has_value()) {
wr->assert_version(m_assert_version.value());
}
AbstractObjectWriteRequest<I>::add_write_hint(wr);
}

template <typename I>
void ObjectWriteRequest<I>::add_write_ops(neorados::WriteOp* wr) {
if (this->m_full_object) {
wr->write_full(bufferlist{m_write_data});
} else {
Expand Down
1 change: 1 addition & 0 deletions src/librbd/io/ObjectRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ class ObjectWriteRequest : public AbstractObjectWriteRequest<ImageCtxT> {

protected:
void add_write_ops(neorados::WriteOp *wr) override;
void add_write_hint(neorados::WriteOp *wr) override;

private:
ceph::bufferlist m_write_data;
Expand Down

0 comments on commit 285ba2a

Please sign in to comment.