From 0e988edfb6ab9085d6d37cfc444d46e8a2841943 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Tue, 7 Mar 2017 09:48:57 -0500 Subject: [PATCH] rgw_file: fix fs_inst progression Reported by Gui Hecheng. This change is a variation on proposed fix by Dan Gryniewicz to take root_fh.state.dev as fs_inst for new handles. Fixes: http://tracker.ceph.com/issues/19214 Signed-off-by: Matt Benjamin --- src/rgw/rgw_file.cc | 2 +- src/rgw/rgw_file.h | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 2df931dd185f..f1d1ef1649d4 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -37,7 +37,7 @@ namespace rgw { const string RGWFileHandle::root_name = "/"; - atomic RGWLibFS::fs_inst; + atomic RGWLibFS::fs_inst_counter; uint32_t RGWLibFS::write_completion_interval_s = 10; diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 68ae24f0cce2..d5d1626f3d10 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -706,7 +706,8 @@ namespace rgw { RGWUserInfo user; RGWAccessKey key; // XXXX acc_key - static atomic fs_inst; + static atomic fs_inst_counter; + static uint32_t write_completion_interval_s; std::string fsid; @@ -757,6 +758,10 @@ namespace rgw { } } state; + uint32_t new_inst() { + return ++fs_inst_counter; + } + friend class RGWFileHandle; friend class RGWLibProcess; @@ -767,7 +772,7 @@ namespace rgw { RGWLibFS(CephContext* _cct, const char *_uid, const char *_user_id, const char* _key) - : cct(_cct), root_fh(this, get_inst()), invalidate_cb(nullptr), + : cct(_cct), root_fh(this, new_inst()), invalidate_cb(nullptr), invalidate_arg(nullptr), shutdown(false), refcnt(1), fh_cache(cct->_conf->rgw_nfs_fhcache_partitions, cct->_conf->rgw_nfs_fhcache_size), @@ -775,12 +780,9 @@ namespace rgw { cct->_conf->rgw_nfs_lru_lane_hiwat), uid(_uid), key(_user_id, _key) { - /* fixup fs_inst */ - root_fh.state.dev = ++fs_inst; - /* no bucket may be named rgw_fs_inst-(.*) */ fsid = RGWFileHandle::root_name + "rgw_fs_inst-" + - std::to_string(fs_inst); + std::to_string(get_inst()); root_fh.init_rootfs(fsid /* bucket */, RGWFileHandle::root_name); @@ -1088,7 +1090,7 @@ namespace rgw { struct rgw_fs* get_fs() { return &fs; } - uint32_t get_inst() { return fs_inst; } + uint32_t get_inst() { return root_fh.state.dev; } RGWUserInfo* get_user() { return &user; } -- 2.47.3