From: Xiubo Li Date: Thu, 18 Mar 2021 01:01:26 +0000 (+0800) Subject: client: cleanup _preadv_pwritev_locked() X-Git-Tag: v17.1.0~2324^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bfa955f7bf089f5ca5e26231773992b968607597;p=ceph.git client: cleanup _preadv_pwritev_locked() Remove the lock parameter. Signed-off-by: Xiubo Li --- diff --git a/src/client/Client.cc b/src/client/Client.cc index ab34dcef19413..bf765a9042814 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -10018,9 +10018,11 @@ int Client::pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset) } int64_t Client::_preadv_pwritev_locked(Fh *fh, const struct iovec *iov, - unsigned iovcnt, int64_t offset, bool write, - bool clamp_to_int, std::unique_lock &cl) + unsigned iovcnt, int64_t offset, + bool write, bool clamp_to_int) { + ceph_assert(ceph_mutex_is_locked_by_me(client_lock)); + #if defined(__linux__) && defined(O_PATH) if (fh->flags & O_PATH) return -CEPHFS_EBADF; @@ -10049,7 +10051,7 @@ int64_t Client::_preadv_pwritev_locked(Fh *fh, const struct iovec *iov, if (r <= 0) return r; - cl.unlock(); + client_lock.unlock(); auto iter = bl.cbegin(); for (unsigned j = 0, resid = r; j < iovcnt && resid > 0; j++) { /* @@ -10061,7 +10063,7 @@ int64_t Client::_preadv_pwritev_locked(Fh *fh, const struct iovec *iov, resid -= round_size; /* iter is self-updating */ } - cl.lock(); + client_lock.lock(); return r; } } @@ -10075,11 +10077,11 @@ int Client::_preadv_pwritev(int fd, const struct iovec *iov, unsigned iovcnt, in tout(cct) << fd << std::endl; tout(cct) << offset << std::endl; - std::unique_lock cl(client_lock); + std::scoped_lock cl(client_lock); Fh *fh = get_filehandle(fd); if (!fh) return -CEPHFS_EBADF; - return _preadv_pwritev_locked(fh, iov, iovcnt, offset, write, true, cl); + return _preadv_pwritev_locked(fh, iov, iovcnt, offset, write, true); } int64_t Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf, @@ -14157,8 +14159,8 @@ int64_t Client::ll_writev(struct Fh *fh, const struct iovec *iov, int iovcnt, in if (!mref_reader.is_state_satisfied()) return -CEPHFS_ENOTCONN; - std::unique_lock cl(client_lock); - return _preadv_pwritev_locked(fh, iov, iovcnt, off, true, false, cl); + std::scoped_lock cl(client_lock); + return _preadv_pwritev_locked(fh, iov, iovcnt, off, true, false); } int64_t Client::ll_readv(struct Fh *fh, const struct iovec *iov, int iovcnt, int64_t off) @@ -14167,8 +14169,8 @@ int64_t Client::ll_readv(struct Fh *fh, const struct iovec *iov, int iovcnt, int if (!mref_reader.is_state_satisfied()) return -CEPHFS_ENOTCONN; - std::unique_lock cl(client_lock); - return _preadv_pwritev_locked(fh, iov, iovcnt, off, false, false, cl); + std::scoped_lock cl(client_lock); + return _preadv_pwritev_locked(fh, iov, iovcnt, off, false, false); } int Client::ll_flush(Fh *fh) diff --git a/src/client/Client.h b/src/client/Client.h index 5414cdb95dd62..16949aed37507 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1320,9 +1320,9 @@ private: const struct iovec *iov, int iovcnt); int64_t _preadv_pwritev_locked(Fh *fh, const struct iovec *iov, unsigned iovcnt, int64_t offset, - bool write, bool clamp_to_int, - std::unique_lock &cl); - int _preadv_pwritev(int fd, const struct iovec *iov, unsigned iovcnt, int64_t offset, bool write); + bool write, bool clamp_to_int); + int _preadv_pwritev(int fd, const struct iovec *iov, unsigned iovcnt, + int64_t offset, bool write); int _flush(Fh *fh); int _fsync(Fh *fh, bool syncdataonly); int _fsync(Inode *in, bool syncdataonly);