]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
fakestore: copy if theres no splice
authorSage Weil <sage@newdream.net>
Mon, 28 Apr 2008 14:41:12 +0000 (07:41 -0700)
committerSage Weil <sage@newdream.net>
Mon, 28 Apr 2008 14:41:12 +0000 (07:41 -0700)
src/osd/FakeStore.cc

index 27afb9704cb97790c49598e806b74e03509d3e85..b45a75e5b203476703ba2d2e5c1572c54eee6d71 100644 (file)
@@ -532,9 +532,31 @@ int FakeStore::clone(pobject_t oldoid, pobject_t newoid)
   else {
     struct stat st;
     ::fstat(o, &st);
+
+#ifdef SPLICE_F_MOVE
     loff_t op = 0, np = 0;
     while (op < st.st_size && r >= 0)
       r = ::splice(o, &op, n, &np, st.st_size-op, 0);
+#else
+    loff_t pos = 0;
+    int buflen = 4096*10;
+    char buf[buflen];
+    while (pos < st.st_size) {
+      int l = MIN(st.st_size-pos, buflen);
+      r = ::read(o, buf, l);
+      if (r < 0)
+       break;
+      int op = 0;
+      while (op < l) {
+       int r2 = ::write(n, buf+op, l-op);
+       
+       if (r2 < 0) { r = r2; break; }
+       op += r2;         
+      }
+      if (r < 0) break;
+      pos += r;
+    }
+#endif
   }
   if (r < 0)
     return -errno;