From: Nick Piggin <npiggin@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-fsdevel@vger.kernel.org,
Christian Borntraeger <borntraeger@de.ibm.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
rob@landley.net, Jens Axboe <axboe@kernel.dk>
Subject: Re: [patch] rewrite rd
Date: Tue, 4 Dec 2007 08:08:56 +0100 [thread overview]
Message-ID: <20071204070856.GF31482@wotan.suse.de> (raw)
In-Reply-To: <20071204070131.GE31482@wotan.suse.de>
On Tue, Dec 04, 2007 at 08:01:31AM +0100, Nick Piggin wrote:
> Thanks for the review, I'll post an incremental patch in a sec.
Index: linux-2.6/drivers/block/brd.c
===================================================================
--- linux-2.6.orig/drivers/block/brd.c
+++ linux-2.6/drivers/block/brd.c
@@ -56,7 +56,7 @@ struct brd_device {
*/
static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector)
{
- unsigned long idx;
+ pgoff_t idx;
struct page *page;
/*
@@ -87,13 +87,17 @@ static struct page *brd_lookup_page(stru
*/
static struct page *brd_insert_page(struct brd_device *brd, sector_t sector)
{
- unsigned long idx;
+ pgoff_t idx;
struct page *page;
page = brd_lookup_page(brd, sector);
if (page)
return page;
+ /*
+ * Must use NOIO because we don't want to recurse back into the
+ * block or filesystem layers from page reclaim.
+ */
page = alloc_page(GFP_NOIO | __GFP_HIGHMEM | __GFP_ZERO);
if (!page)
return NULL;
@@ -148,6 +152,11 @@ static void brd_free_pages(struct brd_de
pos++;
+ /*
+ * This assumes radix_tree_gang_lookup always returns as
+ * many pages as possible. If the radix-tree code changes,
+ * so will this have to.
+ */
} while (nr_pages == FREE_BATCH);
}
@@ -159,7 +168,7 @@ static int copy_to_brd_setup(struct brd_
unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
size_t copy;
- copy = min((unsigned long)n, PAGE_SIZE - offset);
+ copy = min_t(size_t, n, PAGE_SIZE - offset);
if (!brd_insert_page(brd, sector))
return -ENOMEM;
if (copy < n) {
@@ -181,7 +190,7 @@ static void copy_to_brd(struct brd_devic
unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
size_t copy;
- copy = min((unsigned long)n, PAGE_SIZE - offset);
+ copy = min_t(size_t, n, PAGE_SIZE - offset);
page = brd_lookup_page(brd, sector);
BUG_ON(!page);
@@ -213,7 +222,7 @@ static void copy_from_brd(void *dst, str
unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
size_t copy;
- copy = min((unsigned long)n, PAGE_SIZE - offset);
+ copy = min_t(size_t, n, PAGE_SIZE - offset);
page = brd_lookup_page(brd, sector);
if (page) {
src = kmap_atomic(page, KM_USER1);
@@ -318,6 +327,9 @@ static int brd_ioctl(struct inode *inode
/*
* Invalidate the cache first, so it isn't written
* back to the device.
+ *
+ * Another thread might instantiate more buffercache here,
+ * but there is not much we can do to close that race.
*/
invalidate_bh_lrus();
truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
next prev parent reply other threads:[~2007-12-04 7:09 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-04 4:26 [patch] rewrite rd Nick Piggin
2007-12-04 4:26 ` Nick Piggin
2007-12-04 6:29 ` Andrew Morton
2007-12-04 7:01 ` Nick Piggin
2007-12-04 7:08 ` Nick Piggin [this message]
2007-12-04 7:55 ` Rob Landley
2007-12-04 9:29 ` Nick Piggin
2007-12-04 19:53 ` Rob Landley
2007-12-04 9:54 ` Christian Borntraeger
2007-12-04 10:10 ` Nick Piggin
2007-12-04 11:21 ` [patch] rd: support XIP Nick Piggin
2007-12-04 11:23 ` [patch] ext2: xip check fix Nick Piggin
2007-12-05 15:43 ` Carsten Otte
2007-12-05 23:33 ` Nick Piggin
2007-12-06 8:43 ` Carsten Otte
2007-12-06 8:52 ` Nick Piggin
2007-12-06 9:59 ` Carsten Otte
2007-12-06 10:18 ` Nick Piggin
2007-12-06 10:24 ` Carsten Otte
2007-12-06 18:11 ` Rob Landley
2007-12-07 3:22 ` Jared Hulbert
2007-12-07 4:17 ` Rob Landley
2007-12-07 4:23 ` Nick Piggin
2007-12-07 4:40 ` Jared Hulbert
2007-12-07 8:59 ` Carsten Otte
2007-12-07 9:52 ` Jared Hulbert
2007-12-04 11:26 ` [patch] rd: support XIP Andrew Morton
2007-12-04 11:35 ` Nick Piggin
2007-12-04 13:00 ` [patch] mm: fix XIP file writes Nick Piggin
2007-12-10 14:38 ` Christian Borntraeger
2007-12-12 4:03 ` Nick Piggin
2007-12-04 12:06 ` [patch] rd: support XIP Duane Griffin
2007-12-04 13:03 ` [patch] rd: support XIP (updated) Nick Piggin
2008-01-14 16:47 ` [patch] rewrite rd Matthew Wilcox
2008-01-14 17:21 ` Jens Axboe
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=20071204070856.GF31482@wotan.suse.de \
--to=npiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=borntraeger@de.ibm.com \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rob@landley.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.