Skip to content

Commit d921a00

Browse files
committed
Merged code for xlvhd thin-provisioning
GitHub: closes #168
2 parents 2417d53 + 162eb4f commit d921a00

32 files changed

+2028
-29
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
SUBDIRS = lvm
77
SUBDIRS += $(MAYBE_part)
88
SUBDIRS += vhd
9+
SUBDIRS += thin
910
SUBDIRS += control
1011
SUBDIRS += drivers
1112
SUBDIRS += include

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@ control/Makefile
8080
drivers/Makefile
8181
include/Makefile
8282
tapback/Makefile
83+
thin/Makefile
8384
])
8485
AC_OUTPUT

control/tap-ctl-create.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
int
3232
tap_ctl_create(const char *params, char **devname, int flags, int parent_minor,
33-
char *secondary, int timeout)
33+
char *secondary, int timeout, int alloc_quantum)
3434
{
3535
int err, id, minor;
3636

@@ -49,7 +49,7 @@ tap_ctl_create(const char *params, char **devname, int flags, int parent_minor,
4949
goto destroy;
5050

5151
err = tap_ctl_open(id, minor, params, flags, parent_minor, secondary,
52-
timeout);
52+
timeout, alloc_quantum);
5353
if (err)
5454
goto detach;
5555

control/tap-ctl-open.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030

3131
int
3232
tap_ctl_open(const int id, const int minor, const char *params, int flags,
33-
const int prt_minor, const char *secondary, int timeout)
33+
const int prt_minor, const char *secondary, int timeout,
34+
int alloc_quantum)
3435
{
3536
int err;
3637
tapdisk_message_t message;
@@ -41,6 +42,7 @@ tap_ctl_open(const int id, const int minor, const char *params, int flags,
4142
message.u.params.devnum = minor;
4243
message.u.params.prt_devnum = prt_minor;
4344
message.u.params.req_timeout = timeout;
45+
message.u.params.alloc_quantum = alloc_quantum;
4446
message.u.params.flags = flags;
4547

4648
err = snprintf(message.u.params.path,

control/tap-ctl.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,16 @@ tap_cli_create_usage(FILE *stream)
252252
"[-r turn on read caching into leaf node] [-2 <path> "
253253
"use secondary image (in mirror mode if no -s)] [-s "
254254
"fail over to the secondary image on ENOSPC] "
255-
"[-t request timeout in seconds] [-D no O_DIRECT]\n");
255+
"[-t request timeout in seconds] [-D no O_DIRECT] "
256+
"[-T enable thin provisioning] "
257+
"[-q allocation quantum in MBytes]\n");
258+
256259
}
257260

258261
static int
259262
tap_cli_create(int argc, char **argv)
260263
{
261-
int c, err, flags, prt_minor, timeout;
264+
int c, err, flags, prt_minor, timeout, alloc_quantum;
262265
char *args, *devname, *secondary;
263266

264267
args = NULL;
@@ -267,9 +270,10 @@ tap_cli_create(int argc, char **argv)
267270
prt_minor = -1;
268271
flags = 0;
269272
timeout = 0;
273+
alloc_quantum = 0;
270274

271275
optind = 0;
272-
while ((c = getopt(argc, argv, "a:RDd:e:r2:st:h")) != -1) {
276+
while ((c = getopt(argc, argv, "a:RDd:e:r2:st:Tq:h")) != -1) {
273277
switch (c) {
274278
case 'a':
275279
args = optarg;
@@ -300,6 +304,12 @@ tap_cli_create(int argc, char **argv)
300304
case 't':
301305
timeout = atoi(optarg);
302306
break;
307+
case 'T':
308+
flags |= TAPDISK_MESSAGE_FLAG_THIN;
309+
break;
310+
case 'q':
311+
alloc_quantum = atoi(optarg);
312+
break;
303313
case '?':
304314
goto usage;
305315
case 'h':
@@ -312,7 +322,7 @@ tap_cli_create(int argc, char **argv)
312322
goto usage;
313323

314324
err = tap_ctl_create(args, &devname, flags, prt_minor, secondary,
315-
timeout);
325+
timeout, alloc_quantum);
316326
if (!err)
317327
printf("%s\n", devname);
318328

@@ -717,14 +727,16 @@ tap_cli_open_usage(FILE *stream)
717727
"[-r turn on read caching into leaf node] [-2 <path> "
718728
"use secondary image (in mirror mode if no -s)] [-s "
719729
"fail over to the secondary image on ENOSPC] "
720-
"[-t request timeout in seconds] [-D no O_DIRECT]\n");
730+
"[-t request timeout in seconds] [-D no O_DIRECT] "
731+
"[-T enable thin provisioning] "
732+
"[-q allocation quantum in MBytes]\n");
721733
}
722734

723735
static int
724736
tap_cli_open(int argc, char **argv)
725737
{
726738
const char *args, *secondary;
727-
int c, pid, minor, flags, prt_minor, timeout;
739+
int c, pid, minor, flags, prt_minor, timeout, alloc_quantum;
728740

729741
flags = 0;
730742
pid = -1;
@@ -733,9 +745,11 @@ tap_cli_open(int argc, char **argv)
733745
timeout = 0;
734746
args = NULL;
735747
secondary = NULL;
748+
alloc_quantum = 0;
749+
736750

737751
optind = 0;
738-
while ((c = getopt(argc, argv, "a:RDm:p:e:r2:st:h")) != -1) {
752+
while ((c = getopt(argc, argv, "a:RDm:p:e:r2:st:Tq:h")) != -1) {
739753
switch (c) {
740754
case 'p':
741755
pid = atoi(optarg);
@@ -769,6 +783,12 @@ tap_cli_open(int argc, char **argv)
769783
case 't':
770784
timeout = atoi(optarg);
771785
break;
786+
case 'T':
787+
flags |= TAPDISK_MESSAGE_FLAG_THIN;
788+
break;
789+
case 'q':
790+
alloc_quantum = atoi(optarg);
791+
break;
772792
case '?':
773793
goto usage;
774794
case 'h':
@@ -781,7 +801,7 @@ tap_cli_open(int argc, char **argv)
781801
goto usage;
782802

783803
return tap_ctl_open(pid, minor, args, flags, prt_minor, secondary,
784-
timeout);
804+
timeout, alloc_quantum);
785805

786806
usage:
787807
tap_cli_open_usage(stderr);

drivers/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ libtapdisk_la_SOURCES += td-stats.c
100100
libtapdisk_la_SOURCES += td-stats.h
101101

102102
libtapdisk_la_LIBADD = ../vhd/lib/libvhd.la
103+
libtapdisk_la_LIBADD += ../thin/libtapdiskthin.la
103104
libtapdisk_la_LIBADD += -laio
104105
libtapdisk_la_LIBADD += -lxenctrl
105106

0 commit comments

Comments
 (0)