From 21f41c8df058d07ce196902d90b150f6a6347abc Mon Sep 17 00:00:00 2001 From: Xiaoxi CHEN Date: Fri, 19 Jul 2019 08:31:24 -0700 Subject: [PATCH] Client: bump ll_ref from int32 to uint64_t ll_ref can surge up if application repeatly lookup same dentry and finally cause overflow. https://tracker.ceph.com/issues/40775 is an example. in kernel fuse driver and libfuse, uint64_t is used, update ceph-fuse side to match. Fixes: https://tracker.ceph.com/issues/40775 Signed-off-by: Xiaoxi CHEN (cherry picked from commit bb46de885336a8cd2adc9c0507e543c6832346e7) Conflicts: src/client/Client.h use new code, skip all non-toched changes. src/client/Inode.h use new code. --- src/client/Client.cc | 6 +++--- src/client/Client.h | 6 +++--- src/client/Inode.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 5115555ae2163..4c1d92e4a66a8 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -10526,7 +10526,7 @@ void Client::_ll_get(Inode *in) ldout(cct, 20) << __func__ << " " << in << " " << in->ino << " -> " << in->ll_ref << dendl; } -int Client::_ll_put(Inode *in, int num) +int Client::_ll_put(Inode *in, uint64_t num) { in->ll_put(num); ldout(cct, 20) << __func__ << " " << in << " " << in->ino << " " << num << " -> " << in->ll_ref << dendl; @@ -10567,7 +10567,7 @@ void Client::_ll_drop_pins() } } -bool Client::_ll_forget(Inode *in, int count) +bool Client::_ll_forget(Inode *in, uint64_t count) { inodeno_t ino = in->ino; @@ -10596,7 +10596,7 @@ bool Client::_ll_forget(Inode *in, int count) return last; } -bool Client::ll_forget(Inode *in, int count) +bool Client::ll_forget(Inode *in, uint64_t count) { Mutex::Locker lock(client_lock); return _ll_forget(in, count); diff --git a/src/client/Client.h b/src/client/Client.h index 9c75a1c4590ce..9bd77dd90196d 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -755,7 +755,7 @@ private: void _fragmap_remove_stopped_mds(Inode *in, mds_rank_t mds); void _ll_get(Inode *in); - int _ll_put(Inode *in, int num); + int _ll_put(Inode *in, uint64_t num); void _ll_drop_pins(); Fh *_create_fh(Inode *in, int flags, int cmode, const UserPerm& perms); @@ -947,7 +947,7 @@ private: int _lookup_parent(Inode *in, const UserPerm& perms, Inode **parent=NULL); int _lookup_name(Inode *in, Inode *parent, const UserPerm& perms); int _lookup_ino(inodeno_t ino, const UserPerm& perms, Inode **inode=NULL); - bool _ll_forget(Inode *in, int count); + bool _ll_forget(Inode *in, uint64_t count); public: int mount(const std::string &mount_root, const UserPerm& perms, @@ -1149,7 +1149,7 @@ public: int ll_lookupx(Inode *parent, const char *name, Inode **out, struct ceph_statx *stx, unsigned want, unsigned flags, const UserPerm& perms); - bool ll_forget(Inode *in, int count); + bool ll_forget(Inode *in, uint64_t count); bool ll_put(Inode *in); int ll_get_snap_ref(snapid_t snap); diff --git a/src/client/Inode.h b/src/client/Inode.h index ce7b1a6eb6118..f8505c8f96939 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -218,7 +218,7 @@ struct Inode { uint64_t reported_size, wanted_max_size, requested_max_size; int _ref; // ref count. 1 for each dentry, fh that links to me. - int ll_ref; // separate ref count for ll client + uint64_t ll_ref; // separate ref count for ll client xlist dentries; // if i'm linked to a dentry. string symlink; // symlink content, if it's a symlink map xattrs; @@ -246,8 +246,8 @@ struct Inode { void ll_get() { ll_ref++; } - void ll_put(int n=1) { - assert(ll_ref >= n); + void ll_put(uint64_t n=1) { + ceph_assert(ll_ref >= n); ll_ref -= n; } -- 2.47.3