Skip to content

Commit

Permalink
rbd: allow copy of zero-length images. Includes simple test.
Browse files Browse the repository at this point in the history
Fixes: #3765
Signed-off-by: Dan Mick <dan.mick@inktank.com>
  • Loading branch information
Dan Mick committed Jan 10, 2013
1 parent 1c3d684 commit 00898c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions qa/workunits/rbd/copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ test_others() {
rbd export testimg1 /tmp/img1.snap1
cmp /tmp/img2 /tmp/img1.snap1

# test create, copy of zero-length images
rbd rm testimg2
rbd rm testimg3
rbd create testimg2 -s 0
rbd cp testimg2 testimg3

# remove snapshots
rbd snap rm --snap=snap1 testimg1
rbd info --snap=snap1 testimg1 2>&1 | grep 'error setting snapshot context: (2) No such file or directory'
Expand Down
4 changes: 4 additions & 0 deletions src/librbd/internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,10 @@ namespace librbd {
if (!snap_exists)
return -ENOENT;

// special-case "len == 0" requests: always valid
if (*len == 0)
return 0;

// can't start past end
if (off >= image_size)
return -EINVAL;
Expand Down

0 comments on commit 00898c1

Please sign in to comment.