Skip to content

Commit

Permalink
rados: implement radosstripper force remove when full.
Browse files Browse the repository at this point in the history
        extend libradosstripper remove interface and rados tool
        rm force-full when use_stripper.

Signed-off-by: Xiaowei Chen <chen.xiaowei@h3c.com>
  • Loading branch information
Xiaowei Chen committed Nov 25, 2015
1 parent 5246a9b commit 0a9f643
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/include/radosstriper/libradosstriper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions src/libradosstriper/RadosStriperImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/libradosstriper/RadosStriperImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/libradosstriper/libradosstriper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 5 additions & 1 deletion src/tools/rados/rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "true" ){
ret = striper.remove(oid, CEPH_OSD_FLAG_FULL_FORCE);
} else {
ret = striper.remove(oid);
}
} else {
if ( forcefull == "true" ){
ret = io_ctx.remove(oid, CEPH_OSD_FLAG_FULL_FORCE);
Expand Down

0 comments on commit 0a9f643

Please sign in to comment.