* [patch 05/19] Use page_cache_xxx in mm/rmap.c
2007-11-29 1:10 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions Christoph Lameter
@ 2007-11-29 1:10 ` Christoph Lameter
2007-11-29 3:19 ` David Chinner
0 siblings, 1 reply; 30+ messages in thread
From: Christoph Lameter @ 2007-11-29 1:10 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0006-Use-page_cache_xxx-in-mm-rmap.c.patch --]
[-- Type: text/plain, Size: 2027 bytes --]
Use page_cache_xxx in mm/rmap.c
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/rmap.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
Index: mm/mm/rmap.c
===================================================================
--- mm.orig/mm/rmap.c 2007-11-28 12:27:32.312059099 -0800
+++ mm/mm/rmap.c 2007-11-28 14:10:42.758227810 -0800
@@ -190,9 +190,14 @@ static void page_unlock_anon_vma(struct
static inline unsigned long
vma_address(struct page *page, struct vm_area_struct *vma)
{
- pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff;
unsigned long address;
+ if (PageAnon(page))
+ pgoff = page->index;
+ else
+ pgoff = page->index << mapping_order(page->mapping);
+
address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
/* page should be within @vma mapping range */
@@ -345,7 +350,7 @@ static int page_referenced_file(struct p
{
unsigned int mapcount;
struct address_space *mapping = page->mapping;
- pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int referenced = 0;
@@ -464,7 +469,7 @@ out:
static int page_mkclean_file(struct address_space *mapping, struct page *page)
{
- pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int ret = 0;
@@ -897,7 +902,7 @@ static int try_to_unmap_anon(struct page
static int try_to_unmap_file(struct page *page, int migration)
{
struct address_space *mapping = page->mapping;
- pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int ret = SWAP_AGAIN;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
2007-11-29 1:10 ` [patch 05/19] Use page_cache_xxx in mm/rmap.c Christoph Lameter
@ 2007-11-29 3:19 ` David Chinner
2007-11-29 3:30 ` Christoph Lameter
0 siblings, 1 reply; 30+ messages in thread
From: David Chinner @ 2007-11-29 3:19 UTC (permalink / raw)
To: Christoph Lameter
Cc: akpm, linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
On Wed, Nov 28, 2007 at 05:10:57PM -0800, Christoph Lameter wrote:
> Use page_cache_xxx in mm/rmap.c
>
> Signed-off-by: Christoph Lameter <clameter@sgi.com>
> ---
> mm/rmap.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> Index: mm/mm/rmap.c
> ===================================================================
> --- mm.orig/mm/rmap.c 2007-11-28 12:27:32.312059099 -0800
> +++ mm/mm/rmap.c 2007-11-28 14:10:42.758227810 -0800
> @@ -190,9 +190,14 @@ static void page_unlock_anon_vma(struct
> static inline unsigned long
> vma_address(struct page *page, struct vm_area_struct *vma)
> {
> - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> + pgoff_t pgoff;
> unsigned long address;
>
> + if (PageAnon(page))
> + pgoff = page->index;
> + else
> + pgoff = page->index << mapping_order(page->mapping);
> +
> address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
> if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
> /* page should be within @vma mapping range */
> @@ -345,7 +350,7 @@ static int page_referenced_file(struct p
> {
> unsigned int mapcount;
> struct address_space *mapping = page->mapping;
> - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> + pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
Based on the first hunk, shouldn't this be:
pgoff_t pgoff = page->index << mapping_order(mapping);
Cheers,
Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
2007-11-29 3:19 ` David Chinner
@ 2007-11-29 3:30 ` Christoph Lameter
2007-11-29 3:59 ` David Chinner
0 siblings, 1 reply; 30+ messages in thread
From: Christoph Lameter @ 2007-11-29 3:30 UTC (permalink / raw)
To: David Chinner
Cc: akpm, linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, Jens Axboe, Badari Pulavarty,
Maxim Levitsky, Fengguang Wu, swin wang, totty.lu, hugh, joern
On Thu, 29 Nov 2007, David Chinner wrote:
> > unsigned int mapcount;
> > struct address_space *mapping = page->mapping;
> > - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> > + pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
>
> Based on the first hunk, shouldn't this be:
>
> pgoff_t pgoff = page->index << mapping_order(mapping);
Yes that is much simpler
rmap: simplify page_referenced_file use of page cache inlines
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/rmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: mm/mm/rmap.c
===================================================================
--- mm.orig/mm/rmap.c 2007-11-28 19:28:45.689883608 -0800
+++ mm/mm/rmap.c 2007-11-28 19:29:35.090382690 -0800
@@ -350,7 +350,7 @@ static int page_referenced_file(struct p
{
unsigned int mapcount;
struct address_space *mapping = page->mapping;
- pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << mapping_order(mapping);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int referenced = 0;
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
2007-11-29 3:30 ` Christoph Lameter
@ 2007-11-29 3:59 ` David Chinner
2007-11-29 4:09 ` Christoph Lameter
0 siblings, 1 reply; 30+ messages in thread
From: David Chinner @ 2007-11-29 3:59 UTC (permalink / raw)
To: Christoph Lameter
Cc: David Chinner, akpm, linux-fsdevel, linux-mm, Christoph Hellwig,
Mel Gorman, William Lee Irwin III, Jens Axboe, Badari Pulavarty,
Maxim Levitsky, Fengguang Wu, swin wang, totty.lu, hugh, joern
On Wed, Nov 28, 2007 at 07:30:54PM -0800, Christoph Lameter wrote:
> On Thu, 29 Nov 2007, David Chinner wrote:
>
> > > unsigned int mapcount;
> > > struct address_space *mapping = page->mapping;
> > > - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> > > + pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
> >
> > Based on the first hunk, shouldn't this be:
> >
> > pgoff_t pgoff = page->index << mapping_order(mapping);
>
> Yes that is much simpler
>
>
> rmap: simplify page_referenced_file use of page cache inlines
>
> Signed-off-by: Christoph Lameter <clameter@sgi.com>
>
> ---
> mm/rmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: mm/mm/rmap.c
> ===================================================================
> --- mm.orig/mm/rmap.c 2007-11-28 19:28:45.689883608 -0800
> +++ mm/mm/rmap.c 2007-11-28 19:29:35.090382690 -0800
> @@ -350,7 +350,7 @@ static int page_referenced_file(struct p
> {
> unsigned int mapcount;
> struct address_space *mapping = page->mapping;
> - pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
> + pgoff_t pgoff = page->index << mapping_order(mapping);
> struct vm_area_struct *vma;
> struct prio_tree_iter iter;
> int referenced = 0;
And the other two occurrences of this in the first patch?
Cheers,
Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
2007-11-29 3:59 ` David Chinner
@ 2007-11-29 4:09 ` Christoph Lameter
2007-11-29 4:11 ` David Chinner
0 siblings, 1 reply; 30+ messages in thread
From: Christoph Lameter @ 2007-11-29 4:09 UTC (permalink / raw)
To: David Chinner
Cc: akpm, linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, Jens Axboe, Badari Pulavarty,
Maxim Levitsky, Fengguang Wu, swin wang, totty.lu, hugh, joern
On Thu, 29 Nov 2007, David Chinner wrote:
> And the other two occurrences of this in the first patch?
Ahh... Ok they are also in rmap.c:
rmap: simplify page_referenced_file use of page cache inlines
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/rmap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: mm/mm/rmap.c
===================================================================
--- mm.orig/mm/rmap.c 2007-11-28 20:03:15.255240262 -0800
+++ mm/mm/rmap.c 2007-11-28 20:08:50.278132294 -0800
@@ -350,7 +350,7 @@ static int page_referenced_file(struct p
{
unsigned int mapcount;
struct address_space *mapping = page->mapping;
- pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << mapping_order(mapping);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int referenced = 0;
@@ -469,7 +469,7 @@ out:
static int page_mkclean_file(struct address_space *mapping, struct page *page)
{
- pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << mapping_order(mapping);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int ret = 0;
@@ -902,7 +902,7 @@ static int try_to_unmap_anon(struct page
static int try_to_unmap_file(struct page *page, int migration)
{
struct address_space *mapping = page->mapping;
- pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << mapping_order(mapping);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int ret = SWAP_AGAIN;
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
2007-11-29 4:09 ` Christoph Lameter
@ 2007-11-29 4:11 ` David Chinner
0 siblings, 0 replies; 30+ messages in thread
From: David Chinner @ 2007-11-29 4:11 UTC (permalink / raw)
To: Christoph Lameter
Cc: David Chinner, akpm, linux-fsdevel, linux-mm, Christoph Hellwig,
Mel Gorman, William Lee Irwin III, Jens Axboe, Badari Pulavarty,
Maxim Levitsky, Fengguang Wu, swin wang, totty.lu, hugh, joern
On Wed, Nov 28, 2007 at 08:09:39PM -0800, Christoph Lameter wrote:
> On Thu, 29 Nov 2007, David Chinner wrote:
>
> > And the other two occurrences of this in the first patch?
>
> Ahh... Ok they are also in rmap.c:
>
>
>
> rmap: simplify page_referenced_file use of page cache inlines
Ok.
Cheers,
dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2
@ 2007-11-30 17:34 Christoph Lameter
2007-11-30 17:34 ` [patch 01/19] Define functions for page cache handling Christoph Lameter
` (18 more replies)
0 siblings, 19 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
This patchset cleans up page cache handling by replacing
open coded shifts and adds with inline function calls.
The ultimate goal is to replace all uses of PAGE_CACHE_xxx in the
kernel through the use of these functions. All the functions take
a mapping parameter. The mapping parameter is required if we want
to support large block sizes in filesystems and block devices.
Patchset against 2.6.24-rc3-mm2.
V1->V2:
- Review by Dave Chinner. Multiple improvements and fixes.
- Review by Fengguand Wu with more improvements.
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 01/19] Define functions for page cache handling
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-12-03 22:10 ` Andrew Morton
2007-11-30 17:34 ` [patch 02/19] Use page_cache_xxx functions in mm/filemap.c Christoph Lameter
` (17 subsequent siblings)
18 siblings, 1 reply; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0002-Define-functions-for-page-cache-handling.patch --]
[-- Type: text/plain, Size: 3911 bytes --]
We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK
and PAGE_CACHE_ALIGN in various places in the kernel. Many times
common operations like calculating the offset or the index are coded
using shifts and adds. This patch provides inline functions to
get the calculations accomplished without having to explicitly
shift and add constants.
All functions take an address_space pointer. The address space pointer
will be used in the future to eventually support a variable size
page cache. Information reachable via the mapping may then determine
page size.
New function Related base page constant
====================================================================
page_cache_shift(a) PAGE_CACHE_SHIFT
page_cache_size(a) PAGE_CACHE_SIZE
page_cache_mask(a) PAGE_CACHE_MASK
page_cache_index(a, pos) Calculate page number from position
page_cache_next(addr, pos) Page number of next page
page_cache_offset(a, pos) Calculate offset into a page
page_cache_pos(a, index, offset)
Form position based on page number
and an offset.
This provides a basis that would allow the conversion of all page cache
handling in the kernel and ultimately allow the removal of the PAGE_CACHE_*
constants.
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
include/linux/pagemap.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
Index: mm/include/linux/pagemap.h
===================================================================
--- mm.orig/include/linux/pagemap.h 2007-11-29 12:27:53.878812858 -0800
+++ mm/include/linux/pagemap.h 2007-11-29 12:28:42.063283655 -0800
@@ -52,12 +52,61 @@ static inline void mapping_set_gfp_mask(
* space in smaller chunks for same flexibility).
*
* Or rather, it _will_ be done in larger chunks.
+ *
+ * The following constants can be used if a filesystem only supports a single
+ * page size.
*/
#define PAGE_CACHE_SHIFT PAGE_SHIFT
#define PAGE_CACHE_SIZE PAGE_SIZE
#define PAGE_CACHE_MASK PAGE_MASK
#define PAGE_CACHE_ALIGN(addr) (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK)
+/*
+ * Functions that are currently setup for a fixed PAGE_SIZEd. The use of
+ * these will allow the user of largere page sizes in the future.
+ */
+static inline int mapping_order(struct address_space *a)
+{
+ return 0;
+}
+
+static inline int page_cache_shift(struct address_space *a)
+{
+ return PAGE_SHIFT;
+}
+
+static inline unsigned int page_cache_size(struct address_space *a)
+{
+ return PAGE_SIZE;
+}
+
+static inline unsigned int page_cache_offset(struct address_space *a,
+ loff_t pos)
+{
+ return pos & ~PAGE_MASK;
+}
+
+static inline pgoff_t page_cache_index(struct address_space *a,
+ loff_t pos)
+{
+ return pos >> page_cache_shift(a);
+}
+
+/*
+ * Index of the page starting on or after the given position.
+ */
+static inline pgoff_t page_cache_next(struct address_space *a,
+ loff_t pos)
+{
+ return page_cache_index(a, pos + page_cache_size(a) - 1);
+}
+
+static inline loff_t page_cache_pos(struct address_space *a,
+ pgoff_t index, unsigned long offset)
+{
+ return ((loff_t)index << page_cache_shift(a)) + offset;
+}
+
#define page_cache_get(page) get_page(page)
#define page_cache_release(page) put_page(page)
void release_pages(struct page **pages, int nr, int cold);
@@ -142,10 +191,12 @@ extern void __remove_from_page_cache(str
/*
* Return byte-offset into filesystem object for page.
+ * Note: Assumes a mapping of order 0.
+ * Use page_cache_pos to allow larger pages.
*/
static inline loff_t page_offset(struct page *page)
{
- return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
+ return page->index << PAGE_CACHE_SHIFT;
}
static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 02/19] Use page_cache_xxx functions in mm/filemap.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
2007-11-30 17:34 ` [patch 01/19] Define functions for page cache handling Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:34 ` [patch 03/19] Use page_cache_xxx in mm/page-writeback.c Christoph Lameter
` (16 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0003-Use-page_cache_xxx-functions-in-mm-filemap.c.patch --]
[-- Type: text/plain, Size: 8837 bytes --]
Convert the uses of PAGE_CACHE_xxx.
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/filemap.c | 91 +++++++++++++++++++++++++++++------------------------------
1 file changed, 46 insertions(+), 45 deletions(-)
Index: mm/mm/filemap.c
===================================================================
--- mm.orig/mm/filemap.c 2007-11-29 12:05:41.419866445 -0800
+++ mm/mm/filemap.c 2007-11-29 12:08:07.364365995 -0800
@@ -314,8 +314,8 @@ EXPORT_SYMBOL(add_to_page_cache_lru);
int sync_page_range(struct inode *inode, struct address_space *mapping,
loff_t pos, loff_t count)
{
- pgoff_t start = pos >> PAGE_CACHE_SHIFT;
- pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT;
+ pgoff_t start = page_cache_index(mapping, pos);
+ pgoff_t end = page_cache_index(mapping, pos + count - 1);
int ret;
if (!mapping_cap_writeback_dirty(mapping) || !count)
@@ -346,8 +346,8 @@ EXPORT_SYMBOL(sync_page_range);
int sync_page_range_nolock(struct inode *inode, struct address_space *mapping,
loff_t pos, loff_t count)
{
- pgoff_t start = pos >> PAGE_CACHE_SHIFT;
- pgoff_t end = (pos + count - 1) >> PAGE_CACHE_SHIFT;
+ pgoff_t start = page_cache_index(mapping, pos);
+ pgoff_t end = page_cache_index(mapping, pos + count - 1);
int ret;
if (!mapping_cap_writeback_dirty(mapping) || !count)
@@ -376,7 +376,7 @@ int filemap_fdatawait(struct address_spa
return 0;
return wait_on_page_writeback_range(mapping, 0,
- (i_size - 1) >> PAGE_CACHE_SHIFT);
+ page_cache_index(mapping, i_size - 1));
}
EXPORT_SYMBOL(filemap_fdatawait);
@@ -424,8 +424,8 @@ int filemap_write_and_wait_range(struct
/* See comment of filemap_write_and_wait() */
if (err != -EIO) {
int err2 = wait_on_page_writeback_range(mapping,
- lstart >> PAGE_CACHE_SHIFT,
- lend >> PAGE_CACHE_SHIFT);
+ page_cache_index(mapping, lstart),
+ page_cache_index(mapping, lend));
if (!err)
err = err2;
}
@@ -897,11 +897,11 @@ void do_generic_mapping_read(struct addr
unsigned int prev_offset;
int error;
- index = *ppos >> PAGE_CACHE_SHIFT;
- prev_index = ra->prev_pos >> PAGE_CACHE_SHIFT;
- prev_offset = ra->prev_pos & (PAGE_CACHE_SIZE-1);
- last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
- offset = *ppos & ~PAGE_CACHE_MASK;
+ index = page_cache_index(mapping, *ppos);
+ prev_index = page_cache_index(mapping, ra->prev_pos);
+ prev_offset = page_cache_offset(mapping, ra->prev_pos);
+ last_index = page_cache_next(mapping, *ppos + desc->count);
+ offset = page_cache_offset(mapping, *ppos);
for (;;) {
struct page *page;
@@ -938,16 +938,16 @@ page_ok:
*/
isize = i_size_read(inode);
- end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
+ end_index = page_cache_index(mapping, isize - 1);
if (unlikely(!isize || index > end_index)) {
page_cache_release(page);
goto out;
}
/* nr is the maximum number of bytes to copy from this page */
- nr = PAGE_CACHE_SIZE;
+ nr = page_cache_size(mapping);
if (index == end_index) {
- nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1;
+ nr = page_cache_offset(mapping, isize - 1) + 1;
if (nr <= offset) {
page_cache_release(page);
goto out;
@@ -982,8 +982,8 @@ page_ok:
*/
ret = actor(desc, page, offset, nr);
offset += ret;
- index += offset >> PAGE_CACHE_SHIFT;
- offset &= ~PAGE_CACHE_MASK;
+ index += page_cache_index(mapping, offset);
+ offset = page_cache_offset(mapping, offset);
prev_offset = offset;
page_cache_release(page);
@@ -1073,11 +1073,8 @@ no_cached_page:
}
out:
- ra->prev_pos = prev_index;
- ra->prev_pos <<= PAGE_CACHE_SHIFT;
- ra->prev_pos |= prev_offset;
-
- *ppos = ((loff_t)index << PAGE_CACHE_SHIFT) + offset;
+ ra->prev_pos = page_cache_pos(mapping, prev_index, prev_offset);
+ *ppos = page_cache_pos(mapping, index, offset);
if (filp)
file_accessed(filp);
}
@@ -1257,8 +1254,8 @@ asmlinkage ssize_t sys_readahead(int fd,
if (file) {
if (file->f_mode & FMODE_READ) {
struct address_space *mapping = file->f_mapping;
- pgoff_t start = offset >> PAGE_CACHE_SHIFT;
- pgoff_t end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
+ pgoff_t start = page_cache_index(mapping, offset);
+ pgoff_t end = page_cache_index(mapping, offset + count - 1);
unsigned long len = end - start + 1;
ret = do_readahead(mapping, file, start, len);
}
@@ -1326,7 +1323,7 @@ int filemap_fault(struct vm_area_struct
int did_readaround = 0;
int ret = 0;
- size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+ size = page_cache_next(mapping, i_size_read(inode));
if (vmf->pgoff >= size)
return VM_FAULT_SIGBUS;
@@ -1401,7 +1398,7 @@ retry_find:
goto page_not_uptodate;
/* Must recheck i_size under page lock */
- size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+ size = page_cache_next(mapping, i_size_read(inode));
if (unlikely(vmf->pgoff >= size)) {
unlock_page(page);
page_cache_release(page);
@@ -1412,7 +1409,7 @@ retry_find:
* Found the page and have a reference on it.
*/
mark_page_accessed(page);
- ra->prev_pos = (loff_t)page->index << PAGE_CACHE_SHIFT;
+ ra->prev_pos = page_cache_pos(mapping, page->index, 0);
vmf->page = page;
return ret | VM_FAULT_LOCKED;
@@ -1896,8 +1893,8 @@ int pagecache_write_begin(struct file *f
pagep, fsdata);
} else {
int ret;
- pgoff_t index = pos >> PAGE_CACHE_SHIFT;
- unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
+ pgoff_t index = page_cache_index(mapping, pos);
+ unsigned offset = page_cache_offset(mapping, pos);
struct inode *inode = mapping->host;
struct page *page;
again:
@@ -1948,7 +1945,7 @@ int pagecache_write_end(struct file *fil
ret = aops->write_end(file, mapping, pos, len, copied,
page, fsdata);
} else {
- unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
+ unsigned offset = page_cache_offset(mapping, pos);
struct inode *inode = mapping->host;
flush_dcache_page(page);
@@ -2053,10 +2050,11 @@ static ssize_t generic_perform_write_2co
unsigned long bytes; /* Bytes to write to page */
size_t copied; /* Bytes copied from user */
- offset = (pos & (PAGE_CACHE_SIZE - 1));
- index = pos >> PAGE_CACHE_SHIFT;
- bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset,
- iov_iter_count(i));
+ offset = page_cache_offset(mapping, pos);
+ index = page_cache_index(mapping, pos);
+ bytes = min_t(unsigned long,
+ page_cache_size(mapping) - offset,
+ iov_iter_count(i));
/*
* a non-NULL src_page indicates that we're doing the
@@ -2227,10 +2225,11 @@ static ssize_t generic_perform_write(str
size_t copied; /* Bytes copied from user */
void *fsdata;
- offset = (pos & (PAGE_CACHE_SIZE - 1));
- index = pos >> PAGE_CACHE_SHIFT;
- bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset,
- iov_iter_count(i));
+ offset = page_cache_offset(mapping, pos);
+ index = page_cache_index(mapping, pos);
+ bytes = min_t(unsigned long,
+ page_cache_size(mapping) - offset,
+ iov_iter_count(i));
again:
@@ -2276,8 +2275,9 @@ again:
* because not all segments in the iov can be copied at
* once without a pagefault.
*/
- bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset,
- iov_iter_single_seg_count(i));
+ bytes = min_t(unsigned long,
+ page_cache_size(mapping) - offset,
+ iov_iter_single_seg_count(i));
goto again;
}
iov_iter_advance(i, copied);
@@ -2419,8 +2419,8 @@ __generic_file_aio_write_nolock(struct k
if (err == 0) {
written = written_buffered;
invalidate_mapping_pages(mapping,
- pos >> PAGE_CACHE_SHIFT,
- endbyte >> PAGE_CACHE_SHIFT);
+ page_cache_index(mapping, pos),
+ page_cache_index(mapping, endbyte));
} else {
/*
* We don't know how much we wrote, so just return
@@ -2507,7 +2507,7 @@ generic_file_direct_IO(int rw, struct ki
*/
if (rw == WRITE) {
write_len = iov_length(iov, nr_segs);
- end = (offset + write_len - 1) >> PAGE_CACHE_SHIFT;
+ end = page_cache_index(mapping, offset + write_len - 1);
if (mapping_mapped(mapping))
unmap_mapping_range(mapping, offset, write_len, 0);
}
@@ -2524,7 +2524,7 @@ generic_file_direct_IO(int rw, struct ki
*/
if (rw == WRITE && mapping->nrpages) {
retval = invalidate_inode_pages2_range(mapping,
- offset >> PAGE_CACHE_SHIFT, end);
+ page_cache_index(mapping, offset), end);
if (retval)
goto out;
}
@@ -2540,7 +2540,8 @@ generic_file_direct_IO(int rw, struct ki
* fails, tough, the write still worked...
*/
if (rw == WRITE && mapping->nrpages) {
- invalidate_inode_pages2_range(mapping, offset >> PAGE_CACHE_SHIFT, end);
+ invalidate_inode_pages2_range(mapping,
+ page_cache_index(mapping, offset), end);
}
out:
return retval;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 03/19] Use page_cache_xxx in mm/page-writeback.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
2007-11-30 17:34 ` [patch 01/19] Define functions for page cache handling Christoph Lameter
2007-11-30 17:34 ` [patch 02/19] Use page_cache_xxx functions in mm/filemap.c Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:34 ` [patch 04/19] Use page_cache_xxx in mm/truncate.c Christoph Lameter
` (15 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0004-Use-page_cache_xxx-in-mm-page-writeback.c.patch --]
[-- Type: text/plain, Size: 1287 bytes --]
Use page_cache_xxx in mm/page-writeback.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/page-writeback.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: mm/mm/page-writeback.c
===================================================================
--- mm.orig/mm/page-writeback.c 2007-11-28 12:27:32.211962401 -0800
+++ mm/mm/page-writeback.c 2007-11-28 14:10:34.338227137 -0800
@@ -818,8 +818,8 @@ int write_cache_pages(struct address_spa
index = mapping->writeback_index; /* Start from prev offset */
end = -1;
} else {
- index = wbc->range_start >> PAGE_CACHE_SHIFT;
- end = wbc->range_end >> PAGE_CACHE_SHIFT;
+ index = page_cache_index(mapping, wbc->range_start);
+ end = page_cache_index(mapping, wbc->range_end);
if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
range_whole = 1;
scanned = 1;
@@ -1025,7 +1025,7 @@ int __set_page_dirty_nobuffers(struct pa
__inc_zone_page_state(page, NR_FILE_DIRTY);
__inc_bdi_stat(mapping->backing_dev_info,
BDI_RECLAIMABLE);
- task_io_account_write(PAGE_CACHE_SIZE);
+ task_io_account_write(page_cache_size(mapping));
}
radix_tree_tag_set(&mapping->page_tree,
page_index(page), PAGECACHE_TAG_DIRTY);
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 04/19] Use page_cache_xxx in mm/truncate.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (2 preceding siblings ...)
2007-11-30 17:34 ` [patch 03/19] Use page_cache_xxx in mm/page-writeback.c Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:34 ` [patch 05/19] Use page_cache_xxx in mm/rmap.c Christoph Lameter
` (14 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0005-Use-page_cache_xxx-in-mm-truncate.c.patch --]
[-- Type: text/plain, Size: 3870 bytes --]
Use page_cache_xxx in mm/truncate.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/truncate.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
Index: mm/mm/truncate.c
===================================================================
--- mm.orig/mm/truncate.c 2007-11-28 12:27:32.480099915 -0800
+++ mm/mm/truncate.c 2007-11-28 14:10:39.013977394 -0800
@@ -46,9 +46,10 @@ void do_invalidatepage(struct page *page
(*invalidatepage)(page, offset);
}
-static inline void truncate_partial_page(struct page *page, unsigned partial)
+static inline void truncate_partial_page(struct address_space *mapping,
+ struct page *page, unsigned partial)
{
- zero_user_segment(page, partial, PAGE_CACHE_SIZE);
+ zero_user_segment(page, partial, page_cache_size(mapping));
if (PagePrivate(page))
do_invalidatepage(page, partial);
}
@@ -98,7 +99,7 @@ truncate_complete_page(struct address_sp
if (page->mapping != mapping)
return;
- cancel_dirty_page(page, PAGE_CACHE_SIZE);
+ cancel_dirty_page(page, page_cache_size(mapping));
if (PagePrivate(page))
do_invalidatepage(page, 0);
@@ -160,9 +161,9 @@ invalidate_complete_page(struct address_
void truncate_inode_pages_range(struct address_space *mapping,
loff_t lstart, loff_t lend)
{
- const pgoff_t start = (lstart + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
+ const pgoff_t start = page_cache_next(mapping, lstart);
pgoff_t end;
- const unsigned partial = lstart & (PAGE_CACHE_SIZE - 1);
+ const unsigned partial = page_cache_offset(mapping, lstart);
struct pagevec pvec;
pgoff_t next;
int i;
@@ -170,8 +171,9 @@ void truncate_inode_pages_range(struct a
if (mapping->nrpages == 0)
return;
- BUG_ON((lend & (PAGE_CACHE_SIZE - 1)) != (PAGE_CACHE_SIZE - 1));
- end = (lend >> PAGE_CACHE_SHIFT);
+ BUG_ON(page_cache_offset(mapping, lend) !=
+ page_cache_size(mapping) - 1);
+ end = page_cache_index(mapping, lend);
pagevec_init(&pvec, 0);
next = start;
@@ -197,8 +199,8 @@ void truncate_inode_pages_range(struct a
}
if (page_mapped(page)) {
unmap_mapping_range(mapping,
- (loff_t)page_index<<PAGE_CACHE_SHIFT,
- PAGE_CACHE_SIZE, 0);
+ page_cache_pos(mapping, page_index, 0),
+ page_cache_size(mapping), 0);
}
truncate_complete_page(mapping, page);
unlock_page(page);
@@ -211,7 +213,7 @@ void truncate_inode_pages_range(struct a
struct page *page = find_lock_page(mapping, start - 1);
if (page) {
wait_on_page_writeback(page);
- truncate_partial_page(page, partial);
+ truncate_partial_page(mapping, page, partial);
unlock_page(page);
page_cache_release(page);
}
@@ -239,8 +241,8 @@ void truncate_inode_pages_range(struct a
wait_on_page_writeback(page);
if (page_mapped(page)) {
unmap_mapping_range(mapping,
- (loff_t)page->index<<PAGE_CACHE_SHIFT,
- PAGE_CACHE_SIZE, 0);
+ page_cache_pos(mapping, page->index, 0),
+ page_cache_size(mapping), 0);
}
if (page->index > next)
next = page->index;
@@ -424,9 +426,8 @@ int invalidate_inode_pages2_range(struct
* Zap the rest of the file in one hit.
*/
unmap_mapping_range(mapping,
- (loff_t)page_index<<PAGE_CACHE_SHIFT,
- (loff_t)(end - page_index + 1)
- << PAGE_CACHE_SHIFT,
+ page_cache_pos(mapping, page_index, 0),
+ page_cache_pos(mapping, end - page_index + 1, 0),
0);
did_range_unmap = 1;
} else {
@@ -434,8 +435,8 @@ int invalidate_inode_pages2_range(struct
* Just zap this page
*/
unmap_mapping_range(mapping,
- (loff_t)page_index<<PAGE_CACHE_SHIFT,
- PAGE_CACHE_SIZE, 0);
+ page_cache_pos(mapping, page_index, 0),
+ page_cache_size(mapping), 0);
}
}
BUG_ON(page_mapped(page));
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 05/19] Use page_cache_xxx in mm/rmap.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (3 preceding siblings ...)
2007-11-30 17:34 ` [patch 04/19] Use page_cache_xxx in mm/truncate.c Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:34 ` [patch 06/19] Use page_cache_xxx in mm/filemap_xip.c Christoph Lameter
` (13 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0006-Use-page_cache_xxx-in-mm-rmap.c.patch --]
[-- Type: text/plain, Size: 2013 bytes --]
Use page_cache_xxx in mm/rmap.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/rmap.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
Index: mm/mm/rmap.c
===================================================================
--- mm.orig/mm/rmap.c 2007-11-29 11:24:23.371116810 -0800
+++ mm/mm/rmap.c 2007-11-29 11:25:27.551396075 -0800
@@ -190,9 +190,14 @@ static void page_unlock_anon_vma(struct
static inline unsigned long
vma_address(struct page *page, struct vm_area_struct *vma)
{
- pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff;
unsigned long address;
+ if (PageAnon(page))
+ pgoff = page->index;
+ else
+ pgoff = page->index << mapping_order(page->mapping);
+
address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
/* page should be within @vma mapping range */
@@ -345,7 +350,7 @@ static int page_referenced_file(struct p
{
unsigned int mapcount;
struct address_space *mapping = page->mapping;
- pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << mapping_order(mapping);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int referenced = 0;
@@ -464,7 +469,7 @@ out:
static int page_mkclean_file(struct address_space *mapping, struct page *page)
{
- pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << mapping_order(mapping);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int ret = 0;
@@ -897,7 +902,7 @@ static int try_to_unmap_anon(struct page
static int try_to_unmap_file(struct page *page, int migration)
{
struct address_space *mapping = page->mapping;
- pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff = page->index << mapping_order(mapping);
struct vm_area_struct *vma;
struct prio_tree_iter iter;
int ret = SWAP_AGAIN;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 06/19] Use page_cache_xxx in mm/filemap_xip.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (4 preceding siblings ...)
2007-11-30 17:34 ` [patch 05/19] Use page_cache_xxx in mm/rmap.c Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:34 ` [patch 07/19] Use page_cache_xxx in mm/migrate.c Christoph Lameter
` (12 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0007-Use-page_cache_xxx-in-mm-filemap_xip.c.patch --]
[-- Type: text/plain, Size: 2917 bytes --]
Use page_cache_xxx in mm/filemap_xip.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/filemap_xip.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
Index: mm/mm/filemap_xip.c
===================================================================
--- mm.orig/mm/filemap_xip.c 2007-11-29 11:24:22.988616641 -0800
+++ mm/mm/filemap_xip.c 2007-11-29 11:27:35.295767656 -0800
@@ -60,24 +60,24 @@ do_xip_mapping_read(struct address_space
BUG_ON(!mapping->a_ops->get_xip_page);
- index = *ppos >> PAGE_CACHE_SHIFT;
- offset = *ppos & ~PAGE_CACHE_MASK;
+ index = page_cache_index(mapping, *ppos);
+ offset = page_cache_offset(mapping, *ppos);
isize = i_size_read(inode);
if (!isize)
goto out;
- end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
+ end_index = page_cache_index(mapping, isize - 1);
for (;;) {
struct page *page;
unsigned long nr, ret;
/* nr is the maximum number of bytes to copy from this page */
- nr = PAGE_CACHE_SIZE;
+ nr = page_cache_size(mapping);
if (index >= end_index) {
if (index > end_index)
goto out;
- nr = ((isize - 1) & ~PAGE_CACHE_MASK) + 1;
+ nr = page_cache_next(mapping, isize);
if (nr <= offset) {
goto out;
}
@@ -116,8 +116,8 @@ do_xip_mapping_read(struct address_space
*/
ret = actor(desc, page, offset, nr);
offset += ret;
- index += offset >> PAGE_CACHE_SHIFT;
- offset &= ~PAGE_CACHE_MASK;
+ index += page_cache_index(mapping, offset);
+ offset = page_cache_offset(mapping, offset);
if (ret == nr && desc->count)
continue;
@@ -130,7 +130,7 @@ no_xip_page:
}
out:
- *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;
+ *ppos = page_cache_pos(mapping, index, offset);
if (filp)
file_accessed(filp);
}
@@ -219,7 +219,7 @@ static int xip_file_fault(struct vm_area
/* XXX: are VM_FAULT_ codes OK? */
- size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+ size = page_cache_next(mapping, i_size_read(inode));
if (vmf->pgoff >= size)
return VM_FAULT_SIGBUS;
@@ -289,9 +289,9 @@ __xip_file_write(struct file *filp, cons
size_t copied;
char *kaddr;
- offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */
- index = pos >> PAGE_CACHE_SHIFT;
- bytes = PAGE_CACHE_SIZE - offset;
+ offset = page_cache_offset(mapping, pos); /* Within page */
+ index = page_cache_index(mapping, pos);
+ bytes = page_cache_size(mapping) - offset;
if (bytes > count)
bytes = count;
@@ -402,8 +402,8 @@ EXPORT_SYMBOL_GPL(xip_file_write);
int
xip_truncate_page(struct address_space *mapping, loff_t from)
{
- pgoff_t index = from >> PAGE_CACHE_SHIFT;
- unsigned offset = from & (PAGE_CACHE_SIZE-1);
+ pgoff_t index = page_cache_index(mapping, from);
+ unsigned offset = page_cache_offset(mapping, from);
unsigned blocksize;
unsigned length;
struct page *page;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 07/19] Use page_cache_xxx in mm/migrate.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (5 preceding siblings ...)
2007-11-30 17:34 ` [patch 06/19] Use page_cache_xxx in mm/filemap_xip.c Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-12-04 5:45 ` David Chinner
2007-11-30 17:34 ` [patch 08/19] Use page_cache_xxx in fs/libfs.c Christoph Lameter
` (11 subsequent siblings)
18 siblings, 1 reply; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0008-Use-page_cache_xxx-in-mm-migrate.c.patch --]
[-- Type: text/plain, Size: 741 bytes --]
Use page_cache_xxx in mm/migrate.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/migrate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: mm/mm/migrate.c
===================================================================
--- mm.orig/mm/migrate.c 2007-11-28 12:27:32.184464256 -0800
+++ mm/mm/migrate.c 2007-11-28 14:10:49.200977227 -0800
@@ -197,7 +197,7 @@ static void remove_file_migration_ptes(s
struct vm_area_struct *vma;
struct address_space *mapping = page_mapping(new);
struct prio_tree_iter iter;
- pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+ pgoff_t pgoff = new->index << mapping_order(mapping);
if (!mapping)
return;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 08/19] Use page_cache_xxx in fs/libfs.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (6 preceding siblings ...)
2007-11-30 17:34 ` [patch 07/19] Use page_cache_xxx in mm/migrate.c Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:34 ` [patch 09/19] Use page_cache_xxx in fs/sync Christoph Lameter
` (10 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0009-Use-page_cache_xxx-in-fs-libfs.c.patch --]
[-- Type: text/plain, Size: 1567 bytes --]
Use page_cache_xxx in fs/libfs.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/libfs.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
Index: mm/fs/libfs.c
===================================================================
--- mm.orig/fs/libfs.c 2007-11-28 12:24:57.449215408 -0800
+++ mm/fs/libfs.c 2007-11-28 14:10:51.773477763 -0800
@@ -17,7 +17,8 @@ int simple_getattr(struct vfsmount *mnt,
{
struct inode *inode = dentry->d_inode;
generic_fillattr(inode, stat);
- stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9);
+ stat->blocks = inode->i_mapping->nrpages <<
+ (page_cache_shift(inode->i_mapping) - 9);
return 0;
}
@@ -341,10 +342,10 @@ int simple_prepare_write(struct file *fi
unsigned from, unsigned to)
{
if (!PageUptodate(page)) {
- if (to - from != PAGE_CACHE_SIZE)
+ if (to - from != page_cache_size(file->f_mapping))
zero_user_segments(page,
0, from,
- to, PAGE_CACHE_SIZE);
+ to, page_cache_size(file->f_mapping));
}
return 0;
}
@@ -372,8 +373,9 @@ int simple_write_begin(struct file *file
static int simple_commit_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
- loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
+ struct address_space *mapping = page->mapping;
+ struct inode *inode = mapping->host;
+ loff_t pos = page_cache_pos(mapping, page->index, to);
if (!PageUptodate(page))
SetPageUptodate(page);
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 09/19] Use page_cache_xxx in fs/sync
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (7 preceding siblings ...)
2007-11-30 17:34 ` [patch 08/19] Use page_cache_xxx in fs/libfs.c Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:34 ` [patch 10/19] Use page_cache_xxx in fs/buffer.c Christoph Lameter
` (9 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0010-Use-page_cache_xxx-in-fs-sync.patch --]
[-- Type: text/plain, Size: 1093 bytes --]
Use page_cache_xxx in fs/sync.
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/sync.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: mm/fs/sync.c
===================================================================
--- mm.orig/fs/sync.c 2007-11-16 21:16:36.000000000 -0800
+++ mm/fs/sync.c 2007-11-28 14:10:56.269227507 -0800
@@ -260,8 +260,8 @@ int do_sync_mapping_range(struct address
ret = 0;
if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
ret = wait_on_page_writeback_range(mapping,
- offset >> PAGE_CACHE_SHIFT,
- endbyte >> PAGE_CACHE_SHIFT);
+ page_cache_index(mapping, offset),
+ page_cache_index(mapping, endbyte));
if (ret < 0)
goto out;
}
@@ -275,8 +275,8 @@ int do_sync_mapping_range(struct address
if (flags & SYNC_FILE_RANGE_WAIT_AFTER) {
ret = wait_on_page_writeback_range(mapping,
- offset >> PAGE_CACHE_SHIFT,
- endbyte >> PAGE_CACHE_SHIFT);
+ page_cache_index(mapping, offset),
+ page_cache_index(mapping, endbyte));
}
out:
return ret;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 10/19] Use page_cache_xxx in fs/buffer.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (8 preceding siblings ...)
2007-11-30 17:34 ` [patch 09/19] Use page_cache_xxx in fs/sync Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:34 ` [patch 11/19] Use page_cache_xxx in mm/mpage.c Christoph Lameter
` (8 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0011-Use-page_cache_xxx-in-fs-buffer.c.patch --]
[-- Type: text/plain, Size: 12008 bytes --]
Use page_cache_xxx in fs/buffer.c.
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/buffer.c | 103 +++++++++++++++++++++++++++++++++---------------------------
1 file changed, 57 insertions(+), 46 deletions(-)
Index: mm/fs/buffer.c
===================================================================
--- mm.orig/fs/buffer.c 2007-11-29 11:24:22.711616548 -0800
+++ mm/fs/buffer.c 2007-11-29 11:28:05.439616400 -0800
@@ -278,7 +278,7 @@ __find_get_block_slow(struct block_devic
struct page *page;
int all_mapped = 1;
- index = block >> (PAGE_CACHE_SHIFT - bd_inode->i_blkbits);
+ index = block >> (page_cache_shift(bd_mapping) - bd_inode->i_blkbits);
page = find_get_page(bd_mapping, index);
if (!page)
goto out;
@@ -720,7 +720,7 @@ static int __set_page_dirty(struct page
__inc_zone_page_state(page, NR_FILE_DIRTY);
__inc_bdi_stat(mapping->backing_dev_info,
BDI_RECLAIMABLE);
- task_io_account_write(PAGE_CACHE_SIZE);
+ task_io_account_write(page_cache_size(mapping));
}
radix_tree_tag_set(&mapping->page_tree,
page_index(page), PAGECACHE_TAG_DIRTY);
@@ -917,7 +917,7 @@ struct buffer_head *alloc_page_buffers(s
try_again:
head = NULL;
- offset = PAGE_SIZE;
+ offset = page_cache_size(page->mapping);
while ((offset -= size) >= 0) {
bh = alloc_buffer_head(GFP_NOFS);
if (!bh)
@@ -1640,6 +1640,7 @@ static int __block_write_full_page(struc
struct buffer_head *bh, *head;
const unsigned blocksize = 1 << inode->i_blkbits;
int nr_underway = 0;
+ struct address_space *mapping = inode->i_mapping;
BUG_ON(!PageLocked(page));
@@ -1660,7 +1661,8 @@ static int __block_write_full_page(struc
* handle that here by just cleaning them.
*/
- block = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
+ block = (sector_t)page->index <<
+ (page_cache_shift(mapping) - inode->i_blkbits);
head = page_buffers(page);
bh = head;
@@ -1777,7 +1779,7 @@ recover:
} while ((bh = bh->b_this_page) != head);
SetPageError(page);
BUG_ON(PageWriteback(page));
- mapping_set_error(page->mapping, err);
+ mapping_set_error(mapping, err);
set_page_writeback(page);
do {
struct buffer_head *next = bh->b_this_page;
@@ -1844,8 +1846,8 @@ static int __block_prepare_write(struct
struct buffer_head *bh, *head, *wait[2], **wait_bh=wait;
BUG_ON(!PageLocked(page));
- BUG_ON(from > PAGE_CACHE_SIZE);
- BUG_ON(to > PAGE_CACHE_SIZE);
+ BUG_ON(from > page_cache_size(inode->i_mapping));
+ BUG_ON(to > page_cache_size(inode->i_mapping));
BUG_ON(from > to);
blocksize = 1 << inode->i_blkbits;
@@ -1854,7 +1856,8 @@ static int __block_prepare_write(struct
head = page_buffers(page);
bbits = inode->i_blkbits;
- block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits);
+ block = (sector_t)page->index <<
+ (page_cache_shift(inode->i_mapping) - bbits);
for(bh = head, block_start = 0; bh != head || !block_start;
block++, block_start=block_end, bh = bh->b_this_page) {
@@ -1969,8 +1972,8 @@ int block_write_begin(struct file *file,
unsigned start, end;
int ownpage = 0;
- index = pos >> PAGE_CACHE_SHIFT;
- start = pos & (PAGE_CACHE_SIZE - 1);
+ index = page_cache_index(mapping, pos);
+ start = page_cache_offset(mapping, pos);
end = start + len;
page = *pagep;
@@ -2017,7 +2020,7 @@ int block_write_end(struct file *file, s
struct inode *inode = mapping->host;
unsigned start;
- start = pos & (PAGE_CACHE_SIZE - 1);
+ start = page_cache_offset(mapping, pos);
if (unlikely(copied < len)) {
/*
@@ -2095,7 +2098,8 @@ int block_read_full_page(struct page *pa
create_empty_buffers(page, blocksize, 0);
head = page_buffers(page);
- iblock = (sector_t)page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
+ iblock = (sector_t)page->index <<
+ (page_cache_shift(page->mapping) - inode->i_blkbits);
lblock = (i_size_read(inode)+blocksize-1) >> inode->i_blkbits;
bh = head;
nr = 0;
@@ -2213,16 +2217,17 @@ int cont_expand_zero(struct file *file,
unsigned zerofrom, offset, len;
int err = 0;
- index = pos >> PAGE_CACHE_SHIFT;
- offset = pos & ~PAGE_CACHE_MASK;
+ index = page_cache_index(mapping, pos);
+ offset = page_cache_offset(mapping, pos);
- while (index > (curidx = (curpos = *bytes)>>PAGE_CACHE_SHIFT)) {
- zerofrom = curpos & ~PAGE_CACHE_MASK;
+ while (curpos = *bytes, curidx = page_cache_index(mapping, curpos),
+ index > curidx) {
+ zerofrom = page_cache_offset(mapping, curpos);
if (zerofrom & (blocksize-1)) {
*bytes |= (blocksize-1);
(*bytes)++;
}
- len = PAGE_CACHE_SIZE - zerofrom;
+ len = page_cache_size(mapping) - zerofrom;
err = pagecache_write_begin(file, mapping, curpos, len,
AOP_FLAG_UNINTERRUPTIBLE,
@@ -2240,7 +2245,7 @@ int cont_expand_zero(struct file *file,
/* page covers the boundary, find the boundary offset */
if (index == curidx) {
- zerofrom = curpos & ~PAGE_CACHE_MASK;
+ zerofrom = page_cache_offset(mapping, curpos);
/* if we will expand the thing last block will be filled */
if (offset <= zerofrom) {
goto out;
@@ -2286,7 +2291,7 @@ int cont_write_begin(struct file *file,
if (err)
goto out;
- zerofrom = *bytes & ~PAGE_CACHE_MASK;
+ zerofrom = page_cache_offset(mapping, *bytes);
if (pos+len > *bytes && zerofrom & (blocksize-1)) {
*bytes |= (blocksize-1);
(*bytes)++;
@@ -2319,8 +2324,9 @@ int block_commit_write(struct page *page
int generic_commit_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
- struct inode *inode = page->mapping->host;
- loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
+ struct address_space *mapping = page->mapping;
+ struct inode *inode = mapping->host;
+ loff_t pos = page_cache_pos(mapping, page->index, to);
__block_commit_write(inode,page,from,to);
/*
* No need to use i_size_read() here, the i_size
@@ -2356,20 +2362,22 @@ block_page_mkwrite(struct vm_area_struct
unsigned long end;
loff_t size;
int ret = -EINVAL;
+ struct address_space *mapping;
lock_page(page);
+ mapping = page->mapping;
size = i_size_read(inode);
- if ((page->mapping != inode->i_mapping) ||
- (page_offset(page) > size)) {
+ if ((mapping != inode->i_mapping) ||
+ (page_cache_pos(mapping, page->index, 0) > size)) {
/* page got truncated out from underneath us */
goto out_unlock;
}
/* page is wholly or partially inside EOF */
- if (((page->index + 1) << PAGE_CACHE_SHIFT) > size)
- end = size & ~PAGE_CACHE_MASK;
+ if (page_cache_pos(mapping, page->index + 1, 0) > size)
+ end = page_cache_offset(mapping, size);
else
- end = PAGE_CACHE_SIZE;
+ end = page_cache_size(mapping);
ret = block_prepare_write(page, 0, end, get_block);
if (!ret)
@@ -2437,8 +2445,8 @@ int nobh_write_begin(struct file *file,
int ret = 0;
int is_mapped_to_disk = 1;
- index = pos >> PAGE_CACHE_SHIFT;
- from = pos & (PAGE_CACHE_SIZE - 1);
+ index = page_cache_index(mapping, pos);
+ from = page_cache_offset(mapping, pos);
to = from + len;
page = __grab_cache_page(mapping, index);
@@ -2473,7 +2481,8 @@ int nobh_write_begin(struct file *file,
goto out_release;
}
- block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits);
+ block_in_file = (sector_t)page->index <<
+ (page_cache_shift(mapping) - blkbits);
/*
* We loop across all blocks in the page, whether or not they are
@@ -2481,7 +2490,7 @@ int nobh_write_begin(struct file *file,
* page is fully mapped-to-disk.
*/
for (block_start = 0, block_in_page = 0, bh = head;
- block_start < PAGE_CACHE_SIZE;
+ block_start < page_cache_size(mapping);
block_in_page++, block_start += blocksize, bh = bh->b_this_page) {
int create;
@@ -2607,9 +2616,10 @@ EXPORT_SYMBOL(nobh_write_end);
int nobh_writepage(struct page *page, get_block_t *get_block,
struct writeback_control *wbc)
{
- struct inode * const inode = page->mapping->host;
+ struct address_space *mapping = page->mapping;
+ struct inode * const inode = mapping->host;
loff_t i_size = i_size_read(inode);
- const pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
+ const pgoff_t end_index = page_cache_index(mapping, i_size);
unsigned offset;
int ret;
@@ -2618,7 +2628,7 @@ int nobh_writepage(struct page *page, ge
goto out;
/* Is the page fully outside i_size? (truncate in progress) */
- offset = i_size & (PAGE_CACHE_SIZE-1);
+ offset = page_cache_offset(mapping, i_size);
if (page->index >= end_index+1 || !offset) {
/*
* The page may have dirty, unmapped buffers. For example,
@@ -2641,7 +2651,7 @@ int nobh_writepage(struct page *page, ge
* the page size, the remaining memory is zeroed when mapped, and
* writes to that region are not written out to the file."
*/
- zero_user_segment(page, offset, PAGE_CACHE_SIZE);
+ zero_user_segment(page, offset, page_cache_size(mapping));
out:
ret = mpage_writepage(page, get_block, wbc);
if (ret == -EAGAIN)
@@ -2653,8 +2663,8 @@ EXPORT_SYMBOL(nobh_writepage);
int nobh_truncate_page(struct address_space *mapping,
loff_t from, get_block_t *get_block)
{
- pgoff_t index = from >> PAGE_CACHE_SHIFT;
- unsigned offset = from & (PAGE_CACHE_SIZE-1);
+ pgoff_t index = page_cache_index(mapping, from);
+ unsigned offset = page_cache_offset(mapping, from);
unsigned blocksize;
sector_t iblock;
unsigned length, pos;
@@ -2671,7 +2681,7 @@ int nobh_truncate_page(struct address_sp
return 0;
length = blocksize - length;
- iblock = (sector_t)index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
+ iblock = (sector_t)index << (page_cache_shift(mapping) - inode->i_blkbits);
page = grab_cache_page(mapping, index);
err = -ENOMEM;
@@ -2729,8 +2739,8 @@ EXPORT_SYMBOL(nobh_truncate_page);
int block_truncate_page(struct address_space *mapping,
loff_t from, get_block_t *get_block)
{
- pgoff_t index = from >> PAGE_CACHE_SHIFT;
- unsigned offset = from & (PAGE_CACHE_SIZE-1);
+ pgoff_t index = page_cache_index(mapping, from);
+ unsigned offset = page_cache_offset(mapping, from);
unsigned blocksize;
sector_t iblock;
unsigned length, pos;
@@ -2747,8 +2757,8 @@ int block_truncate_page(struct address_s
return 0;
length = blocksize - length;
- iblock = (sector_t)index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
-
+ iblock = (sector_t)index <<
+ (page_cache_shift(mapping) - inode->i_blkbits);
page = grab_cache_page(mapping, index);
err = -ENOMEM;
if (!page)
@@ -2807,9 +2817,10 @@ out:
int block_write_full_page(struct page *page, get_block_t *get_block,
struct writeback_control *wbc)
{
- struct inode * const inode = page->mapping->host;
+ struct address_space *mapping = page->mapping;
+ struct inode * const inode = mapping->host;
loff_t i_size = i_size_read(inode);
- const pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
+ const pgoff_t end_index = page_cache_index(mapping, i_size);
unsigned offset;
/* Is the page fully inside i_size? */
@@ -2817,7 +2828,7 @@ int block_write_full_page(struct page *p
return __block_write_full_page(inode, page, get_block, wbc);
/* Is the page fully outside i_size? (truncate in progress) */
- offset = i_size & (PAGE_CACHE_SIZE-1);
+ offset = page_cache_offset(mapping, i_size);
if (page->index >= end_index+1 || !offset) {
/*
* The page may have dirty, unmapped buffers. For example,
@@ -2836,7 +2847,7 @@ int block_write_full_page(struct page *p
* the page size, the remaining memory is zeroed when mapped, and
* writes to that region are not written out to the file."
*/
- zero_user_segment(page, offset, PAGE_CACHE_SIZE);
+ zero_user_segment(page, offset, page_cache_size(mapping));
return __block_write_full_page(inode, page, get_block, wbc);
}
@@ -3086,7 +3097,7 @@ int try_to_free_buffers(struct page *pag
* dirty bit from being lost.
*/
if (ret)
- cancel_dirty_page(page, PAGE_CACHE_SIZE);
+ cancel_dirty_page(page, page_cache_size(mapping));
spin_unlock(&mapping->private_lock);
out:
if (buffers_to_free) {
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 11/19] Use page_cache_xxx in mm/mpage.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (9 preceding siblings ...)
2007-11-30 17:34 ` [patch 10/19] Use page_cache_xxx in fs/buffer.c Christoph Lameter
@ 2007-11-30 17:34 ` Christoph Lameter
2007-11-30 17:35 ` [patch 12/19] Use page_cache_xxx in mm/fadvise.c Christoph Lameter
` (7 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:34 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0012-Use-page_cache_xxx-in-mm-mpage.c.patch --]
[-- Type: text/plain, Size: 4166 bytes --]
Use page_cache_xxx in mm/mpage.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/mpage.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
Index: mm/fs/mpage.c
===================================================================
--- mm.orig/fs/mpage.c 2007-11-29 11:24:22.074866737 -0800
+++ mm/fs/mpage.c 2007-11-29 11:28:19.422866356 -0800
@@ -127,7 +127,8 @@ mpage_alloc(struct block_device *bdev,
static void
map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block)
{
- struct inode *inode = page->mapping->host;
+ struct address_space *mapping = page->mapping;
+ struct inode *inode = mapping->host;
struct buffer_head *page_bh, *head;
int block = 0;
@@ -136,9 +137,9 @@ map_buffer_to_page(struct page *page, st
* don't make any buffers if there is only one buffer on
* the page and the page just needs to be set up to date
*/
- if (inode->i_blkbits == PAGE_CACHE_SHIFT &&
+ if (inode->i_blkbits == page_cache_shift(mapping) &&
buffer_uptodate(bh)) {
- SetPageUptodate(page);
+ SetPageUptodate(page);
return;
}
create_empty_buffers(page, 1 << inode->i_blkbits, 0);
@@ -171,9 +172,10 @@ do_mpage_readpage(struct bio *bio, struc
sector_t *last_block_in_bio, struct buffer_head *map_bh,
unsigned long *first_logical_block, get_block_t get_block)
{
- struct inode *inode = page->mapping->host;
+ struct address_space *mapping = page->mapping;
+ struct inode *inode = mapping->host;
const unsigned blkbits = inode->i_blkbits;
- const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits;
+ const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits;
const unsigned blocksize = 1 << blkbits;
sector_t block_in_file;
sector_t last_block;
@@ -190,7 +192,7 @@ do_mpage_readpage(struct bio *bio, struc
if (page_has_buffers(page))
goto confused;
- block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits);
+ block_in_file = (sector_t)page->index << (page_cache_shift(mapping) - blkbits);
last_block = block_in_file + nr_pages * blocks_per_page;
last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits;
if (last_block > last_block_in_file)
@@ -278,7 +280,8 @@ do_mpage_readpage(struct bio *bio, struc
}
if (first_hole != blocks_per_page) {
- zero_user_segment(page, first_hole << blkbits, PAGE_CACHE_SIZE);
+ zero_user_segment(page, first_hole << blkbits,
+ page_cache_size(mapping));
if (first_hole == 0) {
SetPageUptodate(page);
unlock_page(page);
@@ -456,7 +459,7 @@ static int __mpage_writepage(struct page
struct inode *inode = page->mapping->host;
const unsigned blkbits = inode->i_blkbits;
unsigned long end_index;
- const unsigned blocks_per_page = PAGE_CACHE_SIZE >> blkbits;
+ const unsigned blocks_per_page = page_cache_size(mapping) >> blkbits;
sector_t last_block;
sector_t block_in_file;
sector_t blocks[MAX_BUF_PER_PAGE];
@@ -525,7 +528,8 @@ static int __mpage_writepage(struct page
* The page has no buffers: map it to disk
*/
BUG_ON(!PageUptodate(page));
- block_in_file = (sector_t)page->index << (PAGE_CACHE_SHIFT - blkbits);
+ block_in_file = (sector_t)page->index <<
+ (page_cache_shift(mapping) - blkbits);
last_block = (i_size - 1) >> blkbits;
map_bh.b_page = page;
for (page_block = 0; page_block < blocks_per_page; ) {
@@ -557,7 +561,7 @@ static int __mpage_writepage(struct page
first_unmapped = page_block;
page_is_mapped:
- end_index = i_size >> PAGE_CACHE_SHIFT;
+ end_index = page_cache_index(mapping, i_size);
if (page->index >= end_index) {
/*
* The page straddles i_size. It must be zeroed out on each
@@ -567,11 +571,11 @@ page_is_mapped:
* is zeroed when mapped, and writes to that region are not
* written out to the file."
*/
- unsigned offset = i_size & (PAGE_CACHE_SIZE - 1);
+ unsigned offset = page_cache_offset(mapping, i_size);
if (page->index > end_index || !offset)
goto confused;
- zero_user_segment(page, offset, PAGE_CACHE_SIZE);
+ zero_user_segment(page, offset, page_cache_size(mapping));
}
/*
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 12/19] Use page_cache_xxx in mm/fadvise.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (10 preceding siblings ...)
2007-11-30 17:34 ` [patch 11/19] Use page_cache_xxx in mm/mpage.c Christoph Lameter
@ 2007-11-30 17:35 ` Christoph Lameter
2007-11-30 17:35 ` [patch 13/19] Use page_cache_xxx in fs/splice.c Christoph Lameter
` (6 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:35 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0013-Use-page_cache_xxx-in-mm-fadvise.c.patch --]
[-- Type: text/plain, Size: 1236 bytes --]
Use page_cache_xxx in mm/fadvise.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
mm/fadvise.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: mm/mm/fadvise.c
===================================================================
--- mm.orig/mm/fadvise.c 2007-11-29 11:24:21.818866688 -0800
+++ mm/mm/fadvise.c 2007-11-29 11:28:23.520116366 -0800
@@ -79,8 +79,8 @@ asmlinkage long sys_fadvise64_64(int fd,
}
/* First and last PARTIAL page! */
- start_index = offset >> PAGE_CACHE_SHIFT;
- end_index = endbyte >> PAGE_CACHE_SHIFT;
+ start_index = page_cache_index(mapping, offset);
+ end_index = page_cache_index(mapping, endbyte);
/* Careful about overflow on the "+1" */
nrpages = end_index - start_index + 1;
@@ -100,8 +100,8 @@ asmlinkage long sys_fadvise64_64(int fd,
filemap_flush(mapping);
/* First and last FULL page! */
- start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT;
- end_index = (endbyte >> PAGE_CACHE_SHIFT);
+ start_index = page_cache_next(mapping, offset);
+ end_index = page_cache_index(mapping, endbyte);
if (end_index >= start_index)
invalidate_mapping_pages(mapping, start_index,
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 13/19] Use page_cache_xxx in fs/splice.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (11 preceding siblings ...)
2007-11-30 17:35 ` [patch 12/19] Use page_cache_xxx in mm/fadvise.c Christoph Lameter
@ 2007-11-30 17:35 ` Christoph Lameter
2007-11-30 17:35 ` [patch 14/19] Use page_cache_xxx in ext2 Christoph Lameter
` (5 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:35 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0014-Use-page_cache_xxx-in-fs-splice.c.patch --]
[-- Type: text/plain, Size: 3433 bytes --]
Use page_cache_xxx in fs/splice.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/splice.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
Index: mm/fs/splice.c
===================================================================
--- mm.orig/fs/splice.c 2007-11-29 11:24:21.758866659 -0800
+++ mm/fs/splice.c 2007-11-29 11:28:38.627616484 -0800
@@ -285,9 +285,9 @@ __generic_file_splice_read(struct file *
.spd_release = spd_release_page,
};
- index = *ppos >> PAGE_CACHE_SHIFT;
- loff = *ppos & ~PAGE_CACHE_MASK;
- req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+ index = page_cache_index(mapping, *ppos);
+ loff = page_cache_offset(mapping, *ppos);
+ req_pages = page_cache_next(mapping, len + loff);
nr_pages = min(req_pages, (unsigned)PIPE_BUFFERS);
/*
@@ -342,7 +342,7 @@ __generic_file_splice_read(struct file *
* Now loop over the map and see if we need to start IO on any
* pages, fill in the partial map, etc.
*/
- index = *ppos >> PAGE_CACHE_SHIFT;
+ index = page_cache_index(mapping, *ppos);
nr_pages = spd.nr_pages;
spd.nr_pages = 0;
for (page_nr = 0; page_nr < nr_pages; page_nr++) {
@@ -354,7 +354,8 @@ __generic_file_splice_read(struct file *
/*
* this_len is the max we'll use from this page
*/
- this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff);
+ this_len = min_t(unsigned long, len,
+ page_cache_size(mapping) - loff);
page = pages[page_nr];
if (PageReadahead(page))
@@ -414,7 +415,7 @@ fill_it:
* i_size must be checked after PageUptodate.
*/
isize = i_size_read(mapping->host);
- end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
+ end_index = page_cache_index(mapping, isize - 1);
if (unlikely(!isize || index > end_index))
break;
@@ -428,7 +429,7 @@ fill_it:
/*
* max good bytes in this page
*/
- plen = ((isize - 1) & ~PAGE_CACHE_MASK) + 1;
+ plen = page_cache_offset(mapping, isize - 1) + 1;
if (plen <= loff)
break;
@@ -453,7 +454,7 @@ fill_it:
*/
while (page_nr < nr_pages)
page_cache_release(pages[page_nr++]);
- in->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT;
+ in->f_ra.prev_pos = page_cache_pos(mapping, index, 0);
if (spd.nr_pages)
return splice_to_pipe(pipe, &spd);
@@ -579,11 +580,11 @@ static int pipe_to_file(struct pipe_inod
if (unlikely(ret))
return ret;
- offset = sd->pos & ~PAGE_CACHE_MASK;
+ offset = page_cache_offset(mapping, sd->pos);
this_len = sd->len;
- if (this_len + offset > PAGE_CACHE_SIZE)
- this_len = PAGE_CACHE_SIZE - offset;
+ if (this_len + offset > page_cache_size(mapping))
+ this_len = page_cache_size(mapping) - offset;
ret = pagecache_write_begin(file, mapping, sd->pos, this_len,
AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata);
@@ -790,7 +791,7 @@ generic_file_splice_write_nolock(struct
unsigned long nr_pages;
*ppos += ret;
- nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+ nr_pages = page_cache_next(mapping, ret);
/*
* If file or inode is SYNC and we actually wrote some data,
@@ -852,7 +853,7 @@ generic_file_splice_write(struct pipe_in
unsigned long nr_pages;
*ppos += ret;
- nr_pages = (ret + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+ nr_pages = page_cache_next(mapping, ret);
/*
* If file or inode is SYNC and we actually wrote some data,
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 14/19] Use page_cache_xxx in ext2
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (12 preceding siblings ...)
2007-11-30 17:35 ` [patch 13/19] Use page_cache_xxx in fs/splice.c Christoph Lameter
@ 2007-11-30 17:35 ` Christoph Lameter
2007-11-30 17:35 ` [patch 15/19] Use page_cache_xxx in fs/ext3 Christoph Lameter
` (4 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:35 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0015-Use-page_cache_xxx-functions-in-fs-ext2.patch --]
[-- Type: text/plain, Size: 5958 bytes --]
Use page_cache_xxx functions in fs/ext2/*
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/ext2/dir.c | 41 +++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)
Index: mm/fs/ext2/dir.c
===================================================================
--- mm.orig/fs/ext2/dir.c 2007-11-29 11:30:12.447616737 -0800
+++ mm/fs/ext2/dir.c 2007-11-29 11:53:40.599116418 -0800
@@ -63,7 +63,7 @@ static inline void ext2_put_page(struct
static inline unsigned long dir_pages(struct inode *inode)
{
- return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
+ return page_cache_next(inode->i_mapping, inode->i_size);
}
/*
@@ -74,10 +74,11 @@ static unsigned
ext2_last_byte(struct inode *inode, unsigned long page_nr)
{
unsigned last_byte = inode->i_size;
+ struct address_space *mapping = inode->i_mapping;
- last_byte -= page_nr << PAGE_CACHE_SHIFT;
- if (last_byte > PAGE_CACHE_SIZE)
- last_byte = PAGE_CACHE_SIZE;
+ last_byte -= page_cache_pos(mapping, page_nr, 0);
+ if (last_byte > page_cache_size(mapping))
+ last_byte = page_cache_size(mapping);
return last_byte;
}
@@ -105,18 +106,19 @@ static int ext2_commit_chunk(struct page
static void ext2_check_page(struct page *page)
{
- struct inode *dir = page->mapping->host;
+ struct address_space *mapping = page->mapping;
+ struct inode *dir = mapping->host;
struct super_block *sb = dir->i_sb;
unsigned chunk_size = ext2_chunk_size(dir);
char *kaddr = page_address(page);
u32 max_inumber = le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count);
unsigned offs, rec_len;
- unsigned limit = PAGE_CACHE_SIZE;
+ unsigned limit = page_cache_size(mapping);
ext2_dirent *p;
char *error;
- if ((dir->i_size >> PAGE_CACHE_SHIFT) == page->index) {
- limit = dir->i_size & ~PAGE_CACHE_MASK;
+ if (page_cache_index(mapping, dir->i_size) == page->index) {
+ limit = page_cache_offset(mapping, dir->i_size);
if (limit & (chunk_size - 1))
goto Ebadsize;
if (!limit)
@@ -168,7 +170,7 @@ Einumber:
bad_entry:
ext2_error (sb, "ext2_check_page", "bad entry in directory #%lu: %s - "
"offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
- dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT)+offs,
+ dir->i_ino, error, page_cache_pos(mapping, page->index, offs),
(unsigned long) le32_to_cpu(p->inode),
rec_len, p->name_len);
goto fail;
@@ -177,7 +179,7 @@ Eend:
ext2_error (sb, "ext2_check_page",
"entry in directory #%lu spans the page boundary"
"offset=%lu, inode=%lu",
- dir->i_ino, (page->index<<PAGE_CACHE_SHIFT)+offs,
+ dir->i_ino, page_cache_pos(mapping, page->index, offs),
(unsigned long) le32_to_cpu(p->inode));
fail:
SetPageChecked(page);
@@ -276,8 +278,9 @@ ext2_readdir (struct file * filp, void *
loff_t pos = filp->f_pos;
struct inode *inode = filp->f_path.dentry->d_inode;
struct super_block *sb = inode->i_sb;
- unsigned int offset = pos & ~PAGE_CACHE_MASK;
- unsigned long n = pos >> PAGE_CACHE_SHIFT;
+ struct address_space *mapping = inode->i_mapping;
+ unsigned int offset = page_cache_offset(mapping, pos);
+ unsigned long n = page_cache_index(mapping, pos);
unsigned long npages = dir_pages(inode);
unsigned chunk_mask = ~(ext2_chunk_size(inode)-1);
unsigned char *types = NULL;
@@ -298,14 +301,14 @@ ext2_readdir (struct file * filp, void *
ext2_error(sb, __FUNCTION__,
"bad page in #%lu",
inode->i_ino);
- filp->f_pos += PAGE_CACHE_SIZE - offset;
+ filp->f_pos += page_cache_size(mapping) - offset;
return -EIO;
}
kaddr = page_address(page);
if (unlikely(need_revalidate)) {
if (offset) {
offset = ext2_validate_entry(kaddr, offset, chunk_mask);
- filp->f_pos = (n<<PAGE_CACHE_SHIFT) + offset;
+ filp->f_pos = page_cache_pos(mapping, n, offset);
}
filp->f_version = inode->i_version;
need_revalidate = 0;
@@ -328,7 +331,7 @@ ext2_readdir (struct file * filp, void *
offset = (char *)de - kaddr;
over = filldir(dirent, de->name, de->name_len,
- (n<<PAGE_CACHE_SHIFT) | offset,
+ page_cache_pos(mapping, n, offset),
le32_to_cpu(de->inode), d_type);
if (over) {
ext2_put_page(page);
@@ -354,6 +357,7 @@ struct ext2_dir_entry_2 * ext2_find_entr
struct dentry *dentry, struct page ** res_page)
{
const char *name = dentry->d_name.name;
+ struct address_space *mapping = dir->i_mapping;
int namelen = dentry->d_name.len;
unsigned reclen = EXT2_DIR_REC_LEN(namelen);
unsigned long start, n;
@@ -395,7 +399,7 @@ struct ext2_dir_entry_2 * ext2_find_entr
if (++n >= npages)
n = 0;
/* next page is past the blocks we've got */
- if (unlikely(n > (dir->i_blocks >> (PAGE_CACHE_SHIFT - 9)))) {
+ if (unlikely(n > (dir->i_blocks >> (page_cache_shift(mapping) - 9)))) {
ext2_error(dir->i_sb, __FUNCTION__,
"dir %lu size %lld exceeds block count %llu",
dir->i_ino, dir->i_size,
@@ -466,6 +470,7 @@ void ext2_set_link(struct inode *dir, st
int ext2_add_link (struct dentry *dentry, struct inode *inode)
{
struct inode *dir = dentry->d_parent->d_inode;
+ struct address_space *mapping = inode->i_mapping;
const char *name = dentry->d_name.name;
int namelen = dentry->d_name.len;
unsigned chunk_size = ext2_chunk_size(dir);
@@ -495,7 +500,7 @@ int ext2_add_link (struct dentry *dentry
kaddr = page_address(page);
dir_end = kaddr + ext2_last_byte(dir, n);
de = (ext2_dirent *)kaddr;
- kaddr += PAGE_CACHE_SIZE - reclen;
+ kaddr += page_cache_size(mapping) - reclen;
while ((char *)de <= kaddr) {
if ((char *)de == dir_end) {
/* We hit i_size */
@@ -531,7 +536,7 @@ int ext2_add_link (struct dentry *dentry
got_it:
pos = page_offset(page) +
(char*)de - (char*)page_address(page);
- err = __ext2_write_begin(NULL, page->mapping, pos, rec_len, 0,
+ err = __ext2_write_begin(NULL, mapping, pos, rec_len, 0,
&page, NULL);
if (err)
goto out_unlock;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 15/19] Use page_cache_xxx in fs/ext3
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (13 preceding siblings ...)
2007-11-30 17:35 ` [patch 14/19] Use page_cache_xxx in ext2 Christoph Lameter
@ 2007-11-30 17:35 ` Christoph Lameter
2007-11-30 17:35 ` [patch 16/19] Use page_cache_xxx in fs/ext4 Christoph Lameter
` (3 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:35 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0016-Use-page_cache_xxx-in-fs-ext3.patch --]
[-- Type: text/plain, Size: 5269 bytes --]
Use page_cache_xxx in fs/ext3
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/ext3/dir.c | 3 ++-
fs/ext3/inode.c | 39 ++++++++++++++++++++-------------------
2 files changed, 22 insertions(+), 20 deletions(-)
Index: mm/fs/ext3/dir.c
===================================================================
--- mm.orig/fs/ext3/dir.c 2007-11-16 21:16:36.000000000 -0800
+++ mm/fs/ext3/dir.c 2007-11-28 14:11:16.689227316 -0800
@@ -133,7 +133,8 @@ static int ext3_readdir(struct file * fi
&map_bh, 0, 0);
if (err > 0) {
pgoff_t index = map_bh.b_blocknr >>
- (PAGE_CACHE_SHIFT - inode->i_blkbits);
+ (page_cache_shift(inode->i_mapping)
+ - inode->i_blkbits);
if (!ra_has_index(&filp->f_ra, index))
page_cache_sync_readahead(
sb->s_bdev->bd_inode->i_mapping,
Index: mm/fs/ext3/inode.c
===================================================================
--- mm.orig/fs/ext3/inode.c 2007-11-28 12:24:24.567962333 -0800
+++ mm/fs/ext3/inode.c 2007-11-28 14:11:16.701086757 -0800
@@ -1159,8 +1159,8 @@ static int ext3_write_begin(struct file
pgoff_t index;
unsigned from, to;
- index = pos >> PAGE_CACHE_SHIFT;
- from = pos & (PAGE_CACHE_SIZE - 1);
+ index = page_cache_index(mapping, pos);
+ from = page_cache_offset(mapping, pos);
to = from + len;
retry:
@@ -1256,7 +1256,7 @@ static int ext3_ordered_write_end(struct
unsigned from, to;
int ret = 0, ret2;
- from = pos & (PAGE_CACHE_SIZE - 1);
+ from = page_cache_offset(mapping, pos);
to = from + len;
ret = walk_page_buffers(handle, page_buffers(page),
@@ -1326,7 +1326,7 @@ static int ext3_journalled_write_end(str
int partial = 0;
unsigned from, to;
- from = pos & (PAGE_CACHE_SIZE - 1);
+ from = page_cache_offset(mapping, pos);
to = from + len;
if (copied < len) {
@@ -1489,6 +1489,7 @@ static int ext3_ordered_writepage(struct
handle_t *handle = NULL;
int ret = 0;
int err;
+ int pagesize = page_cache_size(inode->i_mapping);
J_ASSERT(PageLocked(page));
@@ -1511,8 +1512,7 @@ static int ext3_ordered_writepage(struct
(1 << BH_Dirty)|(1 << BH_Uptodate));
}
page_bufs = page_buffers(page);
- walk_page_buffers(handle, page_bufs, 0,
- PAGE_CACHE_SIZE, NULL, bget_one);
+ walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one);
ret = block_write_full_page(page, ext3_get_block, wbc);
@@ -1529,13 +1529,12 @@ static int ext3_ordered_writepage(struct
* and generally junk.
*/
if (ret == 0) {
- err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
- NULL, journal_dirty_data_fn);
+ err = walk_page_buffers(handle, page_bufs, 0, pagesize,
+ NULL, journal_dirty_data_fn);
if (!ret)
ret = err;
}
- walk_page_buffers(handle, page_bufs, 0,
- PAGE_CACHE_SIZE, NULL, bput_one);
+ walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one);
err = ext3_journal_stop(handle);
if (!ret)
ret = err;
@@ -1583,10 +1582,12 @@ out_fail:
static int ext3_journalled_writepage(struct page *page,
struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host;
+ struct address_space *mapping = page->mapping;
+ struct inode *inode = mapping->host;
handle_t *handle = NULL;
int ret = 0;
int err;
+ int pagesize = page_cache_size(inode->i_mapping);
if (ext3_journal_current_handle())
goto no_write;
@@ -1603,17 +1604,16 @@ static int ext3_journalled_writepage(str
* doesn't seem much point in redirtying the page here.
*/
ClearPageChecked(page);
- ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
- ext3_get_block);
+ ret = block_prepare_write(page, 0, pagesize, ext3_get_block);
if (ret != 0) {
ext3_journal_stop(handle);
goto out_unlock;
}
ret = walk_page_buffers(handle, page_buffers(page), 0,
- PAGE_CACHE_SIZE, NULL, do_journal_get_write_access);
+ pagesize, NULL, do_journal_get_write_access);
err = walk_page_buffers(handle, page_buffers(page), 0,
- PAGE_CACHE_SIZE, NULL, write_end_fn);
+ pagesize, NULL, write_end_fn);
if (ret == 0)
ret = err;
EXT3_I(inode)->i_state |= EXT3_STATE_JDATA;
@@ -1828,8 +1828,8 @@ void ext3_set_aops(struct inode *inode)
static int ext3_block_truncate_page(handle_t *handle, struct page *page,
struct address_space *mapping, loff_t from)
{
- ext3_fsblk_t index = from >> PAGE_CACHE_SHIFT;
- unsigned offset = from & (PAGE_CACHE_SIZE-1);
+ ext3_fsblk_t index = page_cache_index(mapping, from);
+ unsigned offset = page_cache_offset(mapping, from);
unsigned blocksize, iblock, length, pos;
struct inode *inode = mapping->host;
struct buffer_head *bh;
@@ -1837,7 +1837,8 @@ static int ext3_block_truncate_page(hand
blocksize = inode->i_sb->s_blocksize;
length = blocksize - (offset & (blocksize - 1));
- iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
+ iblock = index <<
+ (page_cache_shift(mapping) - inode->i_sb->s_blocksize_bits);
/*
* For "nobh" option, we can only work if we don't need to
@@ -2316,7 +2317,7 @@ void ext3_truncate(struct inode *inode)
page = NULL;
} else {
page = grab_cache_page(mapping,
- inode->i_size >> PAGE_CACHE_SHIFT);
+ page_cache_index(mapping, inode->i_size));
if (!page)
return;
}
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 16/19] Use page_cache_xxx in fs/ext4
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (14 preceding siblings ...)
2007-11-30 17:35 ` [patch 15/19] Use page_cache_xxx in fs/ext3 Christoph Lameter
@ 2007-11-30 17:35 ` Christoph Lameter
2007-11-30 17:35 ` [patch 17/19] Use page_cache_xxx in fs/reiserfs Christoph Lameter
` (2 subsequent siblings)
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:35 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0017-Use-page_cache_xxx-in-fs-ext4.patch --]
[-- Type: text/plain, Size: 5066 bytes --]
Use page_cache_xxx in fs/ext4
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/ext4/dir.c | 3 ++-
fs/ext4/inode.c | 34 +++++++++++++++++-----------------
2 files changed, 19 insertions(+), 18 deletions(-)
Index: mm/fs/ext4/dir.c
===================================================================
--- mm.orig/fs/ext4/dir.c 2007-11-29 11:24:20.922866366 -0800
+++ mm/fs/ext4/dir.c 2007-11-29 11:29:12.515367251 -0800
@@ -132,7 +132,8 @@ static int ext4_readdir(struct file * fi
err = ext4_get_blocks_wrap(NULL, inode, blk, 1, &map_bh, 0, 0);
if (err > 0) {
pgoff_t index = map_bh.b_blocknr >>
- (PAGE_CACHE_SHIFT - inode->i_blkbits);
+ (page_cache_size(inode->i_mapping)
+ - inode->i_blkbits);
if (!ra_has_index(&filp->f_ra, index))
page_cache_sync_readahead(
sb->s_bdev->bd_inode->i_mapping,
Index: mm/fs/ext4/inode.c
===================================================================
--- mm.orig/fs/ext4/inode.c 2007-11-29 11:24:20.934867896 -0800
+++ mm/fs/ext4/inode.c 2007-11-29 11:29:20.370866280 -0800
@@ -1110,8 +1110,8 @@ static int ext4_write_begin(struct file
pgoff_t index;
unsigned from, to;
- index = pos >> PAGE_CACHE_SHIFT;
- from = pos & (PAGE_CACHE_SIZE - 1);
+ index = page_cache_index(mapping, pos);
+ from = page_cache_offset(mapping, pos);
to = from + len;
retry:
@@ -1206,7 +1206,7 @@ static int ext4_ordered_write_end(struct
unsigned from, to;
int ret = 0, ret2;
- from = pos & (PAGE_CACHE_SIZE - 1);
+ from = page_cache_offset(mapping, pos);
to = from + len;
ret = walk_page_buffers(handle, page_buffers(page),
@@ -1276,7 +1276,7 @@ static int ext4_journalled_write_end(str
int partial = 0;
unsigned from, to;
- from = pos & (PAGE_CACHE_SIZE - 1);
+ from = page_cache_offset(mapping, pos);
to = from + len;
if (copied < len) {
@@ -1579,6 +1579,7 @@ static int ext4_ordered_writepage(struct
handle_t *handle = NULL;
int ret = 0;
int err;
+ int pagesize = page_cache_size(inode->i_mapping);
J_ASSERT(PageLocked(page));
@@ -1601,8 +1602,7 @@ static int ext4_ordered_writepage(struct
(1 << BH_Dirty)|(1 << BH_Uptodate));
}
page_bufs = page_buffers(page);
- walk_page_buffers(handle, page_bufs, 0,
- PAGE_CACHE_SIZE, NULL, bget_one);
+ walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bget_one);
ret = block_write_full_page(page, ext4_get_block, wbc);
@@ -1619,13 +1619,12 @@ static int ext4_ordered_writepage(struct
* and generally junk.
*/
if (ret == 0) {
- err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
+ err = walk_page_buffers(handle, page_bufs, 0, pagesize,
NULL, jbd2_journal_dirty_data_fn);
if (!ret)
ret = err;
}
- walk_page_buffers(handle, page_bufs, 0,
- PAGE_CACHE_SIZE, NULL, bput_one);
+ walk_page_buffers(handle, page_bufs, 0, pagesize, NULL, bput_one);
err = ext4_journal_stop(handle);
if (!ret)
ret = err;
@@ -1677,6 +1676,7 @@ static int ext4_journalled_writepage(str
handle_t *handle = NULL;
int ret = 0;
int err;
+ int pagesize = page_cache_size(inode->i_mapping);
if (ext4_journal_current_handle())
goto no_write;
@@ -1693,17 +1693,16 @@ static int ext4_journalled_writepage(str
* doesn't seem much point in redirtying the page here.
*/
ClearPageChecked(page);
- ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
- ext4_get_block);
+ ret = block_prepare_write(page, 0, pagesize, ext4_get_block);
if (ret != 0) {
ext4_journal_stop(handle);
goto out_unlock;
}
ret = walk_page_buffers(handle, page_buffers(page), 0,
- PAGE_CACHE_SIZE, NULL, do_journal_get_write_access);
+ pagesize, NULL, do_journal_get_write_access);
err = walk_page_buffers(handle, page_buffers(page), 0,
- PAGE_CACHE_SIZE, NULL, write_end_fn);
+ pagesize, NULL, write_end_fn);
if (ret == 0)
ret = err;
EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
@@ -1936,8 +1935,8 @@ void ext4_set_aops(struct inode *inode)
int ext4_block_truncate_page(handle_t *handle, struct page *page,
struct address_space *mapping, loff_t from)
{
- ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT;
- unsigned offset = from & (PAGE_CACHE_SIZE-1);
+ ext4_fsblk_t index = page_cache_index(mapping, from);
+ unsigned offset = page_cache_offset(mapping, from);
unsigned blocksize, length, pos;
ext4_lblk_t iblock;
struct inode *inode = mapping->host;
@@ -1946,7 +1945,8 @@ int ext4_block_truncate_page(handle_t *h
blocksize = inode->i_sb->s_blocksize;
length = blocksize - (offset & (blocksize - 1));
- iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
+ iblock = index <<
+ (page_cache_shift(mapping) - inode->i_sb->s_blocksize_bits);
/*
* For "nobh" option, we can only work if we don't need to
@@ -2426,7 +2426,7 @@ void ext4_truncate(struct inode *inode)
page = NULL;
} else {
page = grab_cache_page(mapping,
- inode->i_size >> PAGE_CACHE_SHIFT);
+ page_cache_index(mapping, inode->i_size));
if (!page)
return;
}
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 17/19] Use page_cache_xxx in fs/reiserfs
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (15 preceding siblings ...)
2007-11-30 17:35 ` [patch 16/19] Use page_cache_xxx in fs/ext4 Christoph Lameter
@ 2007-11-30 17:35 ` Christoph Lameter
2007-11-30 17:35 ` [patch 18/19] Use page_cache_xxx for fs/xfs Christoph Lameter
2007-11-30 17:35 ` [patch 19/19] Use page_cache_xxx in drivers/block/rd.c Christoph Lameter
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:35 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0018-Use-page_cache_xxx-in-fs-reiserfs.patch --]
[-- Type: text/plain, Size: 10364 bytes --]
Use page_cache_xxx in fs/reiserfs
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/reiserfs/file.c | 6 ++++--
fs/reiserfs/inode.c | 33 ++++++++++++++++++++-------------
fs/reiserfs/ioctl.c | 2 +-
fs/reiserfs/stree.c | 5 +++--
fs/reiserfs/tail_conversion.c | 5 +++--
fs/reiserfs/xattr.c | 19 ++++++++++---------
6 files changed, 41 insertions(+), 29 deletions(-)
Index: mm/fs/reiserfs/file.c
===================================================================
--- mm.orig/fs/reiserfs/file.c 2007-11-29 11:24:20.387116374 -0800
+++ mm/fs/reiserfs/file.c 2007-11-29 11:29:27.850866491 -0800
@@ -161,11 +161,12 @@ int reiserfs_commit_page(struct inode *i
int partial = 0;
unsigned blocksize;
struct buffer_head *bh, *head;
- unsigned long i_size_index = inode->i_size >> PAGE_CACHE_SHIFT;
+ unsigned long i_size_index =
+ page_cache_index(inode->i_mapping, inode->i_size);
int new;
int logit = reiserfs_file_data_log(inode);
struct super_block *s = inode->i_sb;
- int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
+ int bh_per_page = page_cache_size(inode->i_mapping) / s->s_blocksize;
struct reiserfs_transaction_handle th;
int ret = 0;
Index: mm/fs/reiserfs/inode.c
===================================================================
--- mm.orig/fs/reiserfs/inode.c 2007-11-29 11:24:20.395117533 -0800
+++ mm/fs/reiserfs/inode.c 2007-11-29 11:29:36.146866339 -0800
@@ -337,7 +337,8 @@ static int _get_block_create_0(struct in
goto finished;
}
// read file tail into part of page
- offset = (cpu_key_k_offset(&key) - 1) & (PAGE_CACHE_SIZE - 1);
+ offset = page_cache_offset(inode->i_mapping,
+ cpu_key_k_offset(&key) - 1);
fs_gen = get_generation(inode->i_sb);
copy_item_head(&tmp_ih, ih);
@@ -523,10 +524,10 @@ static int convert_tail_for_hole(struct
return -EIO;
/* always try to read until the end of the block */
- tail_start = tail_offset & (PAGE_CACHE_SIZE - 1);
+ tail_start = page_cache_offset(inode->i_mapping, tail_offset);
tail_end = (tail_start | (bh_result->b_size - 1)) + 1;
- index = tail_offset >> PAGE_CACHE_SHIFT;
+ index = page_cache_index(inode->i_mapping, tail_offset);
/* hole_page can be zero in case of direct_io, we are sure
that we cannot get here if we write with O_DIRECT into
tail page */
@@ -2000,11 +2001,13 @@ static int grab_tail_page(struct inode *
/* we want the page with the last byte in the file,
** not the page that will hold the next byte for appending
*/
- unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT;
+ unsigned long index = page_cache_index(p_s_inode->i_mapping,
+ p_s_inode->i_size - 1);
unsigned long pos = 0;
unsigned long start = 0;
unsigned long blocksize = p_s_inode->i_sb->s_blocksize;
- unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1);
+ unsigned long offset = page_cache_offset(p_s_inode->i_mapping,
+ p_s_inode->i_size);
struct buffer_head *bh;
struct buffer_head *head;
struct page *page;
@@ -2076,7 +2079,8 @@ int reiserfs_truncate_file(struct inode
{
struct reiserfs_transaction_handle th;
/* we want the offset for the first byte after the end of the file */
- unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1);
+ unsigned long offset = page_cache_offset(p_s_inode->i_mapping,
+ p_s_inode->i_size);
unsigned blocksize = p_s_inode->i_sb->s_blocksize;
unsigned length;
struct page *page = NULL;
@@ -2225,7 +2229,7 @@ static int map_block_for_writepage(struc
} else if (is_direct_le_ih(ih)) {
char *p;
p = page_address(bh_result->b_page);
- p += (byte_offset - 1) & (PAGE_CACHE_SIZE - 1);
+ p += page_cache_offset(inode->i_mapping, byte_offset - 1);
copy_size = ih_item_len(ih) - pos_in_item;
fs_gen = get_generation(inode->i_sb);
@@ -2324,7 +2328,8 @@ static int reiserfs_write_full_page(stru
struct writeback_control *wbc)
{
struct inode *inode = page->mapping->host;
- unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT;
+ unsigned long end_index = page_cache_index(inode->i_mapping,
+ inode->i_size);
int error = 0;
unsigned long block;
sector_t last_block;
@@ -2334,7 +2339,7 @@ static int reiserfs_write_full_page(stru
int checked = PageChecked(page);
struct reiserfs_transaction_handle th;
struct super_block *s = inode->i_sb;
- int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
+ int bh_per_page = page_cache_size(inode->i_mapping) / s->s_blocksize;
th.t_trans_id = 0;
/* no logging allowed when nonblocking or from PF_MEMALLOC */
@@ -2361,16 +2366,18 @@ static int reiserfs_write_full_page(stru
if (page->index >= end_index) {
unsigned last_offset;
- last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
+ last_offset = page_cache_offset(inode->i_mapping, inode->i_size);
/* no file contents in this page */
if (page->index >= end_index + 1 || !last_offset) {
unlock_page(page);
return 0;
}
- zero_user_segment(page, last_offset, PAGE_CACHE_SIZE);
+ zero_user_segment(page, last_offset,
+ page_cache_size(inode->i_mapping));
}
bh = head;
- block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits);
+ block = page->index << (page_cache_shift(inode->i_mapping)
+ - s->s_blocksize_bits);
last_block = (i_size_read(inode) - 1) >> inode->i_blkbits;
/* first map all the buffers, logging any direct items we find */
do {
@@ -2765,7 +2772,7 @@ int reiserfs_commit_write(struct file *f
unsigned from, unsigned to)
{
struct inode *inode = page->mapping->host;
- loff_t pos = ((loff_t) page->index << PAGE_CACHE_SHIFT) + to;
+ loff_t pos = page_cache_pos(page->mapping, page->index, to);
int ret = 0;
int update_sd = 0;
struct reiserfs_transaction_handle *th = NULL;
Index: mm/fs/reiserfs/ioctl.c
===================================================================
--- mm.orig/fs/reiserfs/ioctl.c 2007-11-29 11:24:20.399116487 -0800
+++ mm/fs/reiserfs/ioctl.c 2007-11-29 11:29:27.866866325 -0800
@@ -194,8 +194,8 @@ static int reiserfs_unpack(struct inode
** reiserfs_prepare_write on that page. This will force a
** reiserfs_get_block to unpack the tail for us.
*/
- index = inode->i_size >> PAGE_CACHE_SHIFT;
mapping = inode->i_mapping;
+ index = page_cache_index(mapping, inode->i_size);
page = grab_cache_page(mapping, index);
retval = -ENOMEM;
if (!page) {
Index: mm/fs/reiserfs/stree.c
===================================================================
--- mm.orig/fs/reiserfs/stree.c 2007-11-29 11:24:20.407116512 -0800
+++ mm/fs/reiserfs/stree.c 2007-11-29 11:29:27.866866325 -0800
@@ -1283,7 +1283,8 @@ int reiserfs_delete_item(struct reiserfs
*/
data = kmap_atomic(p_s_un_bh->b_page, KM_USER0);
- off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1));
+ off = page_cache_offset(p_s_inode->i_mapping,
+ le_ih_k_offset(&s_ih) - 1);
memcpy(data + off,
B_I_PITEM(PATH_PLAST_BUFFER(p_s_path), &s_ih),
n_ret_value);
@@ -1439,7 +1440,7 @@ static void unmap_buffers(struct page *p
if (page) {
if (page_has_buffers(page)) {
- tail_index = pos & (PAGE_CACHE_SIZE - 1);
+ tail_index = page_cache_offset(page_mapping(page), pos);
cur_index = 0;
head = page_buffers(page);
bh = head;
Index: mm/fs/reiserfs/tail_conversion.c
===================================================================
--- mm.orig/fs/reiserfs/tail_conversion.c 2007-11-29 11:24:20.411116386 -0800
+++ mm/fs/reiserfs/tail_conversion.c 2007-11-29 11:29:27.866866325 -0800
@@ -128,7 +128,8 @@ int direct2indirect(struct reiserfs_tran
*/
if (up_to_date_bh) {
unsigned pgoff =
- (tail_offset + total_tail - 1) & (PAGE_CACHE_SIZE - 1);
+ page_cache_offset(inode->i_mapping,
+ tail_offset + total_tail - 1);
char *kaddr = kmap_atomic(up_to_date_bh->b_page, KM_USER0);
memset(kaddr + pgoff, 0, n_blk_size - total_tail);
kunmap_atomic(kaddr, KM_USER0);
@@ -238,7 +239,7 @@ int indirect2direct(struct reiserfs_tran
** the page was locked and this part of the page was up to date when
** indirect2direct was called, so we know the bytes are still valid
*/
- tail = tail + (pos & (PAGE_CACHE_SIZE - 1));
+ tail = tail + page_cache_offset(p_s_inode->i_mapping, pos);
PATH_LAST_POSITION(p_s_path)++;
Index: mm/fs/reiserfs/xattr.c
===================================================================
--- mm.orig/fs/reiserfs/xattr.c 2007-11-29 11:24:20.423116619 -0800
+++ mm/fs/reiserfs/xattr.c 2007-11-29 11:29:27.870866417 -0800
@@ -468,13 +468,13 @@ reiserfs_xattr_set(struct inode *inode,
while (buffer_pos < buffer_size || buffer_pos == 0) {
size_t chunk;
size_t skip = 0;
- size_t page_offset = (file_pos & (PAGE_CACHE_SIZE - 1));
- if (buffer_size - buffer_pos > PAGE_CACHE_SIZE)
- chunk = PAGE_CACHE_SIZE;
+ size_t page_offset = page_cache_offset(mapping, file_pos);
+ if (buffer_size - buffer_pos > page_cache_size(mapping))
+ chunk = page_cache_size(mapping);
else
chunk = buffer_size - buffer_pos;
- page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
+ page = reiserfs_get_page(xinode, page_cache_index(mapping, file_pos));
if (IS_ERR(page)) {
err = PTR_ERR(page);
goto out_filp;
@@ -486,8 +486,8 @@ reiserfs_xattr_set(struct inode *inode,
if (file_pos == 0) {
struct reiserfs_xattr_header *rxh;
skip = file_pos = sizeof(struct reiserfs_xattr_header);
- if (chunk + skip > PAGE_CACHE_SIZE)
- chunk = PAGE_CACHE_SIZE - skip;
+ if (chunk + skip > page_cache_size(mapping))
+ chunk = page_cache_size(mapping) - skip;
rxh = (struct reiserfs_xattr_header *)data;
rxh->h_magic = cpu_to_le32(REISERFS_XATTR_MAGIC);
rxh->h_hash = cpu_to_le32(xahash);
@@ -577,12 +577,13 @@ reiserfs_xattr_get(const struct inode *i
size_t chunk;
char *data;
size_t skip = 0;
- if (isize - file_pos > PAGE_CACHE_SIZE)
- chunk = PAGE_CACHE_SIZE;
+ if (isize - file_pos > page_cache_size(xinode->i_mapping))
+ chunk = page_cache_size(xinode->i_mapping);
else
chunk = isize - file_pos;
- page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
+ page = reiserfs_get_page(xinode,
+ page_cache_index(xinode->i_mapping, file_pos));
if (IS_ERR(page)) {
err = PTR_ERR(page);
goto out_dput;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 18/19] Use page_cache_xxx for fs/xfs
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (16 preceding siblings ...)
2007-11-30 17:35 ` [patch 17/19] Use page_cache_xxx in fs/reiserfs Christoph Lameter
@ 2007-11-30 17:35 ` Christoph Lameter
2007-11-30 17:35 ` [patch 19/19] Use page_cache_xxx in drivers/block/rd.c Christoph Lameter
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:35 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0019-Use-page_cache_xxx-for-fs-xfs.patch --]
[-- Type: text/plain, Size: 6889 bytes --]
Use page_cache_xxx for fs/xfs
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
fs/xfs/linux-2.6/xfs_aops.c | 55 ++++++++++++++++++++++----------------------
fs/xfs/linux-2.6/xfs_lrw.c | 4 +--
2 files changed, 30 insertions(+), 29 deletions(-)
Index: mm/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- mm.orig/fs/xfs/linux-2.6/xfs_aops.c 2007-11-29 11:24:19.606866627 -0800
+++ mm/fs/xfs/linux-2.6/xfs_aops.c 2007-11-29 11:29:55.115116317 -0800
@@ -75,7 +75,7 @@ xfs_page_trace(
xfs_inode_t *ip;
bhv_vnode_t *vp = vn_from_inode(inode);
loff_t isize = i_size_read(inode);
- loff_t offset = page_offset(page);
+ loff_t offset = page_cache_pos(page->mapping, page->index, 0);
int delalloc = -1, unmapped = -1, unwritten = -1;
if (page_has_buffers(page))
@@ -618,7 +618,7 @@ xfs_probe_page(
break;
} while ((bh = bh->b_this_page) != head);
} else
- ret = mapped ? 0 : PAGE_CACHE_SIZE;
+ ret = mapped ? 0 : page_cache_size(page->mapping);
}
return ret;
@@ -645,7 +645,7 @@ xfs_probe_cluster(
} while ((bh = bh->b_this_page) != head);
/* if we reached the end of the page, sum forwards in following pages */
- tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
+ tlast = page_cache_index(inode->i_mapping, i_size_read(inode));
tindex = startpage->index + 1;
/* Prune this back to avoid pathological behavior */
@@ -663,14 +663,14 @@ xfs_probe_cluster(
size_t pg_offset, pg_len = 0;
if (tindex == tlast) {
- pg_offset =
- i_size_read(inode) & (PAGE_CACHE_SIZE - 1);
+ pg_offset = page_cache_offset(inode->i_mapping,
+ i_size_read(inode));
if (!pg_offset) {
done = 1;
break;
}
} else
- pg_offset = PAGE_CACHE_SIZE;
+ pg_offset = page_cache_size(inode->i_mapping);
if (page->index == tindex && !TestSetPageLocked(page)) {
pg_len = xfs_probe_page(page, pg_offset, mapped);
@@ -752,7 +752,8 @@ xfs_convert_page(
int bbits = inode->i_blkbits;
int len, page_dirty;
int count = 0, done = 0, uptodate = 1;
- xfs_off_t offset = page_offset(page);
+ struct address_space *map = inode->i_mapping;
+ xfs_off_t offset = page_cache_pos(map, page->index, 0);
if (page->index != tindex)
goto fail;
@@ -760,7 +761,7 @@ xfs_convert_page(
goto fail;
if (PageWriteback(page))
goto fail_unlock_page;
- if (page->mapping != inode->i_mapping)
+ if (page->mapping != map)
goto fail_unlock_page;
if (!xfs_is_delayed_page(page, (*ioendp)->io_type))
goto fail_unlock_page;
@@ -772,20 +773,19 @@ xfs_convert_page(
* Derivation:
*
* End offset is the highest offset that this page should represent.
- * If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1))
- * will evaluate non-zero and be less than PAGE_CACHE_SIZE and
+ * If we are on the last page, (end_offset & page_cache_mask())
+ * will evaluate non-zero and be less than page_cache_size() and
* hence give us the correct page_dirty count. On any other page,
* it will be zero and in that case we need page_dirty to be the
* count of buffers on the page.
*/
end_offset = min_t(unsigned long long,
- (xfs_off_t)(page->index + 1) << PAGE_CACHE_SHIFT,
+ (xfs_off_t)page_cache_pos(map, page->index + 1, 0),
i_size_read(inode));
len = 1 << inode->i_blkbits;
- p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1),
- PAGE_CACHE_SIZE);
- p_offset = p_offset ? roundup(p_offset, len) : PAGE_CACHE_SIZE;
+ p_offset = page_cache_offset(map, end_offset);
+ p_offset = p_offset ? roundup(p_offset, len) : page_cache_size(map);
page_dirty = p_offset / len;
bh = head = page_buffers(page);
@@ -941,6 +941,7 @@ xfs_page_state_convert(
int page_dirty, count = 0;
int trylock = 0;
int all_bh = unmapped;
+ struct address_space *map = inode->i_mapping;
if (startio) {
if (wbc->sync_mode == WB_SYNC_NONE && wbc->nonblocking)
@@ -949,11 +950,11 @@ xfs_page_state_convert(
/* Is this page beyond the end of the file? */
offset = i_size_read(inode);
- end_index = offset >> PAGE_CACHE_SHIFT;
- last_index = (offset - 1) >> PAGE_CACHE_SHIFT;
+ end_index = page_cache_index(map, offset);
+ last_index = page_cache_index(map, (offset - 1));
if (page->index >= end_index) {
if ((page->index >= end_index + 1) ||
- !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
+ !(page_cache_offset(map, i_size_read(inode)))) {
if (startio)
unlock_page(page);
return 0;
@@ -967,22 +968,22 @@ xfs_page_state_convert(
* Derivation:
*
* End offset is the highest offset that this page should represent.
- * If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1))
- * will evaluate non-zero and be less than PAGE_CACHE_SIZE and
- * hence give us the correct page_dirty count. On any other page,
+ * If we are on the last page, (page_cache_offset(mapping, end_offset))
+ * will evaluate non-zero and be less than page_cache_size(mapping)
+ * and hence give us the correct page_dirty count. On any other page,
* it will be zero and in that case we need page_dirty to be the
* count of buffers on the page.
*/
end_offset = min_t(unsigned long long,
- (xfs_off_t)(page->index + 1) << PAGE_CACHE_SHIFT, offset);
+ (xfs_off_t)page_cache_pos(map, page->index + 1, 0), offset);
len = 1 << inode->i_blkbits;
- p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1),
- PAGE_CACHE_SIZE);
- p_offset = p_offset ? roundup(p_offset, len) : PAGE_CACHE_SIZE;
+ p_offset = page_cache_offset(map, end_offset);
+ p_offset = p_offset ? roundup(p_offset, len) : page_cache_size(map);
+
page_dirty = p_offset / len;
bh = head = page_buffers(page);
- offset = page_offset(page);
+ offset = page_cache_pos(map, page->index, 0);
flags = BMAPI_READ;
type = IOMAP_NEW;
@@ -1129,8 +1130,8 @@ xfs_page_state_convert(
xfs_start_page_writeback(page, wbc, 1, count);
if (ioend && iomap_valid) {
- offset = (iomap.iomap_offset + iomap.iomap_bsize - 1) >>
- PAGE_CACHE_SHIFT;
+ offset = page_cache_index(map,
+ (iomap.iomap_offset + iomap.iomap_bsize - 1));
tlast = min_t(pgoff_t, offset, last_index);
xfs_cluster_write(inode, page->index + 1, &iomap, &ioend,
wbc, startio, all_bh, tlast);
Index: mm/fs/xfs/linux-2.6/xfs_lrw.c
===================================================================
--- mm.orig/fs/xfs/linux-2.6/xfs_lrw.c 2007-11-29 11:24:19.618866869 -0800
+++ mm/fs/xfs/linux-2.6/xfs_lrw.c 2007-11-29 11:29:55.115116317 -0800
@@ -142,8 +142,8 @@ xfs_iozero(
unsigned offset, bytes;
void *fsdata;
- offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */
- bytes = PAGE_CACHE_SIZE - offset;
+ offset = page_cache_offset(mapping, pos);
+ bytes = page_cache_size(mapping) - offset;
if (bytes > count)
bytes = count;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* [patch 19/19] Use page_cache_xxx in drivers/block/rd.c
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
` (17 preceding siblings ...)
2007-11-30 17:35 ` [patch 18/19] Use page_cache_xxx for fs/xfs Christoph Lameter
@ 2007-11-30 17:35 ` Christoph Lameter
18 siblings, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-11-30 17:35 UTC (permalink / raw)
To: akpm
Cc: linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
[-- Attachment #1: 0020-Use-page_cache_xxx-in-drivers-block-rd.c.patch --]
[-- Type: text/plain, Size: 1475 bytes --]
Use page_cache_xxx in drivers/block/rd.c
Reviewed-by: Dave Chinner <dgc@sgi.com>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
drivers/block/rd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Index: mm/drivers/block/rd.c
===================================================================
--- mm.orig/drivers/block/rd.c 2007-11-28 16:54:34.007439863 -0800
+++ mm/drivers/block/rd.c 2007-11-29 11:23:58.900823092 -0800
@@ -122,7 +122,7 @@ static void make_page_uptodate(struct pa
}
} while ((bh = bh->b_this_page) != head);
} else {
- memset(page_address(page), 0, PAGE_CACHE_SIZE);
+ memset(page_address(page), 0, page_cache_size(page_mapping(page)));
}
flush_dcache_page(page);
SetPageUptodate(page);
@@ -215,9 +215,9 @@ static const struct address_space_operat
static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec, sector_t sector,
struct address_space *mapping)
{
- pgoff_t index = sector >> (PAGE_CACHE_SHIFT - 9);
+ pgoff_t index = sector >> (page_cache_shift(mapping) - 9);
unsigned int vec_offset = vec->bv_offset;
- int offset = (sector << 9) & ~PAGE_CACHE_MASK;
+ int offset = page_cache_offset(mapping, (sector << 9));
int size = vec->bv_len;
int err = 0;
@@ -227,7 +227,7 @@ static int rd_blkdev_pagecache_IO(int rw
char *src;
char *dst;
- count = PAGE_CACHE_SIZE - offset;
+ count = page_cache_size(mapping) - offset;
if (count > size)
count = size;
size -= count;
--
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 01/19] Define functions for page cache handling
2007-11-30 17:34 ` [patch 01/19] Define functions for page cache handling Christoph Lameter
@ 2007-12-03 22:10 ` Andrew Morton
2007-12-04 5:59 ` David Chinner
2007-12-18 20:20 ` Christoph Lameter
0 siblings, 2 replies; 30+ messages in thread
From: Andrew Morton @ 2007-12-03 22:10 UTC (permalink / raw)
To: Christoph Lameter
Cc: linux-fsdevel, linux-mm, hch, mel, wli, dgc, jens.axboe, pbadari,
maximlevitsky, fengguang.wu, wangswin, totty.lu, hugh, joern
On Fri, 30 Nov 2007 09:34:49 -0800
Christoph Lameter <clameter@sgi.com> wrote:
> We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK
> and PAGE_CACHE_ALIGN in various places in the kernel. Many times
> common operations like calculating the offset or the index are coded
> using shifts and adds. This patch provides inline functions to
> get the calculations accomplished without having to explicitly
> shift and add constants.
>
> All functions take an address_space pointer. The address space pointer
> will be used in the future to eventually support a variable size
> page cache. Information reachable via the mapping may then determine
> page size.
>
> New function Related base page constant
> ====================================================================
> page_cache_shift(a) PAGE_CACHE_SHIFT
> page_cache_size(a) PAGE_CACHE_SIZE
> page_cache_mask(a) PAGE_CACHE_MASK
> page_cache_index(a, pos) Calculate page number from position
> page_cache_next(addr, pos) Page number of next page
> page_cache_offset(a, pos) Calculate offset into a page
> page_cache_pos(a, index, offset)
> Form position based on page number
> and an offset.
>
> This provides a basis that would allow the conversion of all page cache
> handling in the kernel and ultimately allow the removal of the PAGE_CACHE_*
> constants.
>
> ...
>
> +/*
> + * Functions that are currently setup for a fixed PAGE_SIZEd. The use of
> + * these will allow the user of largere page sizes in the future.
> + */
> +static inline int mapping_order(struct address_space *a)
> +{
> + return 0;
> +}
> +
> +static inline int page_cache_shift(struct address_space *a)
> +{
> + return PAGE_SHIFT;
> +}
> +
> +static inline unsigned int page_cache_size(struct address_space *a)
> +{
> + return PAGE_SIZE;
> +}
> +
> +static inline unsigned int page_cache_offset(struct address_space *a,
> + loff_t pos)
> +{
> + return pos & ~PAGE_MASK;
> +}
> +
> +static inline pgoff_t page_cache_index(struct address_space *a,
> + loff_t pos)
> +{
> + return pos >> page_cache_shift(a);
> +}
These will of course all work OK as they are presently implemented.
But you have callsites doing things like
page_cache_size(page_mapping(page));
which is a whole different thing. Once page_cache_size() is changed to
look inside the address_space we need to handle races against truncation
and we need to handle the address_space getting reclaimed, etc.
So I think it would be misleading to merge these changes at present - they
make it _look_ like we can have variable PAGE_CACHE_SIZE just by tweaking a
bit of core code, but we in fact cannot do that without a careful review of
all callsites and perhaps the addition of new locking and null-checking.
Now, one possible way around this is to rework all these functions so they
take only a page*, and to create (and assert) the requirement that the caller
has locked the page. That's a little bit inefficient (additional calls to
page_mapping()) but it does mean that we can now confidently change the
implementation of these functions as you intend.
And a coding nit: when you implement the out-of-line versions of these
functions you're going to stick with VFS conventions and use the identifier
`mapping' to identify the address_space*. So I think it would be better to
also call in `mapping' in these inlined stubbed functions, rather than `a'.
No?
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 07/19] Use page_cache_xxx in mm/migrate.c
2007-11-30 17:34 ` [patch 07/19] Use page_cache_xxx in mm/migrate.c Christoph Lameter
@ 2007-12-04 5:45 ` David Chinner
0 siblings, 0 replies; 30+ messages in thread
From: David Chinner @ 2007-12-04 5:45 UTC (permalink / raw)
To: Christoph Lameter
Cc: akpm, linux-fsdevel, linux-mm, Christoph Hellwig, Mel Gorman,
William Lee Irwin III, David Chinner, Jens Axboe,
Badari Pulavarty, Maxim Levitsky, Fengguang Wu, swin wang,
totty.lu, hugh, joern
On Fri, Nov 30, 2007 at 09:34:55AM -0800, Christoph Lameter wrote:
> Use page_cache_xxx in mm/migrate.c
>
> Reviewed-by: Dave Chinner <dgc@sgi.com>
> Signed-off-by: Christoph Lameter <clameter@sgi.com>
> ---
> mm/migrate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: mm/mm/migrate.c
> ===================================================================
> --- mm.orig/mm/migrate.c 2007-11-28 12:27:32.184464256 -0800
> +++ mm/mm/migrate.c 2007-11-28 14:10:49.200977227 -0800
> @@ -197,7 +197,7 @@ static void remove_file_migration_ptes(s
> struct vm_area_struct *vma;
> struct address_space *mapping = page_mapping(new);
> struct prio_tree_iter iter;
> - pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> + pgoff_t pgoff = new->index << mapping_order(mapping);
>
> if (!mapping)
> return;
Mapping could be NULL, therefore the setting of pgoff needs to
occur after the !mapping check.
Cheers,
Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 01/19] Define functions for page cache handling
2007-12-03 22:10 ` Andrew Morton
@ 2007-12-04 5:59 ` David Chinner
2007-12-18 20:20 ` Christoph Lameter
1 sibling, 0 replies; 30+ messages in thread
From: David Chinner @ 2007-12-04 5:59 UTC (permalink / raw)
To: Andrew Morton
Cc: Christoph Lameter, linux-fsdevel, linux-mm, hch, mel, wli, dgc,
jens.axboe, pbadari, maximlevitsky, fengguang.wu, wangswin,
totty.lu, hugh, joern
On Mon, Dec 03, 2007 at 02:10:20PM -0800, Andrew Morton wrote:
> On Fri, 30 Nov 2007 09:34:49 -0800
> Christoph Lameter <clameter@sgi.com> wrote:
>
> > We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK
> > and PAGE_CACHE_ALIGN in various places in the kernel. Many times
> > common operations like calculating the offset or the index are coded
> > using shifts and adds. This patch provides inline functions to
> > get the calculations accomplished without having to explicitly
> > shift and add constants.
> >
> > All functions take an address_space pointer. The address space pointer
> > will be used in the future to eventually support a variable size
> > page cache. Information reachable via the mapping may then determine
> > page size.
> >
> > New function Related base page constant
> > ====================================================================
> > page_cache_shift(a) PAGE_CACHE_SHIFT
> > page_cache_size(a) PAGE_CACHE_SIZE
> > page_cache_mask(a) PAGE_CACHE_MASK
> > page_cache_index(a, pos) Calculate page number from position
> > page_cache_next(addr, pos) Page number of next page
> > page_cache_offset(a, pos) Calculate offset into a page
> > page_cache_pos(a, index, offset)
> > Form position based on page number
> > and an offset.
> >
> > This provides a basis that would allow the conversion of all page cache
> > handling in the kernel and ultimately allow the removal of the PAGE_CACHE_*
> > constants.
> >
> > ...
> >
> > +/*
> > + * Functions that are currently setup for a fixed PAGE_SIZEd. The use of
> > + * these will allow the user of largere page sizes in the future.
> > + */
> > +static inline int mapping_order(struct address_space *a)
> > +{
> > + return 0;
> > +}
> > +
> > +static inline int page_cache_shift(struct address_space *a)
> > +{
> > + return PAGE_SHIFT;
> > +}
> > +
> > +static inline unsigned int page_cache_size(struct address_space *a)
> > +{
> > + return PAGE_SIZE;
> > +}
> > +
> > +static inline unsigned int page_cache_offset(struct address_space *a,
> > + loff_t pos)
> > +{
> > + return pos & ~PAGE_MASK;
> > +}
> > +
> > +static inline pgoff_t page_cache_index(struct address_space *a,
> > + loff_t pos)
> > +{
> > + return pos >> page_cache_shift(a);
> > +}
>
> These will of course all work OK as they are presently implemented.
>
> But you have callsites doing things like
>
> page_cache_size(page_mapping(page));
>
> which is a whole different thing. Once page_cache_size() is changed to
> look inside the address_space we need to handle races against truncation
> and we need to handle the address_space getting reclaimed, etc.
>
> So I think it would be misleading to merge these changes at present - they
> make it _look_ like we can have variable PAGE_CACHE_SIZE just by tweaking a
> bit of core code, but we in fact cannot do that without a careful review of
> all callsites and perhaps the addition of new locking and null-checking.
>
> Now, one possible way around this is to rework all these functions so they
> take only a page*, and to create (and assert) the requirement that the caller
> has locked the page. That's a little bit inefficient (additional calls to
> page_mapping()) but it does mean that we can now confidently change the
> implementation of these functions as you intend.
Hmmmm. Many of the places where these functions are called will have
the page locked and the mapping protected against truncate.
A quick pass through the patches indicates the changes to rmap.c,
migrate.c, alloc_page_buffers(), and drivers/block/rd.c seem to be
the only ones that are suspect. Almost everywhere else we either
use the inode->i_mapping or the page comes in locked (i.e. would
crash on struct inode * inode = page->mapping->host; at function entry
otherwise).
It seems the exposure here is not that great. I'm ambivalent, though; I
don'tmind what interface there is just so long as it cleans up this mess ;)
> And a coding nit: when you implement the out-of-line versions of these
> functions you're going to stick with VFS conventions and use the identifier
> `mapping' to identify the address_space*. So I think it would be better to
> also call in `mapping' in these inlined stubbed functions, rather than `a'.
> No?
Definitely an improvement.
Cheers,
Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [patch 01/19] Define functions for page cache handling
2007-12-03 22:10 ` Andrew Morton
2007-12-04 5:59 ` David Chinner
@ 2007-12-18 20:20 ` Christoph Lameter
1 sibling, 0 replies; 30+ messages in thread
From: Christoph Lameter @ 2007-12-18 20:20 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-fsdevel, linux-mm, hch, mel, wli, dgc, jens.axboe, pbadari,
maximlevitsky, fengguang.wu, wangswin, totty.lu, hugh, joern
On Mon, 3 Dec 2007, Andrew Morton wrote:
> These will of course all work OK as they are presently implemented.
>
> But you have callsites doing things like
>
> page_cache_size(page_mapping(page));
>
> which is a whole different thing. Once page_cache_size() is changed to
> look inside the address_space we need to handle races against truncation
> and we need to handle the address_space getting reclaimed, etc.
Right. The page must be locked for that to work right. I tried to avoid
the above construct as much as possible by relying on the inode mapping. I
can go over this again to make sure that there is nothing amiss after the
recent changes.
> So I think it would be misleading to merge these changes at present - they
> make it _look_ like we can have variable PAGE_CACHE_SIZE just by tweaking a
> bit of core code, but we in fact cannot do that without a careful review of
> all callsites and perhaps the addition of new locking and null-checking.
The mapping is generally available in some form if you cannot get it from
the page. In some cases I added a new parameter to functions to pass the
mapping so that we do not have to use page->mapping. I can recheck that
all is fine on that level.
> And a coding nit: when you implement the out-of-line versions of these
> functions you're going to stick with VFS conventions and use the identifier
> `mapping' to identify the address_space*. So I think it would be better to
> also call in `mapping' in these inlined stubbed functions, rather than `a'.
> No?
Ok. A trivial change. But a is shorter and made the
functions more concise.
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2007-12-18 20:20 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-30 17:34 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions V2 Christoph Lameter
2007-11-30 17:34 ` [patch 01/19] Define functions for page cache handling Christoph Lameter
2007-12-03 22:10 ` Andrew Morton
2007-12-04 5:59 ` David Chinner
2007-12-18 20:20 ` Christoph Lameter
2007-11-30 17:34 ` [patch 02/19] Use page_cache_xxx functions in mm/filemap.c Christoph Lameter
2007-11-30 17:34 ` [patch 03/19] Use page_cache_xxx in mm/page-writeback.c Christoph Lameter
2007-11-30 17:34 ` [patch 04/19] Use page_cache_xxx in mm/truncate.c Christoph Lameter
2007-11-30 17:34 ` [patch 05/19] Use page_cache_xxx in mm/rmap.c Christoph Lameter
2007-11-30 17:34 ` [patch 06/19] Use page_cache_xxx in mm/filemap_xip.c Christoph Lameter
2007-11-30 17:34 ` [patch 07/19] Use page_cache_xxx in mm/migrate.c Christoph Lameter
2007-12-04 5:45 ` David Chinner
2007-11-30 17:34 ` [patch 08/19] Use page_cache_xxx in fs/libfs.c Christoph Lameter
2007-11-30 17:34 ` [patch 09/19] Use page_cache_xxx in fs/sync Christoph Lameter
2007-11-30 17:34 ` [patch 10/19] Use page_cache_xxx in fs/buffer.c Christoph Lameter
2007-11-30 17:34 ` [patch 11/19] Use page_cache_xxx in mm/mpage.c Christoph Lameter
2007-11-30 17:35 ` [patch 12/19] Use page_cache_xxx in mm/fadvise.c Christoph Lameter
2007-11-30 17:35 ` [patch 13/19] Use page_cache_xxx in fs/splice.c Christoph Lameter
2007-11-30 17:35 ` [patch 14/19] Use page_cache_xxx in ext2 Christoph Lameter
2007-11-30 17:35 ` [patch 15/19] Use page_cache_xxx in fs/ext3 Christoph Lameter
2007-11-30 17:35 ` [patch 16/19] Use page_cache_xxx in fs/ext4 Christoph Lameter
2007-11-30 17:35 ` [patch 17/19] Use page_cache_xxx in fs/reiserfs Christoph Lameter
2007-11-30 17:35 ` [patch 18/19] Use page_cache_xxx for fs/xfs Christoph Lameter
2007-11-30 17:35 ` [patch 19/19] Use page_cache_xxx in drivers/block/rd.c Christoph Lameter
-- strict thread matches above, loose matches on Subject: below --
2007-11-29 1:10 [patch 00/19] Page cache: Replace PAGE_CACHE_xx with inline functions Christoph Lameter
2007-11-29 1:10 ` [patch 05/19] Use page_cache_xxx in mm/rmap.c Christoph Lameter
2007-11-29 3:19 ` David Chinner
2007-11-29 3:30 ` Christoph Lameter
2007-11-29 3:59 ` David Chinner
2007-11-29 4:09 ` Christoph Lameter
2007-11-29 4:11 ` David Chinner
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).