]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
librbd: replace deprecated atomic_store with std::atomic<shared_ptr>
authorKefu Chai <tchaikov@gmail.com>
Sat, 29 Mar 2025 13:10:05 +0000 (21:10 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 29 Mar 2025 13:14:19 +0000 (21:14 +0800)
commit6304ba5f7fd5d32afe33e7234e5a90ad48afc862
tree9c92677aa9638230f127649ba0433944a1716357
parent2694580314dc81e1c3f9a1ccd7107a13b949bb59
librbd: replace deprecated atomic_store with std::atomic<shared_ptr>

Update shared pointer atomic operations to use C++20's std::atomic<std::shared_ptr<T>>
instead of the deprecated atomic_store functions. This change addresses deprecation
warnings from GCC-15's libstdc++ where atomic shared pointer operations outside the
std::atomic class are being phased out:
```
/home/kefu/dev/ceph/src/librbd/ImageCtx.cc:1010:5: warning: 'atomic_store<neorados::IOContext>' is deprecated: use 'std::atomic<std::shared_ptr<T>>' instead [-Wdeprecated-declarations]
 1010 |     atomic_store(&data_io_context, ctx);
      |     ^
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr_atomic.h:181:5: note: 'atomic_store<neorados::IOContext>' has been explicitly marked deprecated here
  181 |     _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic<std::shared_ptr<T>>")
      |     ^
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/x86_64-redhat-linux/bits/c++config.h:2055:45: note: expanded from macro '_GLIBCXX20_DEPRECATED_SUGGEST'
 2055 | # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT)
      |                                             ^
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/x86_64-redhat-linux/bits/c++config.h:2023:19: note: expanded from macro '_GLIBCXX_DEPRECATED_SUGGEST'
 2023 |   __attribute__ ((__deprecated__ ("use '" ALT "' instead")))
      |                   ^
```

The implementation now uses the standard-compliant approach that's recommended in
the compiler warnings, while maintaining backward compatibility with older compilers
by conditionally selecting the appropriate implementation.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h