From 47ad28fecad34d55cc9565280e09e0a5e72045ee Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Sat, 11 May 2024 09:57:18 +0200 Subject: [PATCH] test/librbd/fsx: also check sizes in check_clone() Currently only data is checked, based on the size of the file. Check that the size of the image matches that. Signed-off-by: Ilya Dryomov --- src/test/librbd/fsx.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/test/librbd/fsx.cc b/src/test/librbd/fsx.cc index 1de97242da0f8..3cf971a23ac37 100644 --- a/src/test/librbd/fsx.cc +++ b/src/test/librbd/fsx.cc @@ -2853,6 +2853,7 @@ check_clone(int clonenum, bool replay_image) struct rbd_ctx cur_ctx = RBD_CTX_INIT; struct stat file_info; char *good_buf, *temp_buf; + uint64_t size; if (replay_image) { replay_imagename(imagename, sizeof(imagename), clonenum); @@ -2864,20 +2865,30 @@ check_clone(int clonenum, bool replay_image) prterrcode("check_clone: ops->open", ret); exit(167); } + if ((ret = ops->get_size(&cur_ctx, &size)) < 0) { + prterrcode("check_clone: ops->get_size", ret); + exit(167); + } clone_filename(filename, sizeof(filename), clonenum + 1); if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0) { prterrcode("check_clone: open", -errno); exit(168); } - - prt("checking clone #%d, image %s against file %s\n", - clonenum, imagename, filename); if (fstat(fd, &file_info) < 0) { prterrcode("check_clone: fstat", -errno); exit(169); } + prt("checking clone #%d, image %s against file %s\n", + clonenum, imagename, filename); + if (size != (uint64_t)file_info.st_size) { + prt("check_clone: image size 0x%llx != file size 0x%llx\n", + (unsigned long long)size, + (unsigned long long)file_info.st_size); + exit(175); + } + good_buf = NULL; ret = posix_memalign((void **)&good_buf, std::max(writebdy, (int)sizeof(void *)), -- 2.39.5