]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados: implement radosstripper force remove when full. 6202/head
authorshawn <cxwshawn@gmail.com>
Fri, 11 Dec 2015 08:47:27 +0000 (03:47 -0500)
committershawn <cxwshawn@gmail.com>
Fri, 11 Dec 2015 08:47:30 +0000 (03:47 -0500)
                    extend libradosstripper remove interface and rados tool
                    rm force-full when use_stripper.

Signed-off-by: Xiaowei Chen <chen.xiaowei@h3c.com>
src/include/radosstriper/libradosstriper.hpp
src/libradosstriper/RadosStriperImpl.cc
src/libradosstriper/RadosStriperImpl.h
src/libradosstriper/libradosstriper.cc
src/tools/rados/rados.cc

index 05179ffbc658c07e0f1aa1791e9e5a9e4e255146..6352d581e3b5e3437a14c827aebbd5a1a8cb7b18 100644 (file)
@@ -190,7 +190,7 @@ namespace libradosstriper
      * during deletion (same EBUSY return code)
      */
     int remove(const std::string& soid);
-
+    int remove(const std::string& soid, int flags);
     /**
      * Resizes a striped object
      * the truncation can not happen if any I/O is ongoing (it
index 3544cac1b787e68640c8980d716b42551d5027aa..e9b3bd5fa59a6c5469920f13f3bb5013731fd8ac 100644 (file)
@@ -550,7 +550,7 @@ int libradosstriper::RadosStriperImpl::stat(const std::string& soid, uint64_t *p
   return 0;
 }
 
-int libradosstriper::RadosStriperImpl::remove(const std::string& soid)
+int libradosstriper::RadosStriperImpl::remove(const std::string& soid, int flags)
 {
   std::string firstObjOid = getObjectId(soid, 0);
   try {
@@ -591,11 +591,15 @@ int libradosstriper::RadosStriperImpl::remove(const std::string& soid)
     // delete rados objects in reverse order
     int rcr = 0;
     for (int i = nb_objects-1; i >= 0; i--) {
-      rcr = m_ioCtx.remove(getObjectId(soid, i));
+      if (flags == 0) {
+        rcr = m_ioCtx.remove(getObjectId(soid, i));
+      } else {
+        rcr = m_ioCtx.remove(getObjectId(soid, i), flags);  
+      }
       if (rcr < 0 and -ENOENT != rcr) {
         lderr(cct()) << "RadosStriperImpl::remove : deletion incomplete for " << soid
-                  << ", as " << getObjectId(soid, i) << " could not be deleted (rc=" << rc << ")"
-                  << dendl;
+                    << ", as " << getObjectId(soid, i) << " could not be deleted (rc=" << rc << ")"
+                    << dendl;
         break;
       }
     }
@@ -605,6 +609,7 @@ int libradosstriper::RadosStriperImpl::remove(const std::string& soid)
     // errror caught when trying to take the exclusive lock
     return e.m_code;
   }
+
 }
 
 int libradosstriper::RadosStriperImpl::trunc(const std::string& soid, uint64_t size)
index 7862f0596ee57f6a2233c2acc8ef3eefef308475..c2bb8ba321b4c9edf852b97a1711f399c9e09406 100644 (file)
@@ -187,7 +187,7 @@ struct libradosstriper::RadosStriperImpl {
 
   // stat, deletion and truncation
   int stat(const std::string& soid, uint64_t *psize, time_t *pmtime);
-  int remove(const std::string& soid);
+  int remove(const std::string& soid, int flags=0);
   int trunc(const std::string& soid, uint64_t size);
 
   // reference counting
index 44079b5f4e267e85b1a433fa956ab477db2c67f9..969f2d814732f94d6599c9b6541286a43653f5b7 100644 (file)
@@ -273,6 +273,10 @@ int libradosstriper::RadosStriper::remove(const std::string& soid)
 {
   return rados_striper_impl->remove(soid);
 }
+int libradosstriper::RadosStriper::remove(const std::string& soid, int flags)
+{
+  return rados_striper_impl->remove(soid, flags); 
+}
 
 int libradosstriper::RadosStriper::trunc(const std::string& soid, uint64_t size)
 {
index d13a3039a5c0891d32aa6084ffded47b7e2d617d..4057b586d36039911d54fe3bcace57bf4ff1dcbc 100644 (file)
@@ -2149,7 +2149,11 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
     for (; iter != nargs.end(); ++iter) {
       const string & oid = *iter;
       if (use_striper) {
-       ret = striper.remove(oid);
+       if (forcefull) {
+         ret = striper.remove(oid, CEPH_OSD_FLAG_FULL_FORCE);
+       } else {
+         ret = striper.remove(oid);
+       }
       } else {
        if (forcefull) {
          ret = io_ctx.remove(oid, CEPH_OSD_FLAG_FULL_FORCE);