]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: allow setattr on placeholder directories
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 19 Feb 2017 23:21:06 +0000 (18:21 -0500)
committerNathan Cutler <ncutler@suse.com>
Wed, 29 Mar 2017 04:05:42 +0000 (06:05 +0200)
When a POSIX path <bucket>/foo/ is known only as an implicit path
segment from other objects (e.g., <bucket>/foo/bar.txt), a case
that would usually arise from S3 upload of such an object, an
RGWFileHandle object representing "<bucket>/foo/" will be constructed
as needed, with no backing in RGW.

This is by design, but subsequently, if a setattr is performed on
such a handle, we must be ready to create the object inline with
storing the attributes.

Fixes: http://tracker.ceph.com/issues/18989
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit 55eec1c0a0e136736961423b7b6244d0f3693c1a)

src/rgw/rgw_file.cc

index c6c4129608c6639663384824395552da0c45f749..f3016d025b554fdf1e080eef626cbe192f35305f 100644 (file)
@@ -601,6 +601,22 @@ namespace rgw {
     rc = rgwlib.get_fe()->execute_req(&req);
     rc2 = req.get_ret();
 
+    if (rc == -ENOENT) {
+      /* special case:  materialize placeholder dir */
+      buffer::list bl;
+      RGWPutObjRequest req(get_context(), get_user(), rgw_fh->bucket_name(),
+                          obj_name, bl);
+
+      rgw_fh->encode_attrs(ux_key, ux_attrs); /* because std::moved */
+
+      /* save attrs */
+      req.emplace_attr(RGW_ATTR_UNIX_KEY1, std::move(ux_key));
+      req.emplace_attr(RGW_ATTR_UNIX1, std::move(ux_attrs));
+
+      rc = rgwlib.get_fe()->execute_req(&req);
+      rc2 = req.get_ret();
+    }
+
     return (((rc == 0) && (rc2 == 0)) ? 0 : -EIO);
   } /* RGWLibFS::setattr */