summaryrefslogtreecommitdiffstats
path: root/src/common/version.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* src/*: do not pass cct to ceph_version_to_str()Kefu Chai2020-12-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in e5b1ae5554c4d8a20f9f0ff562b231ad0b0ba0ab, a new option named "debug_version_for_testing" is introduced to override the version so we can test version check. in crimson, we have two families of shared functions. - one of them is used by alien store. they are compiled with -DWITH_SEASTAR and -DWITH_ALIEN, to enable the shim code between seastar and POSIX thread. - another is used by crimson in general. where no lock is allowed. currently, we use the "crimson" and "ceph" namespace to differentiate these two families of functions, so they can colocate in the same executable without violating the ODR. see src/include/common_fwd.h for more details. the functions defined in src/common/version.cc are also shared by alien store and crimson code. and because we have different implementations of `CephContext` in crimson and in classic OSD (i.e. alienstore), we have to have different implementations of this function as well, if we follow the same approach. but since these functions are very simple and are non-blocking, there is not much value in differentiating them, it is better to inject the test settings using environment variable instead of using ceph option subsystem. in this change, "ceph_debug_version_for_testing" environment variable is checked instead, so that crimson and alienstore can share the same compilation unit of version.cc. and "debug_version_for_testing" option is removed. Signed-off-by: Kefu Chai <kchai@redhat.com>
* test: Use a config variable debug_version_for_testingDavid Zafman2020-11-121-1/+2
| | | | Signed-off-by: David Zafman <dzafman@redhat.com>
* src/: define ceph_release_t and use itKefu Chai2019-05-041-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | we have following pains when it comes to ceph release related programming: * we use int, uint8_t, uint32_t, unsigned int for representing the ceph release, i.e., jewel, luminous, nautilus, in different places in our source tree. * we always need to add a comment aside of `uint8_t release` to help the folks to understand that it is CEPH_RELEASE_*. * also we keep forgetting that "os << release" actually prints the release as an ASCII. * and it's painful to remember that we have to translate the release number using `ceph_release_name()` before print it out in the human readable format. * we replicate the n+2 upgrade policy in multiple places in this change, `ceph_release_t` and some helper functions are intruduced to alleviate the pains above. * add a scoped enum for representing ceph releases, so the release is typed . which means that we can attach different function to it. and in future, we can even replace `ceph_release_t` with a class if we need to support more fancy features which cannot be implemented using free functions. * add `ostream<<()` operator for `ceph_release_t`, so we can simply send it to `ostream` * add `can_upgrade_from()` so we don't need to repeat ourselves. * move ceph_release_from_name() to ceph_release.{h,cc}, as currently, ceph_release.cc uses `ceph_release_name()` for implementing `ostream<<()`, and after this change, `ceph_release_from_name()` will return `ceph_release_t`, so if we keep `ceph_release_from_name()` where it was, these two headers will be included by each other, which is a no-go. * reimplement `ceph_release_from_name()` using a loop. before this change, `ceph_release_from_name()` was implemented using a manually unrolled if-else structure, which is more performant, but the downside is that, it replicates mapping between release number and its name. so after this change, a loop is used instead. as this function is not used in the critical path, so this change should not have visible impact on the performance. * always use ceph_release_t::unknown as the default value of the "release" member variables. before this change, sometimes, we use "0" and sometimes we use "1", after inspecting the code, i found that "0" is good enough to cover all the use cases. and since "0" is a magic number in this context, it is replaced using `ceph_release_t::unknown`. to facilidate the checking against `ceph_release_t::unknown`, `operator!()` is added. * ceph::to_string() and ceph::to_integer<>() are added to help to remove the asssumption of the underlying type of `ceph_release_t`, ideally, users of `ceph_release_t` should not use `static_cast<>` to cast it into integer types, instead, they should use `ceph::to_integer<>()` to do this job. if, in future, we want to use a `class` to represent `ceph_release_t`, we can get this done with minimum change, if `ceph::to_string()` and `ceph::to_string()` are used. we can not specialize them in `std` naming space. as it's claimed that it's undefined behavior to do so. see https://en.cppreference.com/w/cpp/language/extending_std . Signed-off-by: Kefu Chai <kchai@redhat.com>
* common: Add metadata with only Ceph version number and releaseWido den Hollander2018-03-281-0/+3
| | | | | | | | | | This prevents consumers from this data to have to fully parse and split the 'ceph_version' string which is prone to errors. ceph_version_short only contains the version number (maj, min, patch) and ceph_release the codename, eg, luminous. Signed-off-by: Wido den Hollander <wido@42on.com>
* common/version: include release name and type in version stringSage Weil2017-05-311-0/+7
| | | | | | ceph version 12.0.2-1687-ge042051 (e0420518d712d87a4882b3a327eaf1d3fcea12df) luminous (dev) Signed-off-by: Sage Weil <sage@redhat.com>
* version: fix const warningSage Weil2011-03-061-2/+2
| | | | Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
* dout: Log version message when (re)opening logColin Patrick McCabe2011-03-031-3/+8
| | | | | | | | | | | | | | | | | | | Log a version message whenever we open the dout log, not just the first time. However, only output it to log files and syslog. Spewing versions to stderr and stdout was determined to be annoying. Rename dout_emergency_impl to dout_emergency_to_file_and_syslog to better reflect its function. Rename ceph_version_to_string to pretty_version_to_string. Add get_process_name to do just that. Re-arrange some version.h methods. Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com> Conflicts: src/common/common_init.cc
* debug.h: move Ceph version stuff into version.hColin Patrick McCabe2011-02-181-0/+24
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>