]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use is_truncated to judge whether get all bucket already
authorliuchang0812 <liuchang0812@gmail.com>
Wed, 5 Apr 2017 12:06:11 +0000 (20:06 +0800)
committerliuchang0812 <liuchang0812@gmail.com>
Wed, 5 Apr 2017 12:06:11 +0000 (20:06 +0800)
That use is_truncated is simple and avoid nessesary list. We have to iterate 11
times initially if there is 100 buckets and iter_max_bucket is 10. We only need
10 times now.

Signed-off-by: liuchang0812 <liuchang0812@gmail.com>
src/rgw/rgw_bucket.cc
src/rgw/rgw_op.cc
src/rgw/rgw_user.cc

index e9221783e5285d6c408bab071aaa88143a332afb..02b05c485b767850ef4f2fa3530f5a419e740e4d 100644 (file)
@@ -444,7 +444,6 @@ void check_bad_user_bucket_mapping(RGWRados *store, const rgw_user& user_id,
                                   bool fix)
 {
   RGWUserBuckets user_buckets;
-  bool done;
   bool is_truncated;
   string marker;
 
@@ -496,8 +495,7 @@ void check_bad_user_bucket_mapping(RGWRados *store, const rgw_user& user_id,
         }
       }
     }
-    done = (buckets.size() < max_entries);
-  } while (!done);
+  } while (is_truncated);
 }
 
 static bool bucket_object_check_filter(const string& oid)
@@ -1431,7 +1429,6 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
 
     RGWUserBuckets buckets;
     string marker;
-    bool done;
     bool is_truncated;
 
     do {
@@ -1455,8 +1452,7 @@ int RGWBucketAdminOp::info(RGWRados *store, RGWBucketAdminOpState& op_state,
       }
 
       flusher.flush();
-      done = (m.size() < max_entries);
-    } while (!done);
+    } while (is_truncated);
 
     formatter->close_section();
   } else if (!bucket_name.empty()) {
index a4572dd3a9478139b37753cfe125636fe7175651..441ca6be0dffd9d95c3424305e1a126fa1cfd414 100644 (file)
@@ -1620,7 +1620,7 @@ void RGWListBuckets::execute()
       map<string, RGWBucketEnt>::reverse_iterator riter = m.rbegin();
       marker = riter->first;
     }
-  } while (!done);
+  } while (is_truncated && !done);
 
 send_end:
   if (!started) {
@@ -1701,7 +1701,6 @@ int RGWStatAccount::verify_permission()
 void RGWStatAccount::execute()
 {
   string marker;
-  bool done;
   bool is_truncated;
   uint64_t max_buckets = s->cct->_conf->rgw_list_buckets_max_chunk;
 
@@ -1729,9 +1728,8 @@ void RGWStatAccount::execute()
       }
       buckets_count += m.size();
 
-      done = (m.size() < max_buckets);
     }
-  } while (!done);
+  } while (is_truncated);
 }
 
 int RGWGetBucketVersioning::verify_permission()
index 0a8a6250cceb5661649147f36634e9fdb788348a..94e40698c849c44170531832de5f42091d78d553 100644 (file)
@@ -45,7 +45,6 @@ int rgw_user_sync_all_stats(RGWRados *store, const rgw_user& user_id)
 {
   CephContext *cct = store->ctx();
   size_t max_entries = cct->_conf->rgw_list_buckets_max_chunk;
-  bool done;
   bool is_truncated;
   string marker;
   int ret;
@@ -79,8 +78,7 @@ int rgw_user_sync_all_stats(RGWRados *store, const rgw_user& user_id)
         return ret;
       }
     }
-    done = (buckets.size() < max_entries);
-  } while (!done);
+  } while (is_truncated);
 
   ret = store->complete_sync_user_stats(user_id);
   if (ret < 0) {
@@ -2030,7 +2028,6 @@ int RGWUser::execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg)
     return -ENOENT;
   }
 
-  bool done;
   bool is_truncated;
   string marker;
   CephContext *cct = store->ctx();
@@ -2061,8 +2058,7 @@ int RGWUser::execute_remove(RGWUserAdminOpState& op_state, std::string *err_msg)
       marker = it->first;
     }
 
-    done = (m.size() < max_buckets);
-  } while (!done);
+  } while (is_truncated);
 
   ret = rgw_delete_user(store, user_info, op_state.objv);
   if (ret < 0) {
@@ -2193,7 +2189,6 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg)
       return -EINVAL;
     }
 
-    bool done;
     bool is_truncated;
     string marker;
     CephContext *cct = store->ctx();
@@ -2223,8 +2218,7 @@ int RGWUser::execute_modify(RGWUserAdminOpState& op_state, std::string *err_msg)
         return ret;
       }
 
-      done = (m.size() < max_buckets);
-    } while (!done);
+    } while (is_truncated);
   }
   op_state.set_user_info(user_info);