summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdike <jdike>2003-02-02 18:10:15 +0000
committerjdike <jdike>2003-02-02 18:10:15 +0000
commit9ccde2faf5d6d5370519e191b3d08d79c7e7c084 (patch)
tree42ce2cc922b0318ad6198424ce91b6e1caab32b5
parent42dfa5da8dd89169ddd4a5a5cf9d642ee06561aa (diff)
downloaduml-history-9ccde2faf5d6d5370519e191b3d08d79c7e7c084.tar.gz
Applied James McMechan's COW file creation speedup patch.
-rw-r--r--arch/um/drivers/ubd_user.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c
index 93b6f3e..a756059 100644
--- a/arch/um/drivers/ubd_user.c
+++ b/arch/um/drivers/ubd_user.c
@@ -389,10 +389,10 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
int sectorsize, int *bitmap_offset_out,
unsigned long *bitmap_len_out, int *data_offset_out)
{
- __u64 blocks;
- long zero;
- int err, fd, i;
+ __u64 offset;
+ int err, fd;
long long size;
+ char zero = 0;
flags.c = 1;
fd = open_ubd_file(cow_file, &flags, NULL, NULL, NULL, NULL, NULL);
@@ -406,22 +406,28 @@ int create_cow_file(char *cow_file, char *backing_file, struct openflags flags,
err = write_cow_header(cow_file, fd, backing_file, sectorsize, &size);
if(err) goto out_close;
- blocks = (size + sectorsize - 1) / sectorsize;
- blocks = (blocks + sizeof(long) * 8 - 1) / (sizeof(long) * 8);
- zero = 0;
- for(i = 0; i < blocks; i++){
- err = write(fd, &zero, sizeof(zero));
- if(err != sizeof(zero)){
- printk("Write of bitmap to new COW file '%s' failed, "
- "errno = %d\n", cow_file, errno);
- goto out_close;
- }
- }
-
sizes(size, sectorsize, sizeof(struct cow_header_v2),
bitmap_len_out, data_offset_out);
*bitmap_offset_out = sizeof(struct cow_header_v2);
+ offset = *data_offset_out + size - sizeof(zero);
+ err = os_seek_file(fd, offset);
+ if(err != 0){
+ printk("cow bitmap lseek failed : errno = %d\n", errno);
+ goto out_close;
+ }
+
+ /* does not really matter how much we write it is just to set EOF
+ * this also sets the entire COW bitmap
+ * to zero without having to allocate it
+ */
+ err = os_write_file(fd, &zero, sizeof(zero));
+ if(err != sizeof(zero)){
+ printk("Write of bitmap to new COW file '%s' failed, "
+ "errno = %d\n", cow_file, errno);
+ goto out_close;
+ }
+
return(fd);
out_close: