Merge pull request #38985 from orozery/rbd-nbd-luks2-blksize

tools/rbd-nbd: change block size to 4K for LUKS2 images

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2021-01-21 15:06:20 -05:00 committed by GitHub
commit 21bc198918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1009,7 +1009,8 @@ static int parse_nbd_index(const std::string& devpath)
return index;
}
static int try_ioctl_setup(Config *cfg, int fd, uint64_t size, uint64_t flags)
static int try_ioctl_setup(Config *cfg, int fd, uint64_t size,
uint64_t blksize, uint64_t flags)
{
int index = 0, r;
@ -1072,7 +1073,7 @@ static int try_ioctl_setup(Config *cfg, int fd, uint64_t size, uint64_t flags)
}
}
r = ioctl(nbd, NBD_SET_BLKSIZE, RBD_NBD_BLKSIZE);
r = ioctl(nbd, NBD_SET_BLKSIZE, blksize);
if (r < 0) {
r = -errno;
cerr << "rbd-nbd: NBD_SET_BLKSIZE failed" << std::endl;
@ -1560,6 +1561,7 @@ static int do_map(int argc, const char *argv[], Config *cfg, bool reconnect)
int read_only = 0;
unsigned long flags;
unsigned long size;
unsigned long blksize = RBD_NBD_BLKSIZE;
bool use_netlink;
int fd[2];
@ -1677,6 +1679,7 @@ static int do_map(int argc, const char *argv[], Config *cfg, bool reconnect)
opts.passphrase = passphrase;
r = image.encryption_load(
RBD_ENCRYPTION_FORMAT_LUKS2, &opts, sizeof(opts));
blksize = 4096;
break;
}
default:
@ -1728,7 +1731,7 @@ static int do_map(int argc, const char *argv[], Config *cfg, bool reconnect)
}
if (!use_netlink) {
r = try_ioctl_setup(cfg, fd[0], size, flags);
r = try_ioctl_setup(cfg, fd[0], size, blksize, flags);
if (r < 0)
goto free_server;
}