summaryrefslogtreecommitdiffstats
path: root/src/librbd/internal.cc (follow)
Commit message (Collapse)AuthorAgeFilesLines
* rbd: add the validate of the format and clone_formatjunxiang Mu2024-06-271-0/+5
| | | | | | | | | [ idryomov: squash test_unsupported_clone_format() into test_clone_format() ] Fixes: https://tracker.ceph.com/issues/65744 Signed-off-by: junxiang Mu <1948535941@qq.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* librbd: add rbd_clone4() API to take parent snapshot by IDIlya Dryomov2024-06-131-12/+22
| | | | | | | | | | | | | | | | | | | | | Allow cloning from non-user snapshots -- namely snapshots in group and mirror namespaces. The motivation is to provide a building block for cloning new groups from group snapshots ("rbd group snap create"). Otherwise, group snapshots as they are today can be used only for rolling back the group as a whole, which is very limiting. While at it, there doesn't seem to be anything wrong with making it possible to clone from mirror snapshots as well. Snapshots in a trash namespace can't be cloned from since they are considered to be deleted. Cloning from non-user snapshots is limited to clone v2 just because protecting/unprotecting is limited to snapshots in a user namespace. This happens to simplify some invariants. Fixes: https://tracker.ceph.com/issues/64662 Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* librbd: replace assert with error check in clone()Ilya Dryomov2024-06-131-2/+6
| | | | | | | | With an error check for p_snap_name, it doesn't make much sense to crash if "either p_id or p_name" contract is violated. Replace the assert with a similar error check. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* librbd: clear Image::list_watchers() list before populating itIlya Dryomov2023-03-311-0/+1
| | | | | | | | The "append to the passed list" behavior is confusing and not what the corresponding C API (rbd_watchers_list) or other similar C++ APIs (e.g. list_lockers) do. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* librbd: remove unused trim_image() methodIlya Dryomov2022-12-041-20/+0
| | | | Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* librbd: clip extents to their area instead of DATA areaIlya Dryomov2022-12-041-6/+4
| | | | | | | | This fixes cases where CRYPTO HEADER area is larger than DATA area. In particular, it was effectively impossible to flatten unformatted clones of such images. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* librbd: introduce reduce_parent_overlap() and switch overlap APIIlya Dryomov2022-12-041-7/+17
| | | | | | | | | | | | | | | | When encryption is loaded, rbd_get_overlap() and Image::overlap() now return "effective" overlap, similar to rbd_get_size() and Image::size(). Previously, returned overlap could have been bigger than "effective" size. Note that get_effective_image_size() successor doesn't take snap_id because passing anything but ictx->snap_id was broken. Since the size of the crypto header is stored in the crypto header itself, image areas are defined only for the "opened at" snap_id. Getting "effective" size for an arbitrary snapshot requires actually opening it and loading encryption on it. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* librbd: pass area to ImageDispatchSpec::create_*()Ilya Dryomov2022-12-041-2/+2
| | | | | | | | | | | | | | - DATA area is assumed at the API layer as there is no way to pass an area - DATA area is assumed by ImageWriteback because PWL cache persists image extents as provided by the user without any kind of designator and therefore can be active only in either area - luks::FlattenRequest operates on CRYPTO_HEADER area The passed area is acted upon in ImageDispatchSpec constructor in the next commit. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
* librbd: send FLUSH_SOURCE_INTERNAL when do copy/deep_copy.Jianpeng Ma2021-11-011-1/+16
| | | | | | | | | | copy/deep_copy use object_map to judge whether object exist. If w/ librbdo pwl cache, flush can't flush data to osd which change objectmap state. So we should send flush w/ FLUSH_SOURCE_INTERNAL to make data flush to osd. Fixes:https://tracker.ceph.com/issues/53057 Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
* librbd: build without "using namespace std"Kefu Chai2021-08-131-2/+3
| | | | | | | | | | * add "std::" prefix in headers * add "using" declarations in .cc files. so we don't rely on "using namespace std" in one or more included headers. Signed-off-by: Kefu Chai <kchai@redhat.com>
* librbd: add encryption apiOr Ozeri2021-01-111-11/+6
| | | | | | This commit exposes librbd encryption api Signed-off-by: Or Ozeri <oro@il.ibm.com>
* librbd/cache: move image writeback cache to pluginlixiaoy12020-12-081-1/+2
| | | | Signed-off-by: Li, Xiaoyan <xiaoyan.li@intel.com>
* librbd: replace direct reads from ImageRequest with ImageDispatchSpecJason Dillaman2020-11-011-11/+12
| | | | | | | Read requests will always need to go via the image dispatch layer to ensure migrations are properly handled. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd/internal: update invalidate_cachelixiaoy12020-10-291-2/+18
| | | | | | Except invalidating object cache, invalidate image writeback cache. Signed-off-by: Li, Xiaoyan <xiaoyan.li@intel.com>
* rbd/io: split IO checklixiaoy12020-09-301-4/+10
| | | | | | Move IO check to interfaces in Utils. Signed-off-by: Li, Xiaoyan <xiaoyan.li@intel.com>
* librbd: pass read flags via image-extent dispatch layersJason Dillaman2020-09-211-2/+2
| | | | Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: pass IOContext to image-extent IO dispatch methodsJason Dillaman2020-09-181-3/+5
| | | | | | | This allows a specific IOContext to be used regardless of the image's current read and write snapshot state. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* blacklist -> blocklistSage Weil2020-08-241-5/+5
| | | | | Signed-off-by: Sage Weil <sage@newdream.net> Signed-off-by: Neha Ojha <nojha@redhat.com>
* librbd: replace ImageCtx::get_work_queue with direct AsioEngine usageJason Dillaman2020-07-161-6/+7
| | | | | | | | | | | The ImageCtx will contain a shared_ptr to its AsioEngine and previous usage for get_work_queue now directly instantiate their own AsioEngine instance. Additionally, AsioEngine is now lighter weight by re-using the io_context exposed via a neorados-wrapped librados API. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* cls,rados,rbd,mds,common: Avoid name collision with Windows headersLucian Petrut2020-07-081-1/+1
| | | | | | | | | | | | | There are a few name collisions between Windows headers and ceph. Where possible, we'll update Ceph code to avoid redefinitions. The following names overlap with Windows headers: * ERROR, NO_ERROR * DELETE * LocalLock * LOCK_SHARED, LOCK_EXCLUSIVE Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
* librbd: swapped ThreadPool/ContextWQ for AsioEngineJason Dillaman2020-06-131-2/+2
| | | | | | | | | The majority of usage of ContextWQ has been switched to use the ASIO ContextWQ adapter class. The journal, RWL cache, and image update notifications remain the only remaining use of dedicated ThreadPools in librbd. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: replaced ImageCtx::get_thread_pool_instanceJason Dillaman2020-06-121-4/+2
| | | | | | | Callers have never needed the actual ThreadPool which is being removed. Refactored into ImageCtx::get_work_queue method. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* Merge pull request #34964 from dillaman/wip-45137Mykola Golub2020-05-181-7/+6
|\ | | | | | | | | librbd: replace ImageRequestWQ with pluggable ImageDispatcher Reviewed-by: Mykola Golub <mgolub@suse.com>
| * librbd: switch to new api::Io dispatch helper methodsJason Dillaman2020-05-141-6/+5
| | | | | | | | | | | | | | This is another step in the removal of ImageRequestWQ in favor of the new ImageDispatcher. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
| * librbd: move generic IO dispatcher logic to base classJason Dillaman2020-05-141-1/+1
| | | | | | | | | | | | | | This will allow re-use between the existing ObjectDispatcher and the ImageDispatcher that will be added in a future commit. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* | librbd: copy API should not inherit v1 image format by defaultJason Dillaman2020-05-121-1/+1
|/ | | | | | | | | | When copying from a v1 image, by default the new destination image would be created using the v1 format. Since the creation of v1 images is disallowed, this has been updated to default to using the v2 image format. Fixes: https://tracker.ceph.com/issues/45518 Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: permit mirroring to be enabled upon image creationJason Dillaman2020-04-231-2/+9
| | | | | | | The librbd create API's ImageOptions parameter now supports passing the mirror image mode. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: pass bit-flags to image::CreateRequestJason Dillaman2020-04-211-1/+7
| | | | | | | | The current boolean for skip enable mirror will be able to be changed to a tri-state to force enable mirror (in addition to the current auto-enable if in pool-mode). Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: optionally filter internal image-meta when copying/cloningJason Dillaman2020-02-271-1/+1
| | | | | | | Any ".rbd"-prefixed image-meta keys will be considered RBD-internal and will not be added to the new image when copied/cloned. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: switch to new metadata retrieval state machineJason Dillaman2020-02-211-22/+16
| | | | Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: clone state machine should accept snapshot namespaceJason Dillaman2020-01-301-1/+2
| | | | | | | It currently assumes that you can only create snapshots from user snapshot namespaces. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: pass mirror image mode to create/clone image state machinesJason Dillaman2020-01-301-4/+5
| | | | | | | The rbd-mirror daemon will need to be able to create images using snapshot-based mirroring. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* Merge pull request #31589 from zhengchengyao/mv_snapshotJason Dillaman2019-12-061-243/+0
|\ | | | | | | | | librbd:move all snapshot API functions in internal.cc over to api/Snapshot.cc Reviewed-by: Jason Dillaman <dillaman@redhat.com>
| * librbd: move all snapshot API functions in internal.cc over to api/Snapshot.cczhengyin2019-11-191-243/+0
| | | | | | | | Signed-off-by: Zheng Yin <zhengyin@cmss.chinamobile.com>
* | Merge pull request #31692 from rzarzynski/wip-fips-zeroize-memset_bzeroKefu Chai2019-11-241-0/+1
|\ \ | |/ |/| | | | | FIPS: audit and switch some memset & bzero users Reviewed-by: Marcus Watts <mwatts@redhat.com>
| * librbd: audit memset & bzero users for FIPS.Radoslaw Zarzynski2019-11-171-0/+1
| | | | | | | | Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
* | rbd: do not create temporary objects whenever possibleVenky Shankar2019-11-111-6/+11
|/ | | | | | | | .. for Journal, ExclusiveLock and ObjectMap class, and in case that cannot be avoided, then make sure to destruct the object by calling ->put(). Signed-off-by: Venky Shankar <vshankar@redhat.com>
* librbd: allow to override format in clone requestMykola Golub2019-10-251-4/+17
| | | | Signed-off-by: Mykola Golub <mgolub@suse.com>
* include: convert FunctionContext usage to generic LambdaContextPatrick Donnelly2019-09-161-1/+1
| | | | | | | | The main motivation for this change is to avoid copies due to the use of boost::function/std::function where captures of std::unique_ptr (in subsequent commits) would fail to compile. Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
* librbd: s/Mutex/ceph::mutex/Kefu Chai2019-08-031-37/+38
| | | | Signed-off-by: Kefu Chai <kchai@redhat.com>
* librbd: prevent concurrent AIO callbacks to external clientsJason Dillaman2019-06-261-1/+1
| | | | | | | | | | With the various threads and conditional IO paths within librbd, it was possible for external AIO callbacks to be concurrently executed from different librbd threads. These callbacks should be serialized to reduce the unexpected potential for data corruption. Fixes: http://tracker.ceph.com/issues/40417 Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: switch to lock-free queue for event poll IO interfaceJason Dillaman2019-05-021-5/+3
| | | | | | | | 'perf' shows several percent of CPU being wasted on lock contention in the event poll interface. The 'fio' RBD engine uses this poll IO interface by default when available. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: removed 'ImageCtx::parent_lock'Jason Dillaman2019-04-281-2/+1
| | | | | | | The ImageCtx parent-related data structures are now protected by the image_lock. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: removed 'ImageCtx::md_lock'Jason Dillaman2019-04-281-77/+3
| | | | | | | | | This lock used to protect the IO pathway to prevent writes but that is now handled by the io::ImageRequestWQ. Additional historical uses have been temporarily moved to the 'ImageCtx::image_lock' Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: renamed 'ImageCtx::snap_lock' to 'image_lock'Jason Dillaman2019-04-281-25/+25
| | | | | | | This is the first step in consolidating multiple locks under a single reader/writer lock for simplicity. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
* librbd: add trash purge api callsTheofilos Mouratidis2019-01-111-5/+3
| | | | | | Add trash purge api calls and fix the docs of some other rbd trash functions Signed-off-by: Theofilos Mouratidis <mtheofilos@gmail.com>
* librbd: stringify locker name with get_legacy_str()Sage Weil2019-01-041-2/+2
| | | | | | This avoids the new v1: v2: prefixes. Signed-off-by: Sage Weil <sage@redhat.com>
* common: factories of buffer::ptr_node produce std::unique_ptr now.Radoslaw Zarzynski2018-12-031-5/+4
| | | | Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
* common: proliferate ptr_node in the bufferlist implementation.Radoslaw Zarzynski2018-12-031-2/+3
| | | | Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
* librbd: expand API to include namespaces and image idsJason Dillaman2018-11-251-219/+45
| | | | | | | | | | The get parent and list children methods now return a common struct that includes the full pool details (including the optional namespace). Additionally, a new image list method has been added which includes both the name and id (of v2 images). Fixes: http://tracker.ceph.com/issues/36650 Signed-off-by: Jason Dillaman <dillaman@redhat.com>