Commit 6c29256c authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: allow ubd devices to be shared in a cluster

This adds a 'c' option to the ubd switch which turns off host file locking so
that the device can be shared, as with a cluster.  There's also some
whitespace cleanup while I was in this file.
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cf9165a5
......@@ -71,7 +71,7 @@ struct io_thread_req {
int error;
};
extern int open_ubd_file(char *file, struct openflags *openflags,
extern int open_ubd_file(char *file, struct openflags *openflags, int shared,
char **backing_file_out, int *bitmap_offset_out,
unsigned long *bitmap_len_out, int *data_offset_out,
int *create_cow_out);
......@@ -168,6 +168,7 @@ struct ubd {
__u64 size;
struct openflags boot_openflags;
struct openflags openflags;
int shared;
int no_cow;
struct cow cow;
struct platform_device pdev;
......@@ -189,6 +190,7 @@ struct ubd {
.boot_openflags = OPEN_FLAGS, \
.openflags = OPEN_FLAGS, \
.no_cow = 0, \
.shared = 0, \
.cow = DEFAULT_COW, \
}
......@@ -351,7 +353,7 @@ static int ubd_setup_common(char *str, int *index_out)
if (index_out)
*index_out = n;
for (i = 0; i < 4; i++) {
for (i = 0; i < sizeof("rscd="); i++) {
switch (*str) {
case 'r':
flags.w = 0;
......@@ -362,11 +364,14 @@ static int ubd_setup_common(char *str, int *index_out)
case 'd':
dev->no_cow = 1;
break;
case 'c':
dev->shared = 1;
break;
case '=':
str++;
goto break_loop;
default:
printk(KERN_ERR "ubd_setup : Expected '=' or flag letter (r,s or d)\n");
printk(KERN_ERR "ubd_setup : Expected '=' or flag letter (r, s, c, or d)\n");
goto out;
}
str++;
......@@ -567,9 +572,10 @@ static int ubd_open_dev(struct ubd *dev)
create_cow = 0;
create_ptr = (dev->cow.file != NULL) ? &create_cow : NULL;
back_ptr = dev->no_cow ? NULL : &dev->cow.file;
dev->fd = open_ubd_file(dev->file, &dev->openflags, back_ptr,
&dev->cow.bitmap_offset, &dev->cow.bitmap_len,
&dev->cow.data_offset, create_ptr);
dev->fd = open_ubd_file(dev->file, &dev->openflags, dev->shared,
back_ptr, &dev->cow.bitmap_offset,
&dev->cow.bitmap_len, &dev->cow.data_offset,
create_ptr);
if((dev->fd == -ENOENT) && create_cow){
dev->fd = create_cow_file(dev->file, dev->cow.file,
......@@ -606,8 +612,8 @@ static int ubd_open_dev(struct ubd *dev)
flags = dev->openflags;
flags.w = 0;
err = open_ubd_file(dev->cow.file, &flags, NULL, NULL, NULL,
NULL, NULL);
err = open_ubd_file(dev->cow.file, &flags, dev->shared, NULL,
NULL, NULL, NULL, NULL);
if(err < 0) goto error;
dev->cow.fd = err;
}
......@@ -1182,7 +1188,7 @@ int read_cow_bitmap(int fd, void *buf, int offset, int len)
return(0);
}
int open_ubd_file(char *file, struct openflags *openflags,
int open_ubd_file(char *file, struct openflags *openflags, int shared,
char **backing_file_out, int *bitmap_offset_out,
unsigned long *bitmap_len_out, int *data_offset_out,
int *create_cow_out)
......@@ -1206,11 +1212,15 @@ int open_ubd_file(char *file, struct openflags *openflags,
return fd;
}
if(shared)
printk("Not locking \"%s\" on the host\n", file);
else {
err = os_lock_file(fd, openflags->w);
if(err < 0){
printk("Failed to lock '%s', err = %d\n", file, -err);
goto out_close;
}
}
/* Succesful return case! */
if(backing_file_out == NULL)
......@@ -1260,7 +1270,7 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
int err, fd;
flags.c = 1;
fd = open_ubd_file(cow_file, &flags, NULL, NULL, NULL, NULL, NULL);
fd = open_ubd_file(cow_file, &flags, 0, NULL, NULL, NULL, NULL, NULL);
if(fd < 0){
err = fd;
printk("Open of COW file '%s' failed, errno = %d\n", cow_file,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment