Skip to content

os/bluestore: expand BlueFS log if available space is insufficient - #50216

Merged
yuriw merged 2 commits into
ceph:mainfrom
rhcs-dashboard:log-runway
Aug 22, 2023
Merged

yuriw merged 2 commits into
ceph:mainfrom
rhcs-dashboard:log-runway

Conversation

@pereman2

@pereman2 pereman2 commented Feb 23, 2023 •

Copy link
Copy Markdown
Contributor

With these changes, every call to log compaction will try to expand its runway in case of insufficient log space. async compaction will ignore the log_forbidden_to_expand atomic since we know it should't be harmful. In any other case, expansion of log will wait until compaction is completed.

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

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

@pereman2

Copy link
Copy Markdown
Contributor Author

@aclamk hey can you review this. I want add meaningful tests but I wanted to have a quick review whether this code is correct or missing a point.

Comment thread src/os/bluestore/BlueFS.cc Resolved
@pereman2

Copy link
Copy Markdown
Contributor Author

Currently this is failing on _replay when compaction wasn't previously done. It reads less bytes than the block size in _replay because of the new layout.

Comment thread src/os/bluestore/BlueFS.cc Resolved

@aclamk aclamk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The concept is sound, but still some problems.
The attached test is insufficient to prove that solution works.

Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/test/objectstore/test_bluefs.cc Resolved
Comment thread src/test/objectstore/test_bluefs.cc Resolved

@aclamk aclamk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Needs fixups.

Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved

@aclamk aclamk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Needs fixes.

Comment thread src/os/bluestore/BlueFS.cc Outdated
Comment on lines 2729 to 2750

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move this block below checking if we already started compaction.
It does not have to be here, and return will leave log.lock still locked.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I prefer unlocking on return so we don't have to add a flag to maybe_extend_log. Extending the log will block if log_forbidden_to_expand is true which would always be the case after a successful atomic_exchange.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Honestly I don't understand the above point. Personally I'd prefer setting log_is_compacting prior to log.lock acquisition and maybe_extent_log() call too.
@pereman2 - could you please elaborate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The idea of extending the log before starting compaction is because extending the log will wait until compaction is finished, but since you could set log_is_compacting to true before the _maybe_extend_log call, that would run an infinite loop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm... not that answering this question is important but mostly out of curiosity...

I'm talking about reordering the current code in the following way:

  // only one compaction allowed at one time
  bool old_is_comp = std::atomic_exchange(&log_is_compacting, true);
  if (old_is_comp) {
    dout(10) << __func__ << " ongoing" <<dendl;
    log.lock.unlock();
    return;
  }

 // lock log's run-time structures for a while
  log.lock.lock();

  // Extend log in case of having a big transaction waiting before starting compaction.
  _maybe_extend_log();

IIUC _maybe_extent_log() doesn't access log_is_compacting flag in any way. I can see waiting on log_forbidden_to_expand but not on log_is_compacting. So how this rearrangement would cause any infinite loop?
By setting the flag a bit earlier we just indicate to others that compaction is running (or will happen after maybe_extend_log). So they don't need to run it at that moment. Suggested reordering just extends that gap when other compactions are forbidden.

Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
@github-actions

Copy link
Copy Markdown

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

Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved

@pereman2 pereman2 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ooops I left some comments behind from the last time I checked. My bad.

Comment thread src/os/bluestore/BlueFS.cc Outdated
Comment on lines 2729 to 2750

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I prefer unlocking on return so we don't have to add a flag to maybe_extend_log. Extending the log will block if log_forbidden_to_expand is true which would always be the case after a successful atomic_exchange.

Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved

@pereman2 pereman2 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ooops I left some comments behind from the last time I checked. My bad.

@pereman2 pereman2 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ooops I left some comments behind from the last time I checked. My bad.

Comment thread src/os/bluestore/BlueFS.cc Resolved
@pereman2

Copy link
Copy Markdown
Contributor Author

jenkins test make check

1 similar comment
@pereman2

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@aclamk aclamk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good work, fixes needed.

Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.h Resolved
Comment thread src/test/objectstore/test_bluefs.cc Resolved
Comment thread src/os/bluestore/bluefs_types.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We tend to name such functions bound_encode through the Ceph code base. And its implementation actually attempts to follow the one of encode method.
See bluestore_blob_t::bound_encode as a sample.
Suggest to follow the same approach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, perhaps I haven't shared my point clear enough. Apart from renaming I'd prefer to see the implementation of this method via denc methods to match encode/decode rather than using questionable sizeof(var) constructs.

