From 00b2edee8700f1c014cca7faee5bbe8a67e7c6bb Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 25 Sep 2015 20:49:27 +0800 Subject: [PATCH] client: cleanup 'fuse_req' parameter of ll_setlk/ll_flock fuse request is tracked in thread local data, no need to pass it to ll_setlk/ll_flock Signed-off-by: Yan, Zheng --- src/client/Client.cc | 26 +++++++++++++------------- src/client/Client.h | 12 ++++++------ src/client/fuse_ll.cc | 13 ++++++++----- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 5324c4881ab62..f93936113a446 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6318,7 +6318,7 @@ int Client::flock(int fd, int operation, uint64_t owner) if (!f) return -EBADF; - return _flock(f, operation, owner, NULL); + return _flock(f, operation, owner); } int Client::opendir(const char *relpath, dir_result_t **dirpp) @@ -8316,7 +8316,7 @@ int Client::statfs(const char *path, struct statvfs *stbuf) } int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep, - struct flock *fl, uint64_t owner, void *fuse_req) + struct flock *fl, uint64_t owner) { ldout(cct, 10) << "_do_filelock ino " << in->ino << (lock_type == CEPH_LOCK_FCNTL ? " fcntl" : " flock") @@ -8360,14 +8360,14 @@ int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep, int ret; bufferlist bl; - if (sleep && switch_interrupt_cb && fuse_req) { + if (sleep && switch_interrupt_cb) { // enable interrupt - switch_interrupt_cb(fuse_req, req->get()); + switch_interrupt_cb(callback_handle, req->get()); ret = make_request(req, -1, -1, NULL, NULL, -1, &bl); // disable interrupt - switch_interrupt_cb(fuse_req, NULL); + switch_interrupt_cb(callback_handle, NULL); put_request(req); } else { ret = make_request(req, -1, -1, NULL, NULL, -1, &bl); @@ -8561,16 +8561,16 @@ int Client::_getlk(Fh *fh, struct flock *fl, uint64_t owner) return ret; } -int Client::_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep, void *fuse_req) +int Client::_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep) { Inode *in = fh->inode.get(); ldout(cct, 10) << "_setlk " << fh << " ino " << in->ino << dendl; - int ret = _do_filelock(in, fh, CEPH_LOCK_FCNTL, CEPH_MDS_OP_SETFILELOCK, sleep, fl, owner, fuse_req); + int ret = _do_filelock(in, fh, CEPH_LOCK_FCNTL, CEPH_MDS_OP_SETFILELOCK, sleep, fl, owner); ldout(cct, 10) << "_setlk " << fh << " ino " << in->ino << " result=" << ret << dendl; return ret; } -int Client::_flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req) +int Client::_flock(Fh *fh, int cmd, uint64_t owner) { Inode *in = fh->inode.get(); ldout(cct, 10) << "_flock " << fh << " ino " << in->ino << dendl; @@ -8598,7 +8598,7 @@ int Client::_flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req) fl.l_type = type; fl.l_whence = SEEK_SET; - int ret = _do_filelock(in, fh, CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK, sleep, &fl, owner, fuse_req); + int ret = _do_filelock(in, fh, CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK, sleep, &fl, owner); ldout(cct, 10) << "_flock " << fh << " ino " << in->ino << " result=" << ret << dendl; return ret; } @@ -11003,24 +11003,24 @@ int Client::ll_getlk(Fh *fh, struct flock *fl, uint64_t owner) return _getlk(fh, fl, owner); } -int Client::ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep, void *fuse_req) +int Client::ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep) { Mutex::Locker lock(client_lock); ldout(cct, 3) << "ll_setlk (fh) " << fh << " " << fh->inode->ino << dendl; tout(cct) << "ll_setk (fh)" << (unsigned long)fh << std::endl; - return _setlk(fh, fl, owner, sleep, fuse_req); + return _setlk(fh, fl, owner, sleep); } -int Client::ll_flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req) +int Client::ll_flock(Fh *fh, int cmd, uint64_t owner) { Mutex::Locker lock(client_lock); ldout(cct, 3) << "ll_flock (fh) " << fh << " " << fh->inode->ino << dendl; tout(cct) << "ll_flock (fh)" << (unsigned long)fh << std::endl; - return _flock(fh, cmd, owner, fuse_req); + return _flock(fh, cmd, owner); } class C_Client_RequestInterrupt : public Context { diff --git a/src/client/Client.h b/src/client/Client.h index 4323922ce0f4b..c684ecd9ce334 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -141,7 +141,7 @@ typedef void (*client_dentry_callback_t)(void *handle, vinodeno_t dirino, typedef int (*client_remount_callback_t)(void *handle); typedef int (*client_getgroups_callback_t)(void *handle, uid_t uid, gid_t **sgids); -typedef void(*client_switch_interrupt_callback_t)(void *req, void *data); +typedef void(*client_switch_interrupt_callback_t)(void *handle, void *data); struct client_callback_args { void *handle; @@ -745,8 +745,8 @@ private: int _sync_fs(); int _fallocate(Fh *fh, int mode, int64_t offset, int64_t length); int _getlk(Fh *fh, struct flock *fl, uint64_t owner); - int _setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep, void *fuse_req=NULL); - int _flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req=NULL); + int _setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep); + int _flock(Fh *fh, int cmd, uint64_t owner); int get_or_create(Inode *dir, const char* name, Dentry **pdn, bool expect_null=false); @@ -839,7 +839,7 @@ private: } int _do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep, - struct flock *fl, uint64_t owner, void *fuse_req=NULL); + struct flock *fl, uint64_t owner); int _interrupt_filelock(MetaRequest *req); void _encode_filelocks(Inode *in, bufferlist& bl); void _release_filelocks(Fh *fh); @@ -1070,8 +1070,8 @@ public: int ll_fallocate(Fh *fh, int mode, loff_t offset, loff_t length); int ll_release(Fh *fh); int ll_getlk(Fh *fh, struct flock *fl, uint64_t owner); - int ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep, void *fuse_req); - int ll_flock(Fh *fh, int cmd, uint64_t owner, void *fuse_req); + int ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep); + int ll_flock(Fh *fh, int cmd, uint64_t owner); int ll_file_layout(Fh *fh, ceph_file_layout *layout); void ll_interrupt(void *d); int ll_get_stripe_osd(struct Inode *in, uint64_t blockno, diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 32ef99841e492..b2e3d3daa705c 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -698,7 +698,7 @@ static void fuse_ll_setlk(fuse_req_t req, fuse_ino_t ino, return; } - int r = cfuse->client->ll_setlk(fh, lock, fi->lock_owner, sleep, req); + int r = cfuse->client->ll_setlk(fh, lock, fi->lock_owner, sleep); fuse_reply_err(req, -r); } @@ -708,12 +708,15 @@ static void fuse_ll_interrupt(fuse_req_t req, void* data) cfuse->client->ll_interrupt(data); } -static void switch_interrupt_cb(void *req, void* data) +static void switch_interrupt_cb(void *handle, void* data) { + CephFuse::Handle *cfuse = (CephFuse::Handle *)handle; + fuse_req_t req = cfuse->get_fuse_req(); + if (data) - fuse_req_interrupt_func((fuse_req_t)req, fuse_ll_interrupt, data); + fuse_req_interrupt_func(req, fuse_ll_interrupt, data); else - fuse_req_interrupt_func((fuse_req_t)req, NULL, NULL); + fuse_req_interrupt_func(req, NULL, NULL); } #if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 9) @@ -730,7 +733,7 @@ static void fuse_ll_flock(fuse_req_t req, fuse_ino_t ino, return; } - int r = cfuse->client->ll_flock(fh, cmd, fi->lock_owner, req); + int r = cfuse->client->ll_flock(fh, cmd, fi->lock_owner); fuse_reply_err(req, -r); } #endif -- 2.39.5