]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Do not update mtime in `set_attrs` 52160/head
authorSoumya Koduri <skoduri@redhat.com>
Sat, 24 Jun 2023 06:55:46 +0000 (12:25 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Wed, 28 Jun 2023 07:41:26 +0000 (13:11 +0530)
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 <skoduri@redhat.com>
src/rgw/driver/rados/rgw_rados.cc

index b6c76831a20d3dad983ede9574e302ae1312345f..68398877ae5a75b066c9c6933576f60d71fad84a 100644 (file)
@@ -4733,6 +4733,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;
   }
 
@@ -6045,7 +6046,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();