From 03cade4b83b237e794032071a54a1cc86dee5b30 Mon Sep 17 00:00:00 2001 From: "sf@psjt.org" Date: Sat, 11 Dec 2010 01:27:45 +0100 Subject: [PATCH] 10 TByte partition MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Moin! The attached patch allows to run a 16TB nbd partition on a 32-bit system. Gruß, Stephan --- nbd-client.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/nbd-client.c b/nbd-client.c index 9d725ca..0fc9c34 100644 --- a/nbd-client.c +++ b/nbd-client.c @@ -180,11 +180,11 @@ void negotiate(int sock, u64 *rsize64, u32 *flags, char* name) { size64 = ntohll(size64); #ifdef NBD_SET_SIZE_BLOCKS - if ((size64>>10) > (~0UL >> 1)) { + if ((size64>>12) > (uint64_t)~0UL) { printf("size = %luMB", (unsigned long)(size64>>20)); err("Exported device is too big for me. Get 64-bit machine :-(\n"); } else - printf("size = %luKB", (unsigned long)(size64>>10)); + printf("size = %luMB", (unsigned long)(size64>>20)); #else if (size64 > (~0UL >> 1)) { printf("size = %luKB", (unsigned long)(size64>>10)); @@ -215,16 +215,18 @@ void setsizes(int nbd, u64 size64, int blocksize, u32 flags) { int read_only = (flags & NBD_FLAG_READ_ONLY) ? 1 : 0; #ifdef NBD_SET_SIZE_BLOCKS - if (size64/blocksize > (~0UL >> 1)) + if (size64>>12 > (uint64_t)~0UL) err("Device too large.\n"); else { int er; - if (ioctl(nbd, NBD_SET_BLKSIZE, (unsigned long)blocksize) < 0) + if (ioctl(nbd, NBD_SET_BLKSIZE, 4096UL) < 0) err("Ioctl/1.1a failed: %m\n"); - size = (unsigned long)(size64/blocksize); + size = (unsigned long)(size64>>12); if ((er = ioctl(nbd, NBD_SET_SIZE_BLOCKS, size)) < 0) err("Ioctl/1.1b failed: %m\n"); - fprintf(stderr, "bs=%d, sz=%lu\n", blocksize, size); + if (ioctl(nbd, NBD_SET_BLKSIZE, (unsigned long)blocksize) < 0) + err("Ioctl/1.1c failed: %m\n"); + fprintf(stderr, "bs=%d, sz=%llu bytes\n", blocksize, 4096ULL*size); } #else if (size64 > (~0UL >> 1)) { -- 1.7.10.4