mds: add ref counting to LogSegment#62554
Conversation
59e5177 to
9751c70
Compare
src/mds/MDLog.h
Outdated
| class LogSegment; | ||
| class ESubtreeMap; | ||
|
|
||
| using LogSegmentRef = boost::intrusive_ptr<LogSegment>; |
There was a problem hiding this comment.
Ugh.. where are intrusive_ptr_add_ref and intrusive_ptr_release implemented? o_O
There was a problem hiding this comment.
Oh I see, LogSegment is a subclass of RefCountedObject. Interesting.
src/mds/CDir.h
Outdated
| class MDCache; | ||
| class LogSegment; | ||
|
|
||
| using LogSegmentRef = boost::intrusive_ptr<LogSegment>; |
There was a problem hiding this comment.
Generally, using using keyword is discouraged in header files, especially when its done outside the scope of the class itself (CDir in this case).
There was a problem hiding this comment.
I'll move all such instances inside the class definitions.
There was a problem hiding this comment.
- rebased
- moved
using LogSegmentRef =inside class definitions
9751c70 to
6f68417
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
6f68417 to
a862e7c
Compare
a862e7c to
fffa4d9
Compare
|
rebased |
fffa4d9 to
4403702
Compare
|
Note: PR has been revised completely |
src/mds/MDCache.cc
Outdated
| adjust_subtree_auth(mydir, mds->get_nodeid()); | ||
|
|
||
| LogSegment *ls = mds->mdlog->get_current_segment(); | ||
| std::shared_ptr<LogSegment> &ls = mds->mdlog->get_current_segment(); |
There was a problem hiding this comment.
| std::shared_ptr<LogSegment> &ls = mds->mdlog->get_current_segment(); | |
| auto&& ls = mds->mdlog->get_current_segment(); |
is more robust. I'd also like to see:
using LogSegmentRef = std::shared_ptr<LogSegment>;
in the headers.
There was a problem hiding this comment.
OK, I had advised @mchangir to not use using keyword in headers. I see now, this is being done via a new header as per #62554 (comment)
There was a problem hiding this comment.
So, it looks like using in header is fine iff it's a separate header and this header is only included in cc source, yes?
There was a problem hiding this comment.
Following are the headers in which LogSegmentRef.h is included:
src/mds/CDentry.h:#include "LogSegmentRef.h"
src/mds/CDir.h:#include "LogSegmentRef.h"
src/mds/CInode.h:#include "LogSegmentRef.h"
src/mds/LogEvent.h:#include "LogSegmentRef.h"
src/mds/MDCache.h:#include "LogSegmentRef.h"
src/mds/MDLog.h:#include "LogSegmentRef.h"
src/mds/MDSTableClient.h:#include "LogSegmentRef.h"
src/mds/Migrator.h:#include "LogSegmentRef.h"
src/mds/Mutation.h:#include "LogSegmentRef.h"
src/mds/Server.h:#include "LogSegmentRef.h"
src/mds/events/EMetaBlob.h:#include "../LogSegmentRef.h"
as class function prototypes also make a reference to LogSegmentRef ... otherwise the compiler will spew errors about undefined symbols.
There was a problem hiding this comment.
or, maybe include LogSegmentRef.h in the .cc before any other header included in the .cc makes a reference to LogSegmentRef ?
There was a problem hiding this comment.
I think as long as you include LogSegmentRef.h in LogSegment.h, you can avoid explicitly including it in most of those .cc files. You only need the separate header for places where you do not want to include LogSegment.h for circular dependency reasons.
There was a problem hiding this comment.
There's not many files that both LogSegment.h and LogSegmentRef.h get included. Here's the list:
$ git grep -E 'LogSegment\.h'
src/mds/CDentry.cc:#include "LogSegment.h"
src/mds/CDir.cc:#include "LogSegment.h"
src/mds/CInode.cc:#include "LogSegment.h"
src/mds/MDLog.h:#include "LogSegment.h"
src/mds/MDSTableClient.cc:#include "LogSegment.h"
src/mds/SegmentBoundary.h:#include "LogSegment.h"
src/mds/events/EMetaBlob.h:#include "../LogSegment.h"
src/mds/journal.cc:#include "LogSegment.h"
$ git grep -E 'LogSegmentRef\.h'
src/mds/CDentry.h:#include "LogSegmentRef.h"
src/mds/CDir.h:#include "LogSegmentRef.h"
src/mds/CInode.h:#include "LogSegmentRef.h"
src/mds/LogEvent.h:#include "LogSegmentRef.h"
src/mds/MDCache.h:#include "LogSegmentRef.h"
src/mds/MDLog.h:#include "LogSegmentRef.h"
src/mds/MDSTableClient.h:#include "LogSegmentRef.h"
src/mds/Migrator.h:#include "LogSegmentRef.h"
src/mds/Mutation.h:#include "LogSegmentRef.h"
src/mds/Server.h:#include "LogSegmentRef.h"
src/mds/events/EMetaBlob.h:#include "../LogSegmentRef.h"
src/mds/journal.cc:#include "LogSegmentRef.h"
so the only common files among two lists are:
src/mds/MDLog.h
src/mds/events/EMetaBlob.h
src/mds/journal.cc
I've mostly included LogSegmentRef.h in files where there was no reference to LogSegment.h. I haven't tested what happens if I include LogSegmentRef.h via LogSegment.h.
4403702 to
959d2e2
Compare
959d2e2 to
3154072
Compare
src/mds/events/EMetaBlob.h
Outdated
| * | ||
| */ | ||
|
|
||
| using LogSegmentRef = std::shared_ptr<LogSegment>; |
There was a problem hiding this comment.
Create a new header file mds/LogSegmentRef.h which is just:
<copyright>
#pragma once
class LogSegment;
using LogSegmentRef = std::shared_ptr<LogSegment>;
There was a problem hiding this comment.
should this header be included in all the files that has using LogSegmentRef = defined and replace this declaration ?
There was a problem hiding this comment.
@mchangir I think you forgot to stage the LogSegmentRef.h header.
There was a problem hiding this comment.
thanks for taking a look ... I've now included LogSegmentRef.h in the commit.
3154072 to
a51b170
Compare
Fixes: https://tracker.ceph.com/issues/70723 Signed-off-by: Milind Changire <mchangir@redhat.com>
a51b170 to
fe3b415
Compare
|
This PR is under test in https://tracker.ceph.com/issues/72210. |
Fixes: https://tracker.ceph.com/issues/70723
Signed-off-by: Milind Changire mchangir@redhat.com
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