Using assert version for linger ops doesn't work with retries,
since the version will change after the first send.
This reverts commit
e1776809031c6dad441cfb2b9fac9612720b9083.
Conflicts:
qa/workunits/rbd/watch_correct_version.sh
+++ /dev/null
-#!/bin/bash -ex
-
-resize_image() {
- for i in $(seq 1 1000)
- do
- rbd resize --size $i test
- done
-}
-
-rm -f test.exported || true
-rbd rm test || true
-rbd create -s 1 --order 25 test
-resize_image &
-
-for i in $(seq 1 1000)
-do
- rbd export test test.exported --debug-rbd 20 2>export.log
- rm -f test.exported
- MATCHED=`cat export.log | tr -d '\n' | (grep -c 'watching header object returned -34.*watching header object returned 0' || true)`
- rm -f export.log
- if [ "$MATCHED" == "1" ]
- then
- echo OK
- exit 0
- fi
-done
-rbd rm test
-
-echo "No race detected"
-echo OK
-exit 0
wctx(NULL),
refresh_seq(0),
last_refresh(0),
- last_header_version(0),
md_lock("librbd::ImageCtx::md_lock"),
cache_lock("librbd::ImageCtx::cache_lock"),
snap_lock("librbd::ImageCtx::snap_lock"),
int ImageCtx::register_watch() {
assert(!wctx);
wctx = new WatchCtx(this);
-
- int r = 0;
- do {
- md_lock.Lock();
- if (r == -ERANGE)
- ictx_refresh(this);
- uint64_t last_read = last_header_version;
- md_lock.Unlock();
-
- md_ctx.set_assert_version(last_read);
- r = md_ctx.watch(header_oid, 0, &(wctx->cookie), wctx);
- ldout(cct, 20) << "watching header object returned " << r << dendl;
- } while (r == -ERANGE);
- return r;
+ return md_ctx.watch(header_oid, 0, &(wctx->cookie), wctx);
}
void ImageCtx::unregister_watch() {
WatchCtx *wctx;
int refresh_seq; ///< sequence for refresh requests
int last_refresh; ///< last completed refresh
- uint64_t last_header_version; ///< last version of the header object
- ///< read from librados
/**
* Lock ordering:
lderr(cct) << "Error reading header: " << cpp_strerror(r) << dendl;
return r;
}
- ictx->last_header_version = ictx->md_ctx.get_last_version();
r = cls_client::old_snapshot_list(&ictx->md_ctx, ictx->header_oid,
&snap_names, &snap_sizes, &new_snapc);
if (r < 0) {
<< dendl;
return r;
}
- ictx->last_header_version = ictx->md_ctx.get_last_version();
uint64_t unsupported = incompatible_features & ~RBD_FEATURES_ALL;
if (unsupported) {