]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: simplify stat
authorSage Weil <sage@newdream.net>
Tue, 5 Apr 2011 19:36:10 +0000 (12:36 -0700)
committerSage Weil <sage@newdream.net>
Tue, 5 Apr 2011 19:36:10 +0000 (12:36 -0700)
We don't actually need to stat the object (again) since we have the size
(and mtime) in the object_info_t.  Keep the existing stat in there, tho,
and assert the answer matches for the time being, since I saw behavior
that suggested they were out of sync.  See #933.

Signed-off-by: Sage Weil <sage@newdream.net>
src/osd/ReplicatedPG.cc

index a6210cdc80860ebf3501b4d34a5ef002c1f92f18..c49bebfae35f44754f17bfff75f02403cbed9fe1 100644 (file)
@@ -1198,13 +1198,18 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops,
 
     case CEPH_OSD_OP_STAT:
       {
-       struct stat st;
-       memset(&st, 0, sizeof(st));
-       result = osd->store->stat(coll, soid, &st);
-       if (result >= 0) {
-         uint64_t size = st.st_size;
-         ::encode(size, odata);
-         ::encode(oi.mtime, odata);
+       ::encode(oi.size, odata);
+       ::encode(oi.mtime, odata);
+       dout(10) << "stat oi has " << oi.size << " " << oi.mtime << dendl;
+       if (1) {  // REMOVE ME LATER!
+         struct stat st;
+         memset(&st, 0, sizeof(st));
+         result = osd->store->stat(coll, soid, &st);
+         if (result || st.st_size != oi.size) {
+           osd->clog.error() << info.pgid << " " << soid << " oi.size " << oi.size
+                             << " but stat got " << result << " size " << st.st_size << "\n";
+           assert(0 == "oi disagrees with stat");
+         }
        }
        info.stats.num_rd++;
       }