Re: [patch] rewrite rd

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Nick Piggin
Date: Tuesday, December 4, 2007 - 12:08 am

On Tue, Dec 04, 2007 at 08:01:31AM +0100, Nick Piggin wrote:
 

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);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch] rewrite rd, Nick Piggin, (Mon Dec 3, 9:26 pm)
Re: [patch] rewrite rd, Andrew Morton, (Mon Dec 3, 11:29 pm)
Re: [patch] rewrite rd, Nick Piggin, (Tue Dec 4, 12:01 am)
Re: [patch] rewrite rd, Nick Piggin, (Tue Dec 4, 12:08 am)
Re: [patch] rewrite rd, Rob Landley, (Tue Dec 4, 12:55 am)
Re: [patch] rewrite rd, Nick Piggin, (Tue Dec 4, 2:29 am)
Re: [patch] rewrite rd, Christian Borntraeger, (Tue Dec 4, 2:54 am)
Re: [patch] rewrite rd, Nick Piggin, (Tue Dec 4, 3:10 am)
[patch] rd: support XIP, Nick Piggin, (Tue Dec 4, 4:21 am)
[patch] ext2: xip check fix, Nick Piggin, (Tue Dec 4, 4:23 am)
Re: [patch] rd: support XIP, Andrew Morton, (Tue Dec 4, 4:26 am)
Re: [patch] rd: support XIP, Nick Piggin, (Tue Dec 4, 4:35 am)
Re: [patch] rd: support XIP, Duane Griffin, (Tue Dec 4, 5:06 am)
[patch] mm: fix XIP file writes, Nick Piggin, (Tue Dec 4, 6:00 am)
[patch] rd: support XIP (updated), Nick Piggin, (Tue Dec 4, 6:03 am)
Re: [patch] rewrite rd, Rob Landley, (Tue Dec 4, 12:53 pm)
Re: [patch] ext2: xip check fix, Carsten Otte, (Wed Dec 5, 8:43 am)
Re: [patch] ext2: xip check fix, Nick Piggin, (Wed Dec 5, 4:33 pm)
Re: [patch] ext2: xip check fix, Carsten Otte, (Thu Dec 6, 1:43 am)
Re: [patch] ext2: xip check fix, Nick Piggin, (Thu Dec 6, 1:52 am)
Re: [patch] ext2: xip check fix, Carsten Otte, (Thu Dec 6, 2:59 am)
Re: [patch] ext2: xip check fix, Nick Piggin, (Thu Dec 6, 3:18 am)
Re: [patch] ext2: xip check fix, Carsten Otte, (Thu Dec 6, 3:24 am)
Re: [patch] ext2: xip check fix, Rob Landley, (Thu Dec 6, 11:11 am)
Re: [patch] ext2: xip check fix, Jared Hulbert, (Thu Dec 6, 8:22 pm)
Re: [patch] ext2: xip check fix, Rob Landley, (Thu Dec 6, 9:17 pm)
Re: [patch] ext2: xip check fix, Nick Piggin, (Thu Dec 6, 9:23 pm)
Re: [patch] ext2: xip check fix, Jared Hulbert, (Thu Dec 6, 9:40 pm)
Re: [patch] ext2: xip check fix, Carsten Otte, (Fri Dec 7, 1:59 am)
Re: [patch] ext2: xip check fix, Jared Hulbert, (Fri Dec 7, 2:52 am)
Re: [patch] mm: fix XIP file writes, Christian Borntraeger, (Mon Dec 10, 7:38 am)
Re: [patch] mm: fix XIP file writes, Nick Piggin, (Tue Dec 11, 9:03 pm)
Re: [patch] rewrite rd, Matthew Wilcox, (Mon Jan 14, 9:47 am)
Re: [patch] rewrite rd, Jens Axboe, (Mon Jan 14, 10:21 am)