librados: Add RADOS locks to the C/C++ API
v2 cover librados: Add RADOS locks to the C/C++ API
Hi team,
This set of patches export the RADOS advisory locking functionality to the C/C++ API.
They have been refactored to incorporate Josh suggestions from his review:
* Always set tag to "" for exclusive lock
* Add duration argument to lock_{exclusive, shared}
* Add lock flags to librados.h
* Return -EINVAL on client parsing error
* Remove unneeded std::string convertions
* Typos/style fixes
Kind Regards,
Filippos
Filippos Giannakos (2):
Add RADOS lock mechanism to the librados C/C++ API. Add RADOS API lock tests
src/Makefile.am | 11 +- src/include/rados/librados.h | 102 +++++++++++++- src/include/rados/librados.hpp | 29 ++++ src/librados/librados.cc | 180 ++++++++++++++++++++++++ src/test/librados/lock.cc | 301 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 621 insertions(+), 2 deletions(-) create mode 100644 src/test/librados/lock.cc
Signature · 1 line
1.7.10.4
PATCH v2 1/2 Add RADOS lock mechanism to the librados C/C++ API.
Add functions to the librados C/C++ API, to take advantage and utilize the advisory locking system offered by RADOS.
--- src/Makefile.am | 5 +- src/include/rados/librados.h | 102 ++++++++++++++++++++++- src/include/rados/librados.hpp | 29 +++++++ src/librados/librados.cc | 180 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 314 insertions(+), 2 deletions(-)
src/Makefile.am +4 -1
@@ -357,7 +357,10 @@ librados_SOURCES = \ librados/RadosClient.cc \ librados/IoCtxImpl.cc \ osdc/Objecter.cc \ - osdc/Striper.cc + osdc/Striper.cc \ + cls/lock/cls_lock_client.cc \ + cls/lock/cls_lock_types.cc \ + cls/lock/cls_lock_ops.cc librados_la_SOURCES = ${librados_SOURCES} librados_la_CFLAGS = ${CRYPTO_CFLAGS} ${AM_CFLAGS} librados_la_CXXFLAGS = ${AM_CXXFLAGS}
src/include/rados/librados.h +101 -1
120 lines not on this page · raw message
src/include/rados/librados.hpp +29 -0
@@ -47,6 +47,12 @@ namespace librados uint64_t num_rd, num_rd_kb, num_wr, num_wr_kb; }; + typedef struct { + std::string client; + std::string cookie; + std::string address; + } locker_t; + typedef std::map<std::string, pool_stat_t> stats_map; typedef void *completion_t;
@@ -488,6 +494,29 @@ namespace librados int selfmanaged_snap_rollback(const std::string& oid, uint64_t snapid); + // Advisory locking on rados objects. + int lock_exclusive(const std::string &oid, const std::string &name, + const std::string &cookie, + const std::string &description, + struct timeval * duration, uint8_t flags); + + int lock_shared(const std::string &oid, const std::string &name, + const std::string &cookie, const std::string &tag, + const std::string &description, + struct timeval * duration, uint8_t flags); + + int unlock(const std::string &oid, const std::string &name, + const std::string &cookie); + + int break_lock(const std::string &oid, const std::string &name, + const std::string &client, const std::string &cookie); + + int list_lockers(const std::string &oid, const std::string &name, + int *exclusive, + std::string *tag, + std::list<librados::locker_t> *lockers); + + ObjectIterator objects_begin(); const ObjectIterator& objects_end() const;
src/librados/librados.cc +180 -0
200 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 2/2 Add RADOS API lock tests
In reply to Filippos GiannakosAdd tests for the advisory locking API calls.
--- src/Makefile.am | 6 + src/test/librados/lock.cc | 301 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+) create mode 100644 src/test/librados/lock.cc
src/Makefile.am +6 -0
@@ -1015,6 +1015,12 @@ ceph_test_rados_api_misc_LDADD = librados.la ${UNITTEST_STATIC_LDADD} ceph_test_rados_api_misc_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} bin_DEBUGPROGRAMS += ceph_test_rados_api_misc +ceph_test_rados_api_lock_SOURCES = test/librados/lock.cc test/librados/test.cc +ceph_test_rados_api_lock_LDFLAGS = ${AM_LDFLAGS} +ceph_test_rados_api_lock_LDADD = librados.la ${UNITTEST_STATIC_LDADD} +ceph_test_rados_api_lock_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} +bin_DEBUGPROGRAMS += ceph_test_rados_api_lock + ceph_test_libcephfs_SOURCES = test/libcephfs/test.cc test/libcephfs/readdir_r_cb.cc test/libcephfs/caps.cc ceph_test_libcephfs_LDFLAGS = $(PTHREAD_CFLAGS) ${AM_LDFLAGS} ceph_test_libcephfs_LDADD = ${UNITTEST_STATIC_LDADD} libcephfs.la
src/test/librados/lock.cc new file +301 -0
301 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Josh Durgin
AppliedQuoted 19 lines · Filippos Giannakos
Hi team,
This set of patches export the RADOS advisory locking functionality to the C/C++ API.
They have been refactored to incorporate Josh suggestions from his review:
* Always set tag to "" for exclusive lock
* Add duration argument to lock_{exclusive, shared}
* Add lock flags tolibrados.h
* Return-EINVALon client parsing error
* Remove unneededstd::stringconvertions
* Typos/style fixesKind Regards,
FilipposFilippos Giannakos (2):
Add RADOS lock mechanism to the librados C/C++ API. Add RADOS API lock tests
Quoted 8 lines
src/Makefile.am | 11 +- src/include/rados/librados.h | 102 +++++++++++++- src/include/rados/librados.hpp | 29 ++++ src/librados/librados.cc | 180 ++++++++++++++++++++++++ src/test/librados/lock.cc | 301 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 621 insertions(+), 2 deletions(-)create mode 100644 src/test/librados/lock.cc
Applied, thanks!
Josh