From ed87338afd0ed106ae7bec4523f4bf0ee6a701cd Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Sat, 24 Jun 2023 12:25:46 +0530 Subject: [PATCH] rgw: Do not update mtime in `set_attrs` As per https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html, the only way for users to modify object metadata is to make a copy of the object and set the metadata. Hence retain old mtime for any other attr changes Signed-off-by: Soumya Koduri (cherry picked from commit 31666d71aa5b58a9384938ba31892d48f2ac3f67) --- src/rgw/driver/rados/rgw_rados.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 9e2cfe67794..dfdd3528abb 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -4714,6 +4714,7 @@ int RGWRados::transition_obj(RGWObjectCtx& obj_ctx, if (read_mtime != mtime) { /* raced */ + ldpp_dout(dpp, 0) << __func__ << " ERROR: failed to transition obj(" << obj.key << ") read_mtime = " << read_mtime << " doesn't match mtime = " << mtime << dendl; return -ECANCELED; } @@ -6026,7 +6027,11 @@ int RGWRados::set_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* rctx, RGWBu } - real_time mtime = real_clock::now(); + /* As per https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html, + * the only way for users to modify object metadata is to make a copy of the object and + * set the metadata. + * Hence do not update mtime for any other attr changes */ + real_time mtime = state->mtime; struct timespec mtime_ts = real_clock::to_timespec(mtime); op.mtime2(&mtime_ts); auto& ioctx = ref.pool.ioctx(); -- 2.39.5