[dm-devel] Re: [RFC] File backed target for device-mapper

Christophe Saout christophe at saout.de
Fri Jul 25 19:50:01 UTC 2003


Am Di, 2003-07-22 um 23.39 schrieb Christophe Saout:

> > I just wrote a dm target uses a file as backend instead of another block
> > device.
>
> Umm... lalala... (a cleanup and a *fix*) :D

So, another patch on top of that. A small cleanup and three bugfixes
(avoid the worker thread to be accidentally killed by a signal, fix its
shutdown procedure and add a missing offset).

--
Christophe Saout <christophe at saout.de>
Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
-------------- next part --------------
--- dm-file.c.orig	2003-07-26 02:46:58.731720680 +0200
+++ dm-file.c	2003-07-26 02:47:36.217022048 +0200
@@ -116,7 +116,7 @@
 		int r;
 
 		/*
-		 * No need do use that handy bio_kmap_irq macro since we are always
+		 * No need do use that handy bvec_kmap_irq macro since we are always
 		 * alled in a non-irq context (from our worker thread actually)
 		 */
 		data = kmap(bv->bv_page) + bv->bv_offset,
@@ -135,7 +135,7 @@
  * Handles a bio_vec as a file write operation
  */
 static int fileio_write_bvec(struct file_c *fc, struct bio_vec *bv,
-                             int blocksize, loff_t pos)
+                             loff_t pos)
 {
 	struct file *file = fc->file;
 	struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
@@ -151,7 +151,7 @@
 	offset = pos & ((pgoff_t)PAGE_CACHE_SIZE - 1);
 
 	down(&mapping->host->i_sem);
-	while(len > 0) {
+	while (len > 0) {
 		size = PAGE_CACHE_SIZE - offset;
 		if (size > len)
 			size = len;
@@ -160,15 +160,15 @@
 		if (!page)
 			goto fail;
 
-		if (aops->prepare_write(file, page, offset, offset+size))
+		if (aops->prepare_write(file, page, offset, offset + size))
 			goto unlock;
 
-		dst = kmap(page);
+		dst = kmap(page) + offset;
 		memcpy(dst, src, size);
 		flush_dcache_page(page);
 		kunmap(page);
 
-		if (aops->commit_write(file, page, offset, offset+size))
+		if (aops->commit_write(file, page, offset, offset + size))
 			goto unlock;
 
 		src += size;
@@ -199,7 +199,6 @@
 static int fileio_write(struct file_c *fc, struct bio *bio, loff_t pos)
 {
 	struct bio_vec *bv;
-	int blocksize = fc->file->f_dentry->d_inode->i_blksize;
 	int i;
 
 	bio_for_each_segment(bv, bio, i) {
@@ -207,11 +206,11 @@
 		int r;
 
 		/*
-		 * No need do use that handy bio_kmap_irq macro since we are always
+		 * No need do use that handy bvec_kmap_irq macro since we are always
 		 * alled in a non-irq context (from our worker thread actually)
 		 */
 		data = kmap(bv->bv_page) + bv->bv_offset,
-		r = fileio_write_bvec(fc, bv, blocksize, pos);
+		r = fileio_write_bvec(fc, bv, pos);
 		kunmap(bv->bv_page);
 
 		if (r < 0)
@@ -241,7 +240,7 @@
 	up(&fc->sem);
 
 	while (1) {
-		down_interruptible(&fc->bh_mutex);
+		while (down_interruptible(&fc->bh_mutex) == -EINTR);
 
 		bio = fileio_next_bio(fc);
 
@@ -376,6 +375,7 @@
 	init_MUTEX_LOCKED(&fc->bh_mutex);
 
 	kernel_thread(fileio_thread, fc, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
+	down(&fc->sem);
 
 	ti->private = fc;
 	return 0;


More information about the dm-devel mailing list