Skip to content

Commit

Permalink
cls_lock_client: change modified reference parameters to pointers
Browse files Browse the repository at this point in the history
This makes it clear which parameters are modified,
as our style guide states.

Signed-off-by: Josh Durgin <[email protected]>
  • Loading branch information
jdurgin committed Aug 31, 2012
1 parent 9c6752e commit b4298fc
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 95 deletions.
54 changes: 27 additions & 27 deletions src/cls/lock/cls_lock_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace rados {
namespace cls {
namespace lock {

void lock(ObjectWriteOperation& rados_op,
void lock(ObjectWriteOperation *rados_op,
const string& name, ClsLockType type,
const string& cookie, const string& tag,
const string& description,
Expand All @@ -48,22 +48,22 @@ namespace rados {
op.flags = flags;
bufferlist in;
::encode(op, in);
rados_op.exec("lock", "lock", in);
rados_op->exec("lock", "lock", in);
}

int lock(IoCtx& ioctx,
int lock(IoCtx *ioctx,
const string& oid,
const string& name, ClsLockType type,
const string& cookie, const string& tag,
const string& description, const utime_t& duration,
uint8_t flags)
{
ObjectWriteOperation op;
lock(op, name, type, cookie, tag, description, duration, flags);
return ioctx.operate(oid, &op);
lock(&op, name, type, cookie, tag, description, duration, flags);
return ioctx->operate(oid, &op);
}

void unlock(ObjectWriteOperation& rados_op,
void unlock(ObjectWriteOperation *rados_op,
const string& name, const string& cookie)
{
cls_lock_unlock_op op;
Expand All @@ -72,18 +72,18 @@ namespace rados {
bufferlist in;
::encode(op, in);

rados_op.exec("lock", "unlock", in);
rados_op->exec("lock", "unlock", in);
}

int unlock(IoCtx& ioctx, const string& oid,
int unlock(IoCtx *ioctx, const string& oid,
const string& name, const string& cookie)
{
ObjectWriteOperation op;
unlock(op, name, cookie);
return ioctx.operate(oid, &op);
unlock(&op, name, cookie);
return ioctx->operate(oid, &op);
}

void break_lock(ObjectWriteOperation& rados_op,
void break_lock(ObjectWriteOperation *rados_op,
const string& name, const string& cookie,
const entity_name_t& locker)
{
Expand All @@ -93,22 +93,22 @@ namespace rados {
op.locker = locker;
bufferlist in;
::encode(op, in);
rados_op.exec("lock", "break_lock", in);
rados_op->exec("lock", "break_lock", in);
}

int break_lock(IoCtx& ioctx, const string& oid,
int break_lock(IoCtx *ioctx, const string& oid,
const string& name, const string& cookie,
const entity_name_t& locker)
{
ObjectWriteOperation op;
break_lock(op, name, cookie, locker);
return ioctx.operate(oid, &op);
break_lock(&op, name, cookie, locker);
return ioctx->operate(oid, &op);
}

int list_locks(IoCtx& ioctx, const string& oid, list<string> *locks)
int list_locks(IoCtx *ioctx, const string& oid, list<string> *locks)
{
bufferlist in, out;
int r = ioctx.exec(oid, "lock", "list_locks", in, out);
int r = ioctx->exec(oid, "lock", "list_locks", in, out);
if (r < 0)
return r;

Expand All @@ -125,7 +125,7 @@ namespace rados {
return 0;
}

int get_lock_info(IoCtx& ioctx, const string& oid, const string& lock,
int get_lock_info(IoCtx *ioctx, const string& oid, const string& lock,
map<locker_id_t, locker_info_t> *lockers,
ClsLockType *lock_type,
string *tag)
Expand All @@ -134,7 +134,7 @@ namespace rados {
cls_lock_get_info_op op;
op.name = lock;
::encode(op, in);
int r = ioctx.exec(oid, "lock", "get_info", in, out);
int r = ioctx->exec(oid, "lock", "get_info", in, out);
if (r < 0)
return r;

Expand All @@ -161,46 +161,46 @@ namespace rados {
return 0;
}

void Lock::lock_shared(ObjectWriteOperation& op)
void Lock::lock_shared(ObjectWriteOperation *op)
{
lock(op, name, LOCK_SHARED,
cookie, tag, description, duration, flags);
}

int Lock::lock_shared(IoCtx& ioctx, const string& oid)
int Lock::lock_shared(IoCtx *ioctx, const string& oid)
{
return lock(ioctx, oid, name, LOCK_SHARED,
cookie, tag, description, duration, flags);
}

void Lock::lock_exclusive(ObjectWriteOperation& op)
void Lock::lock_exclusive(ObjectWriteOperation *op)
{
lock(op, name, LOCK_EXCLUSIVE,
cookie, tag, description, duration, flags);
}

int Lock::lock_exclusive(IoCtx& ioctx, const string& oid)
int Lock::lock_exclusive(IoCtx *ioctx, const string& oid)
{
return lock(ioctx, oid, name, LOCK_EXCLUSIVE,
cookie, tag, description, duration, flags);
}

void Lock::unlock(ObjectWriteOperation& op)
void Lock::unlock(ObjectWriteOperation *op)
{
rados::cls::lock::unlock(op, name, cookie);
}

int Lock::unlock(IoCtx& ioctx, const string& oid)
int Lock::unlock(IoCtx *ioctx, const string& oid)
{
return rados::cls::lock::unlock(ioctx, oid, name, cookie);
}

void Lock::break_lock(ObjectWriteOperation& op, const entity_name_t& locker)
void Lock::break_lock(ObjectWriteOperation *op, const entity_name_t& locker)
{
rados::cls::lock::break_lock(op, name, cookie, locker);
}

int Lock::break_lock(IoCtx& ioctx, const string& oid, const entity_name_t& locker)
int Lock::break_lock(IoCtx *ioctx, const string& oid, const entity_name_t& locker)
{
return rados::cls::lock::break_lock(ioctx, oid, name, cookie, locker);
}
Expand Down
45 changes: 24 additions & 21 deletions src/cls/lock/cls_lock_client.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_CLS_LOCK_CLIENT_H
#define CEPH_CLS_LOCK_CLIENT_H

Expand All @@ -12,38 +15,38 @@ namespace rados {
namespace cls {
namespace lock {

extern void lock(librados::ObjectWriteOperation& rados_op,
extern void lock(librados::ObjectWriteOperation *rados_op,
const std::string& name, ClsLockType type,
const std::string& cookie, const std::string& tag,
const std::string& description, const utime_t& duration,
uint8_t flags);
uint8_t flags);

extern int lock(librados::IoCtx& ioctx,
extern int lock(librados::IoCtx *ioctx,
const std::string& oid,
const std::string& name, ClsLockType type,
const std::string& cookie, const std::string& tag,
const std::string& description, const utime_t& duration,
uint8_t flags);
uint8_t flags);

extern void unlock(librados::ObjectWriteOperation& rados_op,
extern void unlock(librados::ObjectWriteOperation *rados_op,
const std::string& name, const std::string& cookie);

extern int unlock(librados::IoCtx& ioctx, const std::string& oid,
extern int unlock(librados::IoCtx *ioctx, const std::string& oid,
const std::string& name, const std::string& cookie);

extern void break_lock(librados::ObjectWriteOperation& op,
extern void break_lock(librados::ObjectWriteOperation *op,
const std::string& name, const std::string& cookie,
const entity_name_t& locker);

extern int break_lock(librados::IoCtx& ioctx, const std::string& oid,
extern int break_lock(librados::IoCtx *ioctx, const std::string& oid,
const std::string& name, const std::string& cookie,
const entity_name_t& locker);

extern int list_locks(librados::IoCtx& ioctx, const std::string& oid,
list<std::string> *locks);
extern int get_lock_info(librados::IoCtx& ioctx, const std::string& oid,
const std::string& lock,
map<locker_id_t, locker_info_t> *lockers,
extern int list_locks(librados::IoCtx *ioctx, const std::string& oid,
list<std::string> *locks);
extern int get_lock_info(librados::IoCtx *ioctx, const std::string& oid,
const std::string& lock,
map<locker_id_t, locker_info_t> *lockers,
ClsLockType *lock_type,
std::string *tag);

Expand Down Expand Up @@ -72,16 +75,16 @@ namespace rados {
}

/* ObjectWriteOperation */
void lock_exclusive(librados::ObjectWriteOperation& ioctx);
void lock_shared(librados::ObjectWriteOperation& ioctx);
void unlock(librados::ObjectWriteOperation& ioctx);
void break_lock(librados::ObjectWriteOperation& ioctx, const entity_name_t& locker);
void lock_exclusive(librados::ObjectWriteOperation *ioctx);
void lock_shared(librados::ObjectWriteOperation *ioctx);
void unlock(librados::ObjectWriteOperation *ioctx);
void break_lock(librados::ObjectWriteOperation *ioctx, const entity_name_t& locker);

/* IoCtx*/
int lock_exclusive(librados::IoCtx& ioctx, const std::string& oid);
int lock_shared(librados::IoCtx& ioctx, const std::string& oid);
int unlock(librados::IoCtx& ioctx, const std::string& oid);
int break_lock(librados::IoCtx& ioctx, const std::string& oid,
int lock_exclusive(librados::IoCtx *ioctx, const std::string& oid);
int lock_shared(librados::IoCtx *ioctx, const std::string& oid);
int unlock(librados::IoCtx *ioctx, const std::string& oid);
int break_lock(librados::IoCtx *ioctx, const std::string& oid,
const entity_name_t& locker);
};

Expand Down
4 changes: 2 additions & 2 deletions src/rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ class RadosBencher : public ObjBencher {

static int do_lock_cmd(std::vector<const char*> &nargs,
const std::map < std::string, std::string > &opts,
IoCtx ioctx,
IoCtx *ioctx,
Formatter *formatter)
{
char buf[128];
Expand Down Expand Up @@ -1958,7 +1958,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
if (!formatter) {
formatter = new JSONFormatter(pretty_format);
}
ret = do_lock_cmd(nargs, opts, io_ctx, formatter);
ret = do_lock_cmd(nargs, opts, &io_ctx, formatter);
} else {
cerr << "unrecognized command " << nargs[0] << std::endl;
usage_exit();
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_gc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int RGWGC::process(int index, int max_secs)
utime_t time(max_secs, 0);
l.set_duration(time);

int ret = l.lock_exclusive(store->gc_pool_ctx, obj_names[index]);
int ret = l.lock_exclusive(&store->gc_pool_ctx, obj_names[index]);
if (ret == -EBUSY) { /* already locked by another gc processor */
dout(0) << "RGWGC::process() failed to acquire lock on " << obj_names[index] << dendl;
return 0;
Expand Down Expand Up @@ -218,7 +218,7 @@ int RGWGC::process(int index, int max_secs)
done:
if (remove_tags.size())
remove(index, remove_tags);
l.unlock(store->gc_pool_ctx, obj_names[index]);
l.unlock(&store->gc_pool_ctx, obj_names[index]);
delete ctx;
return 0;
}
Expand Down
Loading

0 comments on commit b4298fc

Please sign in to comment.