From: Ilya Dryomov Date: Sat, 11 May 2024 07:57:18 +0000 (+0200) Subject: test/librbd/fsx: also check sizes in check_clone() X-Git-Tag: v20.0.0~1907^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=47ad28fecad34d55cc9565280e09e0a5e72045ee;p=ceph.git 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 --- diff --git a/src/test/librbd/fsx.cc b/src/test/librbd/fsx.cc index 1de97242da0..3cf971a23ac 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 *)),