]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: set directory ctime and mtime
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 10 Jan 2016 18:44:52 +0000 (13:44 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:07:46 +0000 (12:07 -0500)
Adds method to RGWStatBucketRequest to access the creation_time of
the returned bucket.

(For now, that's the only timestamp we have.)

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 16817112ba52b3169d1b71077627c42bbfe9e135..34b92d16d1d06d23e5e2ee92736df3b863e3b34f 100644 (file)
@@ -52,6 +52,10 @@ namespace rgw {
       fhr = lookup_fh(parent, path,
                      RGWFileHandle::FLAG_CREATE|
                      RGWFileHandle::FLAG_BUCKET);
+      if (get<0>(fhr)) {
+       RGWFileHandle* rgw_fh = get<0>(fhr);
+       rgw_fh->set_times(req.get_ctime());
+      }
     }
     return fhr;
   }
@@ -109,8 +113,17 @@ namespace rgw {
            fhr = lookup_fh(parent, path,
                            RGWFileHandle::FLAG_CREATE|
                            ((req.is_dir) ?
-                            RGWFileHandle::FLAG_DIRECTORY :
-                            RGWFileHandle::FLAG_NONE));
+                             RGWFileHandle::FLAG_DIRECTORY :
+                             RGWFileHandle::FLAG_NONE));
+           /* XXX we don't have an object--in general, there need not
+            * be one (just a path segment in some other object).  In
+            * actual leaf an object exists, but we'd need another round
+            * trip to get attrs */
+           if (get<0>(fhr)) {
+             /* for now use the parent object's mtime */
+             RGWFileHandle* rgw_fh = get<0>(fhr);
+             rgw_fh->set_mtime(parent->get_mtime());
+           }
          }
        }
       }
index c3953779986bfeb1441c7f0f42cb8956ac818ecc..44cee94088c6dfc020b45eab867007b1347259df 100644 (file)
@@ -280,6 +280,8 @@ namespace rgw {
 
     RGWFileHandle* get_parent() { return parent; }
 
+    struct timespec get_mtime() const { return state.mtime; }
+
     int stat(struct stat *st) {
       /* partial Unix attrs */
       memset(st, 0, sizeof(struct stat));
@@ -1567,6 +1569,10 @@ public:
     return 0;
   }
 
+  time_t get_ctime() const {
+    return bucket.creation_time;
+  }
+
   virtual int get_params() {
     return 0;
   }