[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0709212147270.13529@blonde.wat.veritas.com>
Date: Fri, 21 Sep 2007 21:48:06 +0100 (BST)
From: Hugh Dickins <hugh@...itas.com>
To: Christoph Lameter <clameter@....com>
cc: linux-kernel@...r.kernel.org
Subject: [PATCH 6/6] LBS: support largeblocked swapfile
Adjust setup_swap_extents so as not to assume that PAGE_SIZE is a multiple
of its swapfile blocksize: blocksize might now be a multiple of PAGE_SIZE.
Not vital to support this, but LTP in ext2 -b 32768 /tmp was failing before.
Signed-off-by: Hugh Dickins <hugh@...itas.com>
--- 2.6.23-rc6-lbs/mm/swapfile.c 2007-08-04 07:08:50.000000000 +0100
+++ linux/mm/swapfile.c 2007-09-17 17:09:03.000000000 +0100
@@ -1057,6 +1057,7 @@ static int setup_swap_extents(struct swa
{
struct inode *inode;
unsigned blocks_per_page;
+ unsigned pages_per_block;
unsigned long page_no;
unsigned blkbits;
sector_t probe_block;
@@ -1074,7 +1075,13 @@ static int setup_swap_extents(struct swa
}
blkbits = inode->i_blkbits;
- blocks_per_page = PAGE_SIZE >> blkbits;
+ if (blkbits <= PAGE_SHIFT) {
+ blocks_per_page = 1 << (PAGE_SHIFT - blkbits);
+ pages_per_block = 1;
+ } else {
+ blocks_per_page = 1;
+ pages_per_block = 1 << (blkbits - PAGE_SHIFT);
+ }
/*
* Map all the blocks into the extent list. This code doesn't try
@@ -1114,28 +1121,34 @@ static int setup_swap_extents(struct swa
}
}
- first_block >>= (PAGE_SHIFT - blkbits);
+ if (blkbits <= PAGE_SHIFT)
+ first_block >>= (PAGE_SHIFT - blkbits);
+ else {
+ first_block <<= (blkbits - PAGE_SHIFT);
+ if (page_no + pages_per_block > sis->max)
+ pages_per_block = sis->max - page_no;
+ }
if (page_no) { /* exclude the header page */
if (first_block < lowest_block)
lowest_block = first_block;
- if (first_block > highest_block)
- highest_block = first_block;
+ if (first_block >= highest_block)
+ highest_block = first_block + pages_per_block;
}
/*
* We found a PAGE_SIZE-length, PAGE_SIZE-aligned run of blocks
*/
- ret = add_swap_extent(sis, page_no, 1, first_block);
+ ret = add_swap_extent(sis,page_no,pages_per_block,first_block);
if (ret < 0)
goto out;
nr_extents += ret;
- page_no++;
+ page_no += pages_per_block;
probe_block += blocks_per_page;
reprobe:
continue;
}
ret = nr_extents;
- *span = 1 + highest_block - lowest_block;
+ *span = highest_block - lowest_block;
if (page_no == 0)
page_no = 1; /* force Empty message */
sis->max = page_no;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists