Skip to content

mds: use shared_ptr for LogSegment#47598

Closed
tshacked wants to merge 4 commits intoceph:mainfrom
tshacked:issue_4744_SP
Closed

mds: use shared_ptr for LogSegment#47598
tshacked wants to merge 4 commits intoceph:mainfrom
tshacked:issue_4744_SP

Conversation

@tshacked
Copy link
Contributor

@tshacked tshacked commented Aug 15, 2022

managing LogSegment* in a shared_ptr, especially for handling cases where
it's being stored for later access.
// e.g.: mut->ls = mds->mdlog->get_current_segment();

Fixes: https://tracker.ceph.com/issues/4744
Signed-off-by: Tamar Shacked tshacked@redhat.com

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

switch to use shared_ptr for LogSegment

Fixes: https://tracker.ceph.com/issues/4744

Signed-off-by: Tamar Shacked <tshacked@redhat.com>
@github-actions github-actions bot added the cephfs Ceph File System label Aug 15, 2022
@tshacked tshacked changed the title mds: switch to use shared_ptr for LogSegment (WIP) mds: use shared_ptr for LogSegment Aug 17, 2022
@tshacked
Copy link
Contributor Author

tshacked commented Aug 17, 2022

General comment:

The typedef for the shared_ptr declare in LogSegment.h: using LogSegmentRef = std::shared_ptr<LogSegment>;
I didn"t find a way to enable forward declaration for it.
So I'd to explicitly use std::shared_ptr<LogSegment> in some of the H files (the ones w/o #include "LogSegment.h")

For example, trying to use LogSegmentRef in CDentry.h resolved in:

../src/mds/CDentry.h:253:20: error: ‘LogSegmentRef’ has not been declared
  253 |   void _mark_dirty(LogSegmentRef& ls);
      |                    ^~~~~~~~~~~~~
``

@lxbsz lxbsz requested review from a team and lxbsz August 17, 2022 12:34
@mchangir
Copy link
Contributor

General comment:

The typedef for the shared_ptr declare in LogSegment.h: using LogSegmentRef = std::shared_ptr<LogSegment>; I didn"t find a way to enable forward declaration for it. So I'd to explicitly use std::shared_ptr<LogSegment> in some of the H files (the ones w/o #include "LogSegment.h")

For example, trying to use LogSegmentRef in CDentry.h resolved in:

../src/mds/CDentry.h:253:20: error: ‘LogSegmentRef’ has not been declared
  253 |   void _mark_dirty(LogSegmentRef& ls);
      |                    ^~~~~~~~~~~~~
``

Since a pointer type can just work with forward declared class/struct types, the LogSegment.h header may not have been included in all the places where LogSegment* is used.

You might have to exhaustively check for those cases and explicitly include the LogSegment.h header to make the LogSegmentRef definition available appropriately.

OR

You'll need to place the using declaration for LogSegmentRef in all files where the LogSegment.h header has not been included explicitly.
eg.

class LogSegment;
using LogSegmentRef = std::shared_ptr<LogSegment>;

this should work in .cc as well as .h files.

@tshacked
Copy link
Contributor Author

tshacked commented Aug 21, 2022

You might have to exhaustively check for those cases and explicitly include the LogSegment.h header to make the LogSegmentRef definition available appropriately.

OR

You'll need to place the using declaration for LogSegmentRef in all files where the LogSegment.h header has not been included explicitly. eg.

class LogSegment;
using LogSegmentRef = std::shared_ptr<LogSegment>;

yes, you are right it's legal to declare the same typedef multiple times..but it may cause maintenance issue.
Yet, my current approach is also kind of duplicating the typedef.
So I think your suggestion is cleaner, I"ll apply it. thanks.

@tshacked tshacked marked this pull request as ready for review August 21, 2022 13:00
Copy link
Contributor

@mchangir mchangir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@vshankar vshankar requested a review from a team August 22, 2022 09:41
Copy link
Contributor

@kotreshhr kotreshhr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit. lgtm otherwise

Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tshacked Genrally, the use of using in header files is considered a bit off-putting.

WDYT?

@tshacked
Copy link
Contributor Author

@tshacked Genrally, the use of using in header files is considered a bit off-putting.

WDYT?

Actually. I wasn't aware of it.
The using keyword here is for getting the typedef-name LogSegmentRef. Is there other alternative?

@gregsfortytwo
Copy link
Member

@tshacked Genrally, the use of using in header files is considered a bit off-putting.

WDYT?

Actually. I wasn't aware of it.

The using keyword here is for getting the typedef-name LogSegmentRef. Is there other alternative?

This is definitely our standard pattern for Ref types AFAIK. We don't like to do an import of the standard library with something like "using namespace std;" but this should be fine. @vshankar

@tshacked tshacked requested a review from batrick August 26, 2022 10:16
@lxbsz
Copy link
Member

lxbsz commented Sep 1, 2022

@tshacked Please add the signed-off-by for all the commits.

@tshacked
Copy link
Contributor Author

tshacked commented Sep 1, 2022

@tshacked Please add the signed-off-by for all the commits.

@lxbsz it is missing in 2 commits which were generated by github when I accepted reviewer suggestions.
Is it not good enough that it appears on the main commit-msg? is it mandatory for each commit?

@vshankar
Copy link
Contributor

vshankar commented Sep 1, 2022

@tshacked Genrally, the use of using in header files is considered a bit off-putting.

WDYT?

Actually. I wasn't aware of it.
The using keyword here is for getting the typedef-name LogSegmentRef. Is there other alternative?

This is definitely our standard pattern for Ref types AFAIK. We don't like to do an import of the standard library with something like "using namespace std;" but this should be fine. @vshankar

(sorry for getting back late on this)

ACK. Makes sense (although it would have been a tiny bit better if we could have possibly use the same convention, but the MDS codebase is a bit weirdly organized :)

@vshankar
Copy link
Contributor

vshankar commented Sep 1, 2022

@tshacked you do plan to squash the commits (some, not all) when this is ready to be QA'd, isn't it?

switch to use shared_ptr for LogSegment* for handling cases where
it's store for later usage. (e.g.: mut->ls = mds->mdlog->get_current_segment(); )

Signed-off-by: Tamar Shacked <tshacked@redhat.com>
Fixes: https://tracker.ceph.com/issues/4744
Signed-off-by: Tamar Shacked <tshacked@redhat.com>
@vshankar
Copy link
Contributor

vshankar commented Oct 4, 2022

jenkins retest this please

@vshankar
Copy link
Contributor

jenkins test make check

@github-actions
Copy link

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions
Copy link

github-actions bot commented Jul 9, 2023

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions bot added the stale label Jul 9, 2023
@github-actions
Copy link

github-actions bot commented Aug 8, 2023

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions bot closed this Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants