Project

General

Profile

Actions

Bug #9595

closed

librbd: internal methods can operate on extra objects when non-default striping is used

Added by Josh Durgin over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
-
% Done:

0%

Source:
Development
Tags:
Backport:
Regression:
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

  uint64_t ImageCtx::get_stripe_period() const
  {
    return stripe_count * (1ull << order);
  }
  uint64_t ImageCtx::get_num_objects() const
  {
    uint64_t period = get_stripe_period();
    uint64_t num_periods = (size + period - 1) / period;
    return num_periods * stripe_count;
  }

This rounds up to the next full period, which can overestimate for images with non-default striping and sizes having a small remainder when divided by the period.
The correct number of objects can be calculated by removing this extra remainder, something like:

    remainder_bytes = size % period
    remainder_objs = 0
    if remainder_bytes > 0 and remainder_bytes < stripe_count * stripe_unit:
        remainder_objs = stripe_count - ((remainder_bytes + stripe_unit - 1) / stripe_unit)
    return num_periods * stripe_count - remainder_objs

Hopefully that can be simplified. This could be added to the Striper as a generic method. Then it can be used in librbd's internal methods including flatten(), trim_image(), image_info(), and rollback_image().

This doesn't cause much harm, just a few extra I/Os, and misleading num_objects from rbd_stat().

Actions #1

Updated by Xinxin Shu over 9 years ago

  • Assignee set to Xinxin Shu
Actions #2

Updated by Xinxin Shu over 9 years ago

  • Status changed from New to Fix Under Review
Actions #4

Updated by Josh Durgin over 9 years ago

  • Status changed from Fix Under Review to Resolved

commit:7b66ee4928d934d684b361602de783b927988503

Actions

Also available in: Atom PDF