From: sungjoon-koh Date: Thu, 10 Jul 2025 07:05:31 +0000 (+0900) Subject: rgw: add wildcard "*" support for conditional read X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=beba28f2f4da12bd572325d80469709037009d98;p=ceph.git rgw: add wildcard "*" support for conditional read - Enhanced If-Match and If-None-Match headers to support the wildcard "*". - Updated conditional read behavior: - If-Match: * now returns 200 instead of 412 when any object exists. - If-None-Match: * now returns 304 instead of 200 when any object exists. - If-Match: * + If-None-Match: * now returns 304 instead of 412. - Aligns with AWS S3 expected functionality for improved efficiency. Signed-off-by: sungjoon_koh --- diff --git a/src/rgw/driver/dbstore/common/dbstore.cc b/src/rgw/driver/dbstore/common/dbstore.cc index 687b805c86b..33ae4d9db80 100644 --- a/src/rgw/driver/dbstore/common/dbstore.cc +++ b/src/rgw/driver/dbstore/common/dbstore.cc @@ -1381,14 +1381,22 @@ int DB::Object::Read::prepare(const DoutPrefixProvider *dpp) if (conds.if_match) { string if_match_str = rgw_string_unquote(conds.if_match); - ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-Match: " << if_match_str << dendl; - if (if_match_str.compare(0, etag.length(), etag.c_str(), etag.length()) != 0) { - return -ERR_PRECONDITION_FAILED; + if (if_match_str.compare("*") != 0) { + ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-Match: " << if_match_str << dendl; + if (if_match_str.compare(0, etag.length(), etag.c_str(), etag.length()) != 0) { + return -ERR_PRECONDITION_FAILED; + } + } else { + ldpp_dout(dpp, 10) << "If-Match: " << if_match_str << dendl; } } if (conds.if_nomatch) { string if_nomatch_str = rgw_string_unquote(conds.if_nomatch); + if (if_nomatch_str.compare("*") == 0) { + ldpp_dout(dpp, 10) << "If-NoMatch: " << if_nomatch_str << dendl; + return -ERR_NOT_MODIFIED; + } ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-NoMatch: " << if_nomatch_str << dendl; if (if_nomatch_str.compare(0, etag.length(), etag.c_str(), etag.length()) == 0) { return -ERR_NOT_MODIFIED; diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 02dfb31947c..c293fce3d56 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -7745,14 +7745,22 @@ int RGWRados::Object::Read::prepare(optional_yield y, const DoutPrefixProvider * if (conds.if_match) { string if_match_str = rgw_string_unquote(conds.if_match); - ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-Match: " << if_match_str << dendl; - if (if_match_str.compare(0, etag.length(), etag.c_str(), etag.length()) != 0) { - return -ERR_PRECONDITION_FAILED; + if (if_match_str.compare("*") != 0) { + ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-Match: " << if_match_str << dendl; + if (if_match_str.compare(0, etag.length(), etag.c_str(), etag.length()) != 0) { + return -ERR_PRECONDITION_FAILED; + } + } else { + ldpp_dout(dpp, 10) << "If-Match: " << if_match_str << dendl; } } if (conds.if_nomatch) { string if_nomatch_str = rgw_string_unquote(conds.if_nomatch); + if (if_nomatch_str.compare("*") == 0) { + ldpp_dout(dpp, 10) << "If-NoMatch: " << if_nomatch_str << dendl; + return -ERR_NOT_MODIFIED; + } ldpp_dout(dpp, 10) << "ETag: " << string(etag.c_str(), etag.length()) << " " << " If-NoMatch: " << if_nomatch_str << dendl; if (if_nomatch_str.compare(0, etag.length(), etag.c_str(), etag.length()) == 0) { return -ERR_NOT_MODIFIED;