Permalink
Browse files

Merge remote branch 'origin/wip-rbd-watch'

Reviewed-by: Dan Mick <dan.mick@inktank.com>
  • Loading branch information...
2 parents f1e0305 + c4370ff commit 6a3d475cf08eb3051e8cdbce10b17b53c92b9cb5 @jdurgin jdurgin committed Jan 4, 2013
Showing with 15 additions and 60 deletions.
  1. +0 −31 qa/workunits/rbd/watch_correct_version.sh
  2. +1 −15 src/librbd/ImageCtx.cc
  3. +0 −2 src/librbd/ImageCtx.h
  4. +14 −12 src/librbd/internal.cc
@@ -1,31 +0,0 @@
-#!/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
View
@@ -39,7 +39,6 @@ namespace librbd {
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"),
@@ -556,20 +555,7 @@ namespace librbd {
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() {
View
@@ -54,8 +54,6 @@ namespace librbd {
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:
View
@@ -1601,7 +1601,6 @@ namespace librbd {
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) {
@@ -1639,7 +1638,6 @@ namespace librbd {
<< dendl;
return r;
}
- ictx->last_header_version = ictx->md_ctx.get_last_version();
uint64_t unsupported = incompatible_features & ~RBD_FEATURES_ALL;
if (unsupported) {
@@ -1915,25 +1913,29 @@ namespace librbd {
if (r < 0)
return r;
- ictx->md_lock.Lock();
- r = ictx_refresh(ictx);
- ictx->md_lock.Unlock();
- if (r < 0)
- return r;
-
- _snap_set(ictx, ictx->snap_name.c_str());
-
if (!ictx->read_only) {
r = ictx->register_watch();
if (r < 0) {
lderr(ictx->cct) << "error registering a watch: " << cpp_strerror(r)
<< dendl;
- close_image(ictx);
- return r;
+ goto err_close;
}
}
+ ictx->md_lock.Lock();
+ r = ictx_refresh(ictx);
+ ictx->md_lock.Unlock();
+ if (r < 0)
+ goto err_close;
+
+ if ((r = _snap_set(ictx, ictx->snap_name.c_str())) < 0)
+ goto err_close;
+
return 0;
+
+ err_close:
+ close_image(ictx);
+ return r;
}
void close_image(ImageCtx *ictx)

0 comments on commit 6a3d475

Please sign in to comment.