]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge remote branch 'origin/wip-librbd-locking'
authorJosh Durgin <josh.durgin@inktank.com>
Tue, 18 Sep 2012 23:06:25 +0000 (16:06 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Tue, 18 Sep 2012 23:06:25 +0000 (16:06 -0700)
Conflicts:
qa/workunits/rbd/copy.sh

Reviewed-by: Sage Weil <sage.weil@inktank.com>
1  2 
qa/workunits/rbd/copy.sh
src/Makefile.am
src/cls_rbd.cc
src/librbd/internal.cc
src/rados.cc
src/rbd.cc
src/rgw/rgw_gc.cc
src/test/rbd/test_cls_rbd.cc
src/test/test_librbd.cc

index 7660991b2d2dde9c43da5171da90c945c88da0f7,94a7f33841534177e3600577218167d336f6ec27..ce916c92812a8e02d16bef26ec47e3bd0e8590a6
@@@ -148,51 -148,32 +148,77 @@@ test_remove() 
      rbd ls | wc -l | grep "^0$"
  }
  
+ test_locking() {
+     echo "testing locking..."
+     remove_images
+     rbd create -s 1 test1
+     rbd lock list test1 | wc -l | grep '^0$'
+     rbd lock add test1 id
+     rbd lock list test1 | grep ' 1 '
+     LOCKER=$(rbd lock list test1 | tail -n 1 | cut -f 1)
+     rbd lock remove test1 id $LOCKER
+     rbd lock list test1 | wc -l | grep '^0$'
+     rbd lock add test1 id --shared tag
+     rbd lock list test1 | grep ' 1 '
+     rbd lock add test1 id --shared tag
+     rbd lock list test1 | grep ' 2 '
+     rbd lock add test1 id2 --shared tag
+     rbd lock list test1 | grep ' 3 '
+     LOCKER=$(rbd lock list test1 | tail -n 1 | cut -f 1)
+     ID=$(rbd lock list test1 | tail -n 1 | cut -f 2)
+     rbd lock remove test1 $ID $LOCKER
+     # locks don't prevent you from removing an image,
+     # just from taking a lock
+     rbd rm test1
+ }
 +test_pool_image_args() {
 +    echo "testing pool and image args..."
 +    remove_images
 +
 +    ceph osd pool delete test || true
 +    ceph osd pool create test 100
 +    truncate -s 1 /tmp/empty
 +
 +    rbd ls | wc -l | grep 0
 +    rbd create -s 1 test1
 +    rbd ls | grep -q test1
 +    rbd import --image test2 /tmp/empty
 +    rbd ls | grep -q test2
 +    rbd --dest test3 import /tmp/empty
 +    rbd ls | grep -q test3
 +    rbd import /tmp/empty foo
 +    rbd ls | grep -q foo
 +
 +    rbd ls test | wc -l | grep 0
 +    rbd import /tmp/empty test/test1
 +    rbd ls test | grep -q test1
 +    rbd -p test import /tmp/empty test2
 +    rbd ls test | grep -q test2
 +    rbd --image test3 -p test import /tmp/empty
 +    rbd ls test | grep -q test3
 +    rbd --image test4 -p test import /tmp/empty
 +    rbd ls test | grep -q test4
 +    rbd --dest test5 -p test import /tmp/empty
 +    rbd ls test | grep -q test5
 +    rbd --dest test6 --dest-pool test import /tmp/empty
 +    rbd ls test | grep -q test6
 +    rbd --image test7 --dest-pool test import /tmp/empty
 +    rbd ls test | grep -q test7
 +    rbd --image test/test8 import /tmp/empty
 +    rbd ls test | grep -q test8
 +    rbd --dest test/test9 import /tmp/empty
 +    rbd ls test | grep -q test9
 +    rbd import --pool test /tmp/empty
 +    rbd ls test | grep -q empty
 +
 +    rm -f /tmp/empty
 +    ceph osd pool delete test
 +}
 +
 +test_import_args
  test_rename
  test_ls
  test_remove
diff --cc src/Makefile.am
Simple merge
diff --cc src/cls_rbd.cc
Simple merge
Simple merge
diff --cc src/rados.cc
Simple merge
diff --cc src/rbd.cc
index eb68d3a315ee060d1049db2e6b83a9d0c0b92158,b96d851de4952a7d8165473562d78dd1b78def2e..478b15e46a95679b75ae9dca95b6c202095083f1
@@@ -1258,12 -1351,23 +1348,26 @@@ int main(int argc, const char **argv
      return EXIT_FAILURE;
    }
  
 -  if (opt_cmd == OPT_IMPORT && !destname)
 -    destname = imgname_from_path(path);
 +  if (opt_cmd == OPT_IMPORT && !destname) {
 +    destname = imgname;
 +    if (!destname)
 +      destname = imgname_from_path(path);
 +  }
  
+   if (opt_cmd != OPT_LOCK_ADD && lock_tag) {
+     cerr << "error: only the lock add command uses the --shared option"
+        << std::endl;
+     usage();
+     return EXIT_FAILURE;
+   }
+   if ((opt_cmd == OPT_LOCK_ADD || opt_cmd == OPT_LOCK_REMOVE) &&
+       !lock_cookie) {
+     cerr << "error: lock id was not specified" << std::endl;
+     usage();
+     return EXIT_FAILURE;
+   }
    if (opt_cmd != OPT_LIST && opt_cmd != OPT_IMPORT && opt_cmd != OPT_UNMAP && opt_cmd != OPT_SHOWMAPPED &&
        !imgname) {
      cerr << "error: image name was not specified" << std::endl;
Simple merge
Simple merge
Simple merge