Skip to content

Commit

Permalink
Merge pull request #18885 from dzafman/wip-22112
Browse files Browse the repository at this point in the history
ceph-objectstore-tool: Fix set-size to clear data_digest if changing …

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Nov 15, 2017
2 parents 267b97e + 7ca3ce9 commit 730b2d9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/tools/ceph_objectstore_tool.cc
Expand Up @@ -2133,12 +2133,15 @@ int set_size(ObjectStore *store, coll_t coll, ghobject_t &ghobj, uint64_t setsiz
if (!dry_run) {
attr.clear();
oi.size = setsize;
::encode(oi, attr, -1); /* fixme: using full features */
ObjectStore::Transaction t;
t.setattr(coll, ghobj, OI_ATTR, attr);
// Only modify object info if we want to corrupt it
if (!corrupt)
if (!corrupt && (uint64_t)st.st_size != setsize) {
t.truncate(coll, ghobj, setsize);
// Changing objectstore size will invalidate data_digest, so clear it.
oi.clear_data_digest();
}
::encode(oi, attr, -1); /* fixme: using full features */
t.setattr(coll, ghobj, OI_ATTR, attr);
if (is_snap) {
bufferlist snapattr;
snapattr.clear();
Expand Down

0 comments on commit 730b2d9

Please sign in to comment.