Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librbd/cache/pwl: fix m_bytes_{allocated,cached} calculation on reopen #42883

Merged
merged 1 commit into from Sep 10, 2021

Conversation

majianpeng
Copy link
Member

…load entries.

Currently, it will load existing entries after restart and cacl
m_bytes_allocated based on those entries. But currently there are
the following problems:
1: The allocated of write-same is not calculated for rwl & ssd cache.
2: for ssd cache, it not include the size of log-entry itself and don't
consider data alignment. This will cause less calculation and more
allocatation later. And will overwrite the data which don't flush to osd
and make data lost.

The calculation methods of ssd and rwl are different. So add new api
allocated_and_cached_data() to implement their own method.

For SSD cache, we dirtly use m_first_valid_entry & m_first_free_entry to
calc m_bytes_allocated.

Fixes:https://tracker.ceph.com/issues/52341
Signed-off-by: Jianpeng Ma jianpeng.ma@intel.com

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

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

@github-actions github-actions bot added the rbd label Aug 23, 2021
@majianpeng
Copy link
Member Author

@MahatiC @CongMinYin please review. Thanks

@majianpeng
Copy link
Member Author

retest this please

@CongMinYin
Copy link
Contributor

LGTM

@majianpeng
Copy link
Member Author

@MahatiC , ping.

@majianpeng
Copy link
Member Author

@MahatiC ping.

@majianpeng
Copy link
Member Author

@MahatiC ping

src/librbd/cache/pwl/ssd/WriteLog.cc Show resolved Hide resolved
template <typename I>
void WriteLog<I>::calc_allocated_and_cached_data(std::shared_ptr<pwl::GenericLogEntry> log_entry, uint32_t alloc_size) {
auto gen_write_entry = static_pointer_cast<GenericWriteLogEntry>(log_entry);
if (log_entry->is_write_entry()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain why this check if (log_entry->write_bytes() == log_entry->bytes_dirty()) is removed? That check will differentiate writesame from a write request. In writesame, we don't allocate all of the write_bytes() length. I think we need to differentiate when calculating m_bytes_allocated

src/librbd/cache/pwl/AbstractWriteLog.cc Outdated Show resolved Hide resolved
src/librbd/cache/pwl/AbstractWriteLog.h Outdated Show resolved Hide resolved
src/librbd/cache/pwl/rwl/WriteLog.cc Outdated Show resolved Hide resolved
src/librbd/cache/pwl/rwl/WriteLog.cc Show resolved Hide resolved
src/librbd/cache/pwl/AbstractWriteLog.cc Outdated Show resolved Hide resolved
src/librbd/cache/pwl/rwl/WriteLog.cc Outdated Show resolved Hide resolved
src/librbd/cache/pwl/ssd/WriteLog.cc Outdated Show resolved Hide resolved
src/librbd/cache/pwl/rwl/WriteLog.cc Outdated Show resolved Hide resolved
src/librbd/cache/pwl/ssd/WriteLog.cc Show resolved Hide resolved
@majianpeng
Copy link
Member Author

@idryomov . update please review.

@idryomov
Copy link
Contributor

idryomov commented Aug 30, 2021

I would maybe rename calc_allocated_and_cached_data() to inc_allocated_cached_bytes(), otherwise looks good to me.
@MahatiC I think your concern about write_bytes() == bytes_dirty() check has been resolved. Please take a look -- it is the only outstanding conversation now.

…load entries.

Currently, it will load existing entries after restart and cacl
m_bytes_allocated based on those entries. But currently there are
the following problems:
1: The allocated of write-same is not calculated for rwl & ssd cache.
2: for ssd cache, it not include the size of log-entry itself and don't
consider data alignment. This will cause less calculation and more
allocatation later. And will overwrite the data which don't flush to osd
and make data lost.

The calculation methods of ssd and rwl are different. So add new api
allocated_and_cached_data() to implement their own method.

For SSD cache, we dirtly use m_first_valid_entry & m_first_free_entry to
calc m_bytes_allocated.

Fixes:https://tracker.ceph.com/issues/52341
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
@idryomov idryomov changed the title librbd/cache/pwl: solve the problem of calc m_bytes_allocated when re… librbd/cache/pwl: fix m_bytes_{allocated,cached} calculation on reopen Sep 9, 2021
@idryomov idryomov merged commit f455a7a into ceph:master Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants