mirror of
https://github.com/ceph/ceph
synced 2024-12-19 01:46:00 +00:00
client: use atomic variable to track reference of MetaRequeset
this allow us to increase reference count of MetaRequest while not holding the client_lock Signed-off-by: Yan, Zheng <zyan@redhat.com>
This commit is contained in:
parent
4134c149d3
commit
e464a77652
@ -1487,15 +1487,15 @@ int Client::make_request(MetaRequest *request,
|
||||
|
||||
void Client::put_request(MetaRequest *request)
|
||||
{
|
||||
if (request->get_num_ref() == 1) {
|
||||
if (request->_put()) {
|
||||
if (request->inode())
|
||||
put_inode(request->take_inode());
|
||||
if (request->old_inode())
|
||||
put_inode(request->take_old_inode());
|
||||
if (request->other_inode())
|
||||
put_inode(request->take_other_inode());
|
||||
delete request;
|
||||
}
|
||||
request->_put();
|
||||
}
|
||||
|
||||
int Client::encode_inode_release(Inode *in, MetaRequest *req,
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "msg/msg_types.h"
|
||||
#include "include/xlist.h"
|
||||
#include "include/filepath.h"
|
||||
#include "include/atomic.h"
|
||||
#include "mds/mdstypes.h"
|
||||
|
||||
#include "common/Mutex.h"
|
||||
@ -48,7 +49,7 @@ public:
|
||||
__u32 sent_on_mseq; // mseq at last submission of this request
|
||||
int num_fwd; // # of times i've been forwarded
|
||||
int retry_attempt;
|
||||
int ref;
|
||||
atomic_t ref;
|
||||
|
||||
MClientReply *reply; // the reply
|
||||
bool kick;
|
||||
@ -127,17 +128,14 @@ public:
|
||||
Dentry *old_dentry();
|
||||
|
||||
MetaRequest* get() {
|
||||
++ref;
|
||||
ref.inc();
|
||||
return this;
|
||||
}
|
||||
|
||||
/// psuedo-private put method; use Client::put_request()
|
||||
void _put() {
|
||||
if (--ref == 0)
|
||||
delete this;
|
||||
}
|
||||
int get_num_ref() {
|
||||
return ref;
|
||||
bool _put() {
|
||||
int v = ref.dec();
|
||||
return v == 0;
|
||||
}
|
||||
|
||||
// normal fields
|
||||
|
Loading…
Reference in New Issue
Block a user