ceph_lock_state_t *lock_state;
if (lock_type == CEPH_LOCK_FCNTL) {
if (!in->fcntl_locks)
- in->fcntl_locks = new ceph_lock_state_t(cct, CEPH_LOCK_FCNTL);
- lock_state = in->fcntl_locks;
+ in->fcntl_locks.reset(new ceph_lock_state_t(cct, CEPH_LOCK_FCNTL));
+ lock_state = in->fcntl_locks.get();
} else if (lock_type == CEPH_LOCK_FLOCK) {
if (!in->flock_locks)
- in->flock_locks = new ceph_lock_state_t(cct, CEPH_LOCK_FLOCK);
- lock_state = in->flock_locks;
+ in->flock_locks.reset(new ceph_lock_state_t(cct, CEPH_LOCK_FLOCK));
+ lock_state = in->flock_locks.get();
} else {
ceph_abort();
return -EINVAL;
if (!removing) {
if (lock_type == CEPH_LOCK_FCNTL) {
if (!fh->fcntl_locks)
- fh->fcntl_locks = new ceph_lock_state_t(cct, CEPH_LOCK_FCNTL);
- lock_state = fh->fcntl_locks;
+ fh->fcntl_locks.reset(new ceph_lock_state_t(cct, CEPH_LOCK_FCNTL));
+ lock_state = fh->fcntl_locks.get();
} else {
if (!fh->flock_locks)
- fh->flock_locks = new ceph_lock_state_t(cct, CEPH_LOCK_FLOCK);
- lock_state = fh->flock_locks;
+ fh->flock_locks.reset(new ceph_lock_state_t(cct, CEPH_LOCK_FLOCK));
+ lock_state = fh->flock_locks.get();
}
_update_lock_state(fl, owner, lock_state);
}
unsigned nr_fcntl_locks = in->fcntl_locks ? in->fcntl_locks->held_locks.size() : 0;
::encode(nr_fcntl_locks, bl);
if (nr_fcntl_locks) {
- ceph_lock_state_t* lock_state = in->fcntl_locks;
+ auto &lock_state = in->fcntl_locks;
for(multimap<uint64_t, ceph_filelock>::iterator p = lock_state->held_locks.begin();
p != lock_state->held_locks.end();
++p)
unsigned nr_flock_locks = in->flock_locks ? in->flock_locks->held_locks.size() : 0;
::encode(nr_flock_locks, bl);
if (nr_flock_locks) {
- ceph_lock_state_t* lock_state = in->flock_locks;
+ auto &lock_state = in->flock_locks;
for(multimap<uint64_t, ceph_filelock>::iterator p = lock_state->held_locks.begin();
p != lock_state->held_locks.end();
++p)
list<pair<int, ceph_filelock> > to_release;
if (fh->fcntl_locks) {
- ceph_lock_state_t* lock_state = fh->fcntl_locks;
+ auto &lock_state = fh->fcntl_locks;
for(multimap<uint64_t, ceph_filelock>::iterator p = lock_state->held_locks.begin();
p != lock_state->held_locks.end();
++p)
to_release.push_back(pair<int, ceph_filelock>(CEPH_LOCK_FCNTL, p->second));
- delete fh->fcntl_locks;
+ lock_state.reset();
}
if (fh->flock_locks) {
- ceph_lock_state_t* lock_state = fh->flock_locks;
+ auto &lock_state = fh->flock_locks;
for(multimap<uint64_t, ceph_filelock>::iterator p = lock_state->held_locks.begin();
p != lock_state->held_locks.end();
++p)
to_release.push_back(pair<int, ceph_filelock>(CEPH_LOCK_FLOCK, p->second));
- delete fh->flock_locks;
+ lock_state.reset();
}
if (to_release.empty())
#include "include/types.h"
#include "InodeRef.h"
#include "UserPerm.h"
+#include "mds/flock.h"
class Cond;
-class ceph_lock_state_t;
class Inode;
// file handle for any open file state
Readahead readahead;
// file lock
- ceph_lock_state_t *fcntl_locks;
- ceph_lock_state_t *flock_locks;
+ std::unique_ptr<ceph_lock_state_t> fcntl_locks;
+ std::unique_ptr<ceph_lock_state_t> flock_locks;
// IO error encountered by any writeback on this Inode while
// this Fh existed (i.e. an fsync on another Fh will still show
async_err = 0;
return e;
}
-
+
Fh() = delete;
Fh(InodeRef in, int flags, int cmode, const UserPerm &perms);
~Fh();
+
void get() { ++_ref; }
int put() { return --_ref; }
};
#include "include/types.h"
#include "include/xlist.h"
+#include "mds/flock.h"
#include "mds/mdstypes.h" // hrm
#include "osdc/ObjectCacher.h"
class Dir;
struct SnapRealm;
struct Inode;
-class ceph_lock_state_t;
class MetaRequest;
class filepath;
class Fh;
}
// file locks
- ceph_lock_state_t *fcntl_locks;
- ceph_lock_state_t *flock_locks;
+ std::unique_ptr<ceph_lock_state_t> fcntl_locks;
+ std::unique_ptr<ceph_lock_state_t> flock_locks;
xlist<MetaRequest*> unsafe_ops;
snaprealm(0), snaprealm_item(this),
oset((void *)this, newlayout->pool_id, this->ino),
reported_size(0), wanted_max_size(0), requested_max_size(0),
- _ref(0), ll_ref(0), dn_set(),
- fcntl_locks(NULL), flock_locks(NULL)
+ _ref(0), ll_ref(0), dn_set()
{
memset(&dir_layout, 0, sizeof(dir_layout));
memset("a, 0, sizeof(quota));