LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, richard@nod.at
Subject: [PATCH 14/15] hostfs: Use page_offset()
Date: Mon, 16 Mar 2015 12:41:18 +0100	[thread overview]
Message-ID: <1426506079-26183-15-git-send-email-richard@nod.at> (raw)
In-Reply-To: <1426506079-26183-1-git-send-email-richard@nod.at>

The kernel offers a helper function for that, use it.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/hostfs/hostfs_kern.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index f154747..f82f98a5 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -410,7 +410,7 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
 	struct address_space *mapping = page->mapping;
 	struct inode *inode = mapping->host;
 	char *buffer;
-	unsigned long long base;
+	loff_t base = page_offset(page);
 	int count = PAGE_CACHE_SIZE;
 	int end_index = inode->i_size >> PAGE_CACHE_SHIFT;
 	int err;
@@ -419,7 +419,6 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
 		count = inode->i_size & (PAGE_CACHE_SIZE-1);
 
 	buffer = kmap(page);
-	base = ((unsigned long long) page->index) << PAGE_CACHE_SHIFT;
 
 	err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count);
 	if (err != count) {
@@ -444,10 +443,9 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
 static int hostfs_readpage(struct file *file, struct page *page)
 {
 	char *buffer;
-	long long start;
+	loff_t start = page_offset(page);
 	int bytes_read, ret = 0;
 
-	start = (long long) page->index << PAGE_CACHE_SHIFT;
 	buffer = kmap(page);
 	bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
 			PAGE_CACHE_SIZE);
-- 
2.3.2


  parent reply	other threads:[~2015-03-16 11:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 11:41 Hostfs updates Richard Weinberger
2015-03-16 11:41 ` [PATCH 01/15] hostfs: hostfs_file_open: Switch to data locking model Richard Weinberger
2015-03-16 11:41 ` [PATCH 02/15] hostfs: hostfs_file_open: Fix a fd leak in hostfs_file_open Richard Weinberger
2015-03-16 11:41 ` [PATCH 03/15] hostfs: Allow fsync on directories Richard Weinberger
2015-03-16 11:41 ` [PATCH 04/15] hostfs: Handle bogus st.mode Richard Weinberger
2015-03-16 11:41 ` [PATCH 05/15] hostfs: Make hostfs_readpage more readable Richard Weinberger
2015-03-16 11:41 ` [PATCH 06/15] hostfs: Add a BUG_ON to detect behavior changes of dentry_path_raw() Richard Weinberger
2015-03-16 11:41 ` [PATCH 07/15] hostfs: Remove open coded strcpy() Richard Weinberger
2015-03-16 12:03   ` [uml-devel] " Geert Uytterhoeven
2015-03-16 12:18     ` Richard Weinberger
2015-03-16 12:44       ` Geert Uytterhoeven
2015-03-16 11:41 ` [PATCH 08/15] hostfs: Use __getname() in follow_link Richard Weinberger
2015-03-16 11:41 ` [PATCH 09/15] hostfs: Report append flag in ->show_options() Richard Weinberger
2015-03-16 11:41 ` [PATCH 10/15] hostfs: Remove superfluous test in hostfs_open() Richard Weinberger
2015-03-16 11:41 ` [PATCH 11/15] hostfs: hostfs_open: Reset open flags upon each retry Richard Weinberger
2015-03-16 11:41 ` [PATCH 12/15] hostfs: Remove superfluous initializations in hostfs_open() Richard Weinberger
2015-03-16 11:41 ` [PATCH 13/15] hostfs: Set page flags in hostfs_readpage() correctly Richard Weinberger
2015-03-16 11:41 ` Richard Weinberger [this message]
2015-03-16 11:41 ` [PATCH 15/15] hostfs: No need to box and later unbox the file mode Richard Weinberger

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=1426506079-26183-15-git-send-email-richard@nod.at \
    --to=richard@nod.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    --subject='Re: [PATCH 14/15] hostfs: Use page_offset()' \
    /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

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