public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] add page_offset to mm.h
Date: Wed, 19 Jan 2005 12:21:57 +0100	[thread overview]
Message-ID: <20050119112157.GA10585@lst.de> (raw)

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)
 {

                 reply	other threads:[~2005-01-19 11:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050119112157.GA10585@lst.de \
    --to=hch@lst.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox