Repository navigation
backports to bobtail for rbd bug fixes - #238
Merged
Merged
Conversation
This was causing librados to unblock after the ACK on unwatch, which meant that librbd users raced and tried to delete the image before the unwatch change was committed..and got EBUSY. See #3958. The watch operation has a similar problem. Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit fea7768) Conflicts: src/librados/IoCtxImpl.cc
Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit de4fa95)
A watch is a mutation, while a notify is a read. The mutations need to pass in a proper snap context to be fully correct. Also, make the WRITE flag implicit so the caller doesn't need to pass it in. Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit 6c08c7c)
Since they are write ops now, it must be CEPH_NOSNAP or the OSD returns EINVAL. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 15bb9ba)
This makes them easier to use, especially instead of existing mutexes. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit e0f8e5a)
Image metadata like snapshots, size, and parent is frequently read, but rarely updated. During flatten, we were depending on the parent lock to prevent the parent ImageCtx from disappearing out from under us while we read from it. The copy-up path also needed the parent lock to be able to read from the parent image, which lead to a deadlock. Convert parent_lock, snap_lock, and md_lock to RWLocks, and change their use to read instead of exclusive locks where appropriate. The main place exclusive locks are needed is in ictx_refresh, so this is pretty simple. This fixes the deadlock, since parent_lock is only needed for read access in both flatten and the copy-up operation. cache_lock and refresh_lock are only really used for exclusive access, so leave them as regular mutexes. One downside to this is that there's no way to assert is_locked() for RWLocks, so we'll have to be very careful about changing code in the future. Fixes: #3665 Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 995ff0e)
The only way for a parent to disappear is a racing flatten completing, or possibly in the future the image being forcibly removed. In either case, continuing to flatten makes no sense, so stop early. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit a1ae856)
Make snap_rollback() only take a read lock on snap_lock, since it does not modify snapshot-related fields. Conflicts: src/librbd/internal.cc (cherry picked from commit db5fc22)
The duplicate calls to get_image_size() and get_snap_size() replaced by 5806226 uncovered this. The first call was using the currently set snap_id instead of the snapshot being rolled back to. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit d6c126e)
They need the same setup, and it's easy enough to run specific subtests. Making them a separate subclass accidentally duplicated tests from TestClone. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 9c693d7)
Reads always use C_ReadFinish as a callback (and they are the only user of this callback). Keep an xlist of these for each object, so they can remove themselves as they finish. To prevent racing requests and with discard removing objects from the cache, clear the xlist in the object destructor, so if the Object is still valid the set_item will still be on the list. Make the ObjectCacher constructor take an Object* instead of the pool and object id, which are derived from the Object* anyway. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit f6f876f)
Clear the exists and complete flags for any objects that have exists set to false, and force any in-flight reads to retry if they get -ENOENT instead of generating zeros. This is useful for getting the cache into a consistent state for rbd after an image has been flattened, since many objects which previously did not exist and went up to the parent to retrieve data may now exist in the child. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit f2a23dc)
The cache stores which objects don't exist. Flatten bypasses the cache when doing its copyups, so when it is done the -ENOENT from the cache is treated as zeroes instead of 'need to read from parent'. Clients that have the image open need to forgot about the cached non-existent objects as well. Do this during ictx_refresh, while the parent_lock is held exclusively so no new reads from the parent can happen until the updated parent metadata is visible, so no new reads from the parent will occur. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 46e8fc0)
Older guests may not send flushes properly (i.e. never), so if this is enabled, rbd_cache=true is safe for them transparently. Disable by default, since it will unnecessarily slow down newer guest boot, and prevent writeback caching for things that don't need to send flushes, like the command line tool. Refs: #3817 Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Sage Weil <[email protected]> (cherry picked from commit 1597b3e)
If there are writes pending, they should be sent while the image is still writeable. If the image becomes read-only, flushing the cache will just mark everything dirty again due to -EROFS. Fixes: #4525 Backport: bobtail Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 613b708)
Add a callback argument to writex, and a finisher to run the callbacks. Move the check for dirty+tx > max_dirty into a helper that can be called from a wrapper around the callbacks from writex, or from the current place in _wait_for_write(). Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit c212504)
When the ObjectCacher's writex blocks, it affects the thread requesting the aio, which can cause starvation for other I/O when used by QEMU. Preserve the old behavior via a config option in case this has any bad side-effects, like too much memory usage under heavy write loads. Fixes: #4091 Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 03ac01f)
commit_set() and flush_set() are identical in functionality, so use flush_set everywhere and remove commit_set from the code. Also fixes a bug in flush_set where the finisher context was getting freed twice if no objects needed to be flushed. Signed-off-by: Sam Lang <[email protected]> (cherry picked from commit 72147fd)
C_GatherBuilder takes ownership of the Context we pass it. Deleting it in flush_set after constructing the C_GatherBuilder results in a double delete. Fixes: #3946 Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Sam Lang <[email protected]> (cherry picked from commit 3bc2114)
This removes the last remnants of b5e9995. If there's nothing to flush, immediately call the callback instead of deleting it. Callers were assuming they were responsible for completing the callback whenever flush_set() returned true, and always called complete(0) in this case. Simplify the interface and just do this in flush_set(), so that it always calls the callback. Since C_GatherBuilder deletes its finisher if there are no subs, only set its finisher when subs are present. This way we can still call ->complete() for the callback. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 92db06c) Conflicts: src/client/Client.cc
Callers will always pass a callback, so assert this and remove the checks for it being NULL. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 41568b9)
The gather will only have subs if there is something to flush. Remove the safe variable, which indicates the same thing, and convert the conditionals that used it to an else branch. Movinig gather.activate() inside the has_subs() check has no effect since activate() does nothing when there are no subs. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 553aaac)
Sometimes you don't want flush to block, and can't modify already scheduled aio_writes. This will be useful for a librbd async flush interface. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 7cc0940) Conflicts: src/include/rados/librados.h src/include/rados/librados.hpp
Usually the snapid to read from or the snapcontext to send with a write are determined implicitly by the IoCtx the operations are done on. This makes it difficult to have multiple ops in flight to the same IoCtx using different snapcontexts or reading from different snapshots, particularly when more than one operation may be needed past the initial scheduling. Add versions of aio_read, aio_sparse_read, and aio_operate that don't depend on the snap id or snapcontext stored in the IoCtx, but get them from the caller. Specifying this information for each operation can be a more useful interface in general, but for now just add it for the methods used by librbd. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit f06debe)
Mainly this is useful for testing, like flushing and checking that all pending writes are complete after the flush finishes. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 2ae3206)
Before we were duplicating the IoCtx for each new request since they could have a different snapshot context or read from a different snapshot id. Since librados now supports setting these explicitly for a given request, do that instead. Since librados tracks outstanding requests on a per-IoCtx basis, this also fixes a bug that causes flush() without caching to ignore all the outstanding requests, since they were to separate, duplicate IoCtxs. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 860493e)
At this point it's a simple wrapper around the ObjectCacher or librados. This is needed for QEMU so that its main thread can continue while a flush is occurring. Since this will be backported, don't update the librbd version yet, just add a #define that QEMU and others can use to detect the presence of aio_flush(). Refs: #3737 Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 302b93c)
The common case already has a snapshot context, so avoid duplicating it (copying a potentially large vector) in IoCtxImpl::aio_operate(). Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 4c4d559)
This is a quick workaround for the next branch. A more complete fix will be done for the master branch. This does not affect correctness, just what qa runs with lockdep enabled do. Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Sage Weil <[email protected]> (cherry picked from commit 267ce0d)
There's no reason to check the duration of a watch. The notify will timeout after 30s on the OSD, but there's no guarantee the client will see that in any bounded time. This test is really meant as a stress test of the OSDs anyway, not of the clients, so just remove asserts about operation duration. Fixes: #4591 Signed-off-by: Josh Durgin <[email protected]> Reviewed-by: Sam Just <[email protected]> (cherry picked from commit 4b65673)
Both versions of flush_set() did the same thing. Move it into a helper called from both. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit f5b81d8)
The tid returned by reads is ignored, and would make tracking writes internally more difficult by using the same id-space as them. Make read void and update all implementations. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 870f9cd)
An int could be much smaller, leading to overflow and bad behavior. Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 9d19961)
Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 909dfb7)
RADOS returns writes to the same object in the same order. The ObjectCacher relies on this assumption to make sure previous writes are complete and maintain consistency. Reads, however, may be reordered with respect to each other. When writing to an rbd clone, reads to the parent must be performed when the object does not exist in the child yet. These reads may be reordered, resulting in the original writes being reordered. This breaks the assmuptions of the ObjectCacher, causing an assert to fail. To fix this, keep a per-object queue of outstanding writes to an object in the LibrbdWriteback handler, and finish them in the order in which they were sent. Fixes: #4531 Signed-off-by: Josh Durgin <[email protected]> (cherry picked from commit 06d05e5)
Only set the STRIPINGV2 feature if the striping parameters are non-default. Specifically, fix the case where the passed-in size and count are == 0. Fixes: #4710 Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit 5926ffa) Conflicts: src/rbd.cc
jdurgin
added a commit
that referenced
this pull request
Apr 23, 2013
Reviewed-by: Sage Weil <[email protected]>
liewegas
pushed a commit
to liewegas/ceph
that referenced
this pull request
Nov 5, 2021
blog: fix survey post pdf+csv
3 of 14 tasks
irq0
pushed a commit
to irq0/ceph
that referenced
this pull request
Nov 13, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These passed the rbd regression suite perfectly