New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rbd: introduce v2 format for rbd export/import. #10487
Conversation
@dillaman |
@dillaman I found there is still some bug in this PR, so it's not ready for code-review. |
967dfa5
to
f46cb1e
Compare
@dillaman it passed my local manual testing now, please help to take a look. thanx |
e16ab22
to
7125613
Compare
src/tools/rbd/action/MergeDiff.cc
Outdated
@@ -196,7 +196,7 @@ static int do_merge_diff(const char *first, const char *second, | |||
} | |||
} | |||
|
|||
//We just handle the case like 'banner, [ftag], [ttag], stag, [wztag]*,etag', | |||
//We just handle the case like 'banner, [ftag], [ttag], [stag], [wztag]*, [etag]', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was an attempt to say that the "s" and "e" tags are not optional and the ones in the brackets are optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right. 👍
@yangdongsheng I'd recommend combining Export/ExportDiff and Import/ImportDiff into the same file now that they are going to be interdependent. |
@yangdongsheng It might be cleaner to just 100% re-use the existing export/import diff format for the export/import with snaps. Just create a new "v2" header to distinguish the new behavior that it might contain >1 snapshot segment. Then on import(diff), if it's a v2, it should keep looping when it gets to the end snapshot marker, then the next field should be a from snapshot marker, data, etc, end snapshot, etc. |
src/tools/rbd/action/Import.cc
Outdated
goto done; | ||
} | ||
// seek back to the beginning. | ||
lseek(fd, 0, SEEK_SET); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just set "import_snaps" to false here and eliminate the need for new_format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I am not sure what's your suggestion here, but I can explain the logic here more clear.
(1).import_snaps == true means --with-snaps is specified.
(2).(from_stdin == false )means importing something from file.
Then there are 3 possibility we will into this if statement.
(1). (import_snaps == true) and (from_stdin == true), in this case, when we found it's old format, because it's from stdin, we can't seek back, so return -EINVAL. That means, you have to make sure the you are accepting a new format importing stdin when you specify --with-snaps manually.
(2). (import_snaps == true) and (from_stdin == false), in this case, when we found it's a old format. we will lseek to the beginning, because it's from a fd. and the all data in file should be imported into image.
(3). (import_snaps == false) and (from_stdin == false), in this case, --with-snaps are not specified, and we are importing data from a file. then we try to check the banner at first, if we found it's old format. lseek to 0 to import it in old manner.
In this way, we can keep the backforwad compatability for the old format of export/exportdiff
7125613
to
9dedd83
Compare
bbc99e7
to
9a37724
Compare
Hi @dillaman sorry for the late update. Please help to take a look again. thanx |
@dillaman do you have a time to take a look at this PR? |
qa/workunits/rbd/import_export.sh
Outdated
rbd info testimg_import | ||
rbd info testimg_import@snap | ||
rm ${TMPDIR}/img | ||
rbd snap rm testimg_import@snap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compare the contents between snaps and image HEAD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey
src/librbd/ExclusiveLock.cc
Outdated
@@ -711,8 +711,11 @@ void ExclusiveLock<I>::handle_shutdown(int r) { | |||
|
|||
m_image_ctx.aio_work_queue->clear_require_lock_on_read(); | |||
m_image_ctx.aio_work_queue->unblock_writes(); | |||
m_image_ctx.image_watcher->flush(util::create_context_callback< | |||
ExclusiveLock<I>, &ExclusiveLock<I>::complete_shutdown>(this)); | |||
if (m_image_ctx.image_watcher == nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to make any changes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a segmentation fault without this change in "rbd export --with-snaps"
src/tools/rbd/action/Export.cc
Outdated
@@ -154,6 +213,8 @@ void get_arguments(po::options_description *positional, | |||
at::add_path_options(positional, options, | |||
"export file (or '-' for stdout)"); | |||
at::add_no_progress_option(options); | |||
options->add_options() | |||
("with-snaps", po::bool_switch(), "export snapshots at the same time"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: for some reason, "with-snaps" doesn't feel clear to me. Perhaps "--export-snapshots" or "--include-snapshots"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okey
src/tools/rbd/Utils.cc
Outdated
@@ -857,5 +857,265 @@ std::string timestr(time_t t) { | |||
return buf; | |||
} | |||
|
|||
int export_diff_fd(librbd::Image& image, const char *fromsnapname, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I would recommend combining Export.cc and ExportDiff.cc into the same file and then keeping the export_diff
and export_diff_fd
within the new combined Export.cc file. Same logic for Import.cc and ImportDiff.cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey.
src/tools/rbd/Utils.h
Outdated
#include <string> | ||
#include <boost/program_options.hpp> | ||
|
||
namespace rbd { | ||
namespace utils { | ||
|
||
static const std::string RBD_IMAGE_BANNER ("rbd image v1\n"); | ||
static const std::string RBD_IMAGE_SNAPS_BANNER ("rbd image snaps v1\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I can foresee wanted to eventually export other image attributes in addition to snapshots (e.g. features, metadata, etc). Therefore, perhaps it should be a v2 banner and then the export format should have a set of flag at the start that indicate what optional attributes have been included in the export (e.g. snapshots, features, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
src/tools/rbd/action/Export.cc
Outdated
if (with_snaps) { | ||
// header | ||
bufferlist bl; | ||
bl.append(utils::RBD_IMAGE_BANNER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: new RBD_IMAGE_BANNER_V2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okey
src/tools/rbd/action/Export.cc
Outdated
} | ||
|
||
if (r < 0) { | ||
if (with_snaps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you would first want to export the image starting at the first available snapshot via export_diff (i.e. only record the data that actually exists in the image), then iterating through all the available snapshots to generate diffs for each successive snapshot until you get to the specified head location. This would create a nice sparse export.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then we can't import a image without snaps in this case.
rbd export --with-snaps test test.export
rbd import test.import test.export
I mean, sometimes, we can get a exported image with snapshots, but we only want to import a full image from it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I name it as "with snaps" rather than "snaps mode". But yes, --include-snapshots sounds better. :)
src/tools/rbd/action/Import.cc
Outdated
if (from_stdin && (image_pos + (size_t)blklen) > size) { | ||
size *= 2; | ||
r = image.resize(size); | ||
lseek(fd, size, SEEK_CUR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like exported image has the full (non-sparse) image export which isn't used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this will be used when we import a image without --with-snaps. Sometimes, maybe we only want to import a full image even the snaps were exported already.
@yangdongsheng Sorry -- the comments were sitting in "pending" state for days since I forgot to publish them. |
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
…xport.sh Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
… importing test cases. Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
…port Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
…platform Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
…ff and import. Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
f50ff33
to
5b14582
Compare
the workunit change breaks the jewel-x-singleton test, see http://pulpito.ceph.com/kchai-2017-03-30_14:32:23-rados-wip-13999-kefu---basic-mira/966061/
|
@tchaikov Please open a tracker ticket -- this PR is already merged |
@dillaman sure, will do tomorrow. just wanted to give you guys a quick heads-up in case you run into this. |
@tchaikov It's a teuthology issue where the test case specifies that the "jewel" branch of the workunit should be used, but instead it downloads the "head" version (d463f52) of the workunit. Can't help but notice that particular commit changes the behavior of |
Fixes: http://tracker.ceph.com/issues/13186