Comment thread src/os/bluestore/BlueFS.cc Resolved
Comment thread src/os/bluestore/BlueFS.cc Outdated
Comment on lines 2729 to 2750

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Honestly I don't understand the above point. Personally I'd prefer setting log_is_compacting prior to log.lock acquisition and maybe_extent_log() call too.
@pereman2 - could you please elaborate?

Comment thread src/os/bluestore/bluefs_types.h Resolved
Comment thread src/os/bluestore/bluefs_types.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, perhaps I haven't shared my point clear enough. Apart from renaming I'd prefer to see the implementation of this method via denc methods to match encode/decode rather than using questionable sizeof(var) constructs.

With these changes, every call to log compaction will try to expand its
runway in case of insufficient log space. async compaction will ignore
the `log_forbidden_to_expand` atomic since we know it should't be
harmful. In any other case, expansion of log will wait until compaction
is completed.

in order to ensure op_file_update_inc fits on disk we increase the size
of logs as previously used in _maybe_extend_log. This means we too bring
back _maybe_extend_log with a different usage.

_maybe_extend_log increases the size of the log if the runway is less
than the min runway and if the current transaction is too big to fit.

Fixes: https://tracker.ceph.com/issues/58759
Signed-off-by: Pere Diaz Bou <[email protected]>
@ljflores

Copy link
Copy Markdown
Member

@yuriw
yuriw merged commit 9396138 into ceph:main Aug 22, 2023
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Aug 26, 2023
This fixes failures found in
test_concurrent_dir_link_and_compact_log_56210 where the underlying
machinery would attempt to write into a too-small ondisk segment.

We just backport the entire patch from `main`.

Upstream-ref: ceph/ceph@9396138
References: https://github.com/ceph/ceph/blob/main/src/test/objectstore/test_bluefs.cc#L1359
References: ceph/ceph#50216
References: https://tracker.ceph.com/issues/58759
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Aug 26, 2023
This fixes failures found in
test_concurrent_dir_link_and_compact_log_56210 where the underlying
machinery would attempt to write into a too-small ondisk segment.

We just backport the entire patch from `main`.

Upstream-ref: ceph/ceph@9396138
References: https://github.com/ceph/ceph/blob/main/src/test/objectstore/test_bluefs.cc#L1359
References: ceph/ceph#50216
References: https://tracker.ceph.com/issues/58759
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Sep 2, 2023
This fixes failures found in
test_concurrent_dir_link_and_compact_log_56210 where the underlying
machinery would attempt to write into a too-small ondisk segment.

We just backport the entire patch from `main`.

Upstream-ref: ceph/ceph@9396138
References: https://github.com/ceph/ceph/blob/main/src/test/objectstore/test_bluefs.cc#L1359
References: ceph/ceph#50216
References: https://tracker.ceph.com/issues/58759
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Sep 7, 2023
This fixes failures found in
test_concurrent_dir_link_and_compact_log_56210 where the underlying
machinery would attempt to write into a too-small ondisk segment.

We just backport the entire patch from `main`.

Upstream-ref: ceph/ceph@9396138
References: https://github.com/ceph/ceph/blob/main/src/test/objectstore/test_bluefs.cc#L1359
References: ceph/ceph#50216
References: https://tracker.ceph.com/issues/58759
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Sep 7, 2023
This fixes failures found in
test_concurrent_dir_link_and_compact_log_56210 where the underlying
machinery would attempt to write into a too-small ondisk segment.

We just backport the entire patch from `main`.

Upstream-ref: ceph/ceph@9396138
References: https://github.com/ceph/ceph/blob/main/src/test/objectstore/test_bluefs.cc#L1359
References: ceph/ceph#50216
References: https://tracker.ceph.com/issues/58759
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Sep 9, 2023
This fixes failures found in
test_concurrent_dir_link_and_compact_log_56210 where the underlying
machinery would attempt to write into a too-small ondisk segment.

We just backport the entire patch from `main`.

Upstream-ref: ceph/ceph@9396138
References: https://github.com/ceph/ceph/blob/main/src/test/objectstore/test_bluefs.cc#L1359
References: ceph/ceph#50216
References: https://tracker.ceph.com/issues/58759
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Sep 9, 2023
This fixes failures found in
test_concurrent_dir_link_and_compact_log_56210 where the underlying
machinery would attempt to write into a too-small ondisk segment.

We just backport the entire patch from `main`.

Upstream-ref: ceph/ceph@9396138
References: https://github.com/ceph/ceph/blob/main/src/test/objectstore/test_bluefs.cc#L1359
References: ceph/ceph#50216
References: https://tracker.ceph.com/issues/58759
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Oct 3, 2024
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Oct 4, 2024
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants