From: Jeff Garzik <jgarzik@mandrakesoft.com>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@transmeta.com>,
viro@math.psu.edu, William Stearns <wstearns@pobox.com>
Subject: PATCH 2.4.0.11.4: loopback block device fixes
Date: Tue, 14 Nov 2000 16:21:33 -0500 [thread overview]
Message-ID: <200011142121.QAA01124@havoc.gtf.org> (raw)
Since I am not a block device expert, I am interested to know if
these fixes look ok, and if they fix the reported loopback deadlocks.
I added calls to deactive_page and flush_dcache_page, and made sure
that any error returns were propagated back to the caller.
This is UNTESTED but it looks ok to me [a blkdev newbie...]
Comments appreciated.
Jeff
Index: drivers/block/loop.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/block/loop.c,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 loop.c
--- drivers/block/loop.c 2000/11/10 02:10:21 1.1.1.8
+++ drivers/block/loop.c 2000/11/14 21:17:27
@@ -56,7 +56,8 @@
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/major.h>
-
+#include <linux/mm.h>
+#include <linux/swap.h>
#include <linux/init.h>
#include <linux/devfs_fs_kernel.h>
@@ -178,6 +179,7 @@
char *kaddr;
unsigned long index;
unsigned size, offset;
+ int ret;
index = pos >> PAGE_CACHE_SHIFT;
offset = pos & (PAGE_CACHE_SIZE - 1);
@@ -188,14 +190,23 @@
size = len;
page = grab_cache_page(mapping, index);
- if (!page)
+ if (!page) {
+ ret = -ENOMEM;
goto fail;
- if (aops->prepare_write(file, page, offset, offset+size))
+ }
+ /* We have exclusive IO access to the page.. */
+ if (!PageLocked(page))
+ PAGE_BUG(page);
+ ret = aops->prepare_write(file, page, offset, offset+size);
+ if (ret)
goto unlock;
kaddr = page_address(page);
- if ((lo->transfer)(lo, WRITE, kaddr+offset, data, size, IV))
+ ret = (lo->transfer)(lo, WRITE, kaddr+offset, data, size, IV);
+ flush_dcache_page(page);
+ if (ret)
goto write_fail;
- if (aops->commit_write(file, page, offset, offset+size))
+ ret = aops->commit_write(file, page, offset, offset+size);
+ if (ret)
goto unlock;
data += size;
len -= size;
@@ -203,6 +214,7 @@
index++;
pos += size;
UnlockPage(page);
+ deactivate_page(page);
page_cache_release(page);
}
return 0;
@@ -213,9 +225,10 @@
kunmap(page);
unlock:
UnlockPage(page);
+ deactivate_page(page);
page_cache_release(page);
fail:
- return -1;
+ return ret;
}
struct lo_read_data {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next reply other threads:[~2000-11-14 21:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-14 21:21 Jeff Garzik [this message]
2000-11-14 21:57 ` PATCH 2.4.0.11.4: loopback block device fixes Alexander Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200011142121.QAA01124@havoc.gtf.org \
--to=jgarzik@mandrakesoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
--cc=viro@math.psu.edu \
--cc=wstearns@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).