Project

General

Profile

Actions

Feature #51110

open

invalidate crc in buffer::ptr::c_str()

Added by Wenjun Huang almost 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Dev Interfaces
Target version:
-
% Done:

0%

Source:
Tags:
Backport:
Reviewed:
Affected Versions:
Component(RADOS):
Pull request ID:

Description

what:

buffer::ptr (or more precisely, buffer::raw) has the ability to cache CRC codes that are calculated from its underlying buffer.

Since the cached codes become invalid when the underlying buffer is modified, they should be invalidated in the non-const version of c_str() (https://github.com/ceph/ceph/blob/76d882bd6dc255cde9c124bcae8016c4da514d05/src/common/buffer.cc#L513) via a call to _raw->invalidate_crc():

char *buffer::ptr::c_str() {
  ceph_assert(_raw);
  raw->invalidate_crc();
  return _raw->get_data() + _off;
}

why:

While the current behavior is not wrong, it is quite counterintuitive to someone who doesn't know much about Ceph internals (e.g. I ran into some weird bugs when developing a Ceph object class because of this).

If "out-of-tree" development is supported for object classes (https://docs.ceph.com/en/latest/rados/api/objclass-sdk/), then assuming knowledge about Ceph internals doesn't make much sense, so I think this behavior should be changed.

Also, it looks like people have run into a related issue in the past: https://github.com/ceph/ceph/pull/29248, so I suppose this behavior is confusing not only to me but to others as well.

potential problems:

This can have a performance impact in theory, but I doubt it'll be significant. After all, if someone's calling the non-const c_str(), it can be safely assumed that the underlying buffer will be modified.

No data to display

Actions

Also available in: Atom PDF