[PATCH] add page_offset to mm.h

From: Christoph Hellwig
Date: Wed Jan 19 2005 - 06:23:22 EST


To convert page->index to a byte index you need to cast it to loff_t
first so it's a 64bit value. There have been quite a few places that
got it wrong in the kernel. To make it easier a nice little helper
would be nice, and in fact the NFS code already has it. Let's move it
to pagemap.h so everyone can use it.


--- 1.92/include/linux/nfs_fs.h 2005-01-04 01:00:00 +01:00
+++ edited/include/linux/nfs_fs.h 2005-01-19 11:40:42 +01:00
@@ -254,12 +254,6 @@
return NFS_FLAGS(inode) & NFS_INO_ADVISE_RDPLUS;
}

-static inline
-loff_t page_offset(struct page *page)
-{
- return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
-}
-
/**
* nfs_save_change_attribute - Returns the inode attribute change cookie
* @inode - pointer to inode
--- 1.44/include/linux/pagemap.h 2004-08-27 08:31:38 +02:00
+++ edited/include/linux/pagemap.h 2005-01-19 11:42:59 +01:00
@@ -143,6 +143,14 @@
return ret;
}

+/*
+ * Return byte-offset into filesystem object for page.
+ */
+static inline loff_t page_offset(struct page *page)
+{
+ return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
+}
+
static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
unsigned long address)
{
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/