osd: Access/Modify epoch maps under mutex in OSDSuperblock class#62916
osd: Access/Modify epoch maps under mutex in OSDSuperblock class#62916NitzanMordhai merged 1 commit intoceph:mainfrom
Conversation
|
jenkins test make check |
25f8c8a to
289631e
Compare
|
jenkins test make check |
|
jenkins test make check |
src/osd/osd_types.h
Outdated
|
|
||
| class OSDSuperblock { | ||
| private: | ||
| mutable std::shared_ptr<std::mutex> map_lock = std::make_shared<std::mutex>(); |
There was a problem hiding this comment.
shared_ptr makes me worried about copy-constructing. Have you tried unique_ptr?
Do we ever copy-construct OSDSuperblock?
There was a problem hiding this comment.
Yes i have tried there are multiple places where we do copy the object.
There was a problem hiding this comment.
Huh, this aggregates the critical sections between all these instances.
There was a problem hiding this comment.
Move the maps to a new class MapContainer and that class is using mutex to get/set the maps.
289631e to
cd06003
Compare
|
jenkins test make check |
rzarzynski
left a comment
There was a problem hiding this comment.
Basically LGTM! Just some nits.
src/osd/osd_types.h
Outdated
| interval_set<epoch_t> maps; | ||
|
|
||
| epoch_t get_oldest_map() const { | ||
| epoch_t _get_newest_map() const { |
There was a problem hiding this comment.
nit: these two methods got flapped got flapped which makes reading the diff a bit harder. Not a blocker, though.
| public: | ||
| MapContainer() = default; | ||
| MapContainer(const MapContainer& other) | ||
| : map_lock(ceph::make_mutex("map_lock")) |
There was a problem hiding this comment.
Hmm, is not giving the name for default-constructed instances intentional?
There was a problem hiding this comment.
I thought it is always recommended to use default instead of declaring empty constructor so i use default, please let me know if you want to change it to empty constructor something like MapContainer () {}.
There was a problem hiding this comment.
Sorry, I'm taking my previous comment back. There is the initializer:
mutable ceph::mutex map_lock = ceph::make_mutex("map_lock");
src/osd/osd_types.h
Outdated
| int32_t whoami = -1; // my role in this fs. | ||
| epoch_t current_epoch = 0; // most recent epoch | ||
| interval_set<epoch_t> maps; // oldest/newest maps we have. | ||
| class MapContainer { |
There was a problem hiding this comment.
nit: MapContainer is a quite general name while the entity is very closely related to OSDSuperblock. How about renaming to OSDSuperblockGuardedMap? Even better clarity might achieved with a nested class (if possible): OSDSuperblock::GuardedMap.
cd06003 to
844e94b
Compare
|
jenkins test make check |
|
There is an FTBFS when building the file for crimson: I think this is rather a trivial issue – most likely the header for |
844e94b to
29fe9f4
Compare
done |
|
jenkins test make check |
src/osd/osd_types.h
Outdated
| #include "common/hobject.h" | ||
| #include "common/snap_types.h" | ||
| #include "common/strtol.h" // for ritoa() | ||
| #include "common/ceph_mutex.h" //To use make_mutex() for crimson |
There was a problem hiding this comment.
nit: I think that the comment is confusing and should be removed. make_mutex is needed for both.
Classic was ok without it because of it being included indirectly (implicitly).
The OSDSuperblock object access/modify epoch maps in multiple threads simultaneously due to that OSD is getting crashed. To avoid the crash access the maps under mutex. Fixes: https://tracker.ceph.com/issues/66819 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
29fe9f4 to
8cf896e
Compare
|
jenkins test make check |
| public: | ||
| MapContainer() = default; | ||
| MapContainer(const MapContainer& other) | ||
| : map_lock(ceph::make_mutex("map_lock")) |
There was a problem hiding this comment.
Sorry, I'm taking my previous comment back. There is the initializer:
mutable ceph::mutex map_lock = ceph::make_mutex("map_lock");backport tracker: https://tracker.ceph.com/issues/72070 backport of ceph#62916 parent tracker: https://tracker.ceph.com/issues/66819 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
backport tracker: https://tracker.ceph.com/issues/72070 backport of ceph#62916 parent tracker: https://tracker.ceph.com/issues/66819 (cherry picked from commit 8cf896e) Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
backport tracker: https://tracker.ceph.com/issues/72070 backport of ceph#62916 parent tracker: https://tracker.ceph.com/issues/66819 (cherry picked from commit 8cf896e) Signed-off-by: Mohit Agrawal <moagrawa@redhat.com> (cherry picked from commit 1fdf9cd) Resolves: rhbz#2417015
backport tracker: https://tracker.ceph.com/issues/72070 backport of ceph#62916 parent tracker: https://tracker.ceph.com/issues/66819 (cherry picked from commit 8cf896e) Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
The OSDSuperblock object access/modify epoch maps in multiple threads simultaneously due to that OSD is getting crashed. To avoid the crash access the maps under mutex.
Fixes: https://tracker.ceph.com/issues/66819
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job Definition