linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Ken Chen" <kenchen@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Badari Pulavarty <pbadari@us.ibm.com>
Cc: linux-mm@kvack.org
Subject: [patch] fix file position for hugetlbfs-read-support
Date: Tue, 2 Oct 2007 15:30:15 -0700	[thread overview]
Message-ID: <b040c32a0710021530o7a8ae28aybd65f8f4d677029@mail.gmail.com> (raw)

While working on a related area, I ran into a bug in hugetlbfs file
read support that is currently in -mm tree
(hugetlbfs-read-support.patch).

The problem is that hugetlb file position wasn't updated in
hugetlbfs_read(), so sys_read() will always read from same file
location.  A simple "cp" command that reads file until EOF will never
terminate.  Fix it by updating the ppos at the end of
hugetlbfs_read().

Signed-off-by: Ken Chen <kenchen@google.com>


diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 6dde2c3..8d9a631 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -228,9 +228,9 @@ hugetlbfs_read(struct file *filp
 	struct address_space *mapping = filp->f_mapping;
 	struct inode *inode = mapping->host;
 	unsigned long index = *ppos >> HPAGE_SHIFT;
+	unsigned long offset = *ppos & ~HPAGE_MASK;
 	unsigned long end_index;
 	loff_t isize;
-	unsigned long offset;
 	ssize_t retval = 0;

 	/* validate length */
@@ -241,7 +241,6 @@ hugetlbfs_read(struct file *filp
 	if (!isize)
 		goto out;

-	offset = *ppos & ~HPAGE_MASK;
 	end_index = (isize - 1) >> HPAGE_SHIFT;
 	for (;;) {
 		struct page *page;
@@ -290,6 +289,7 @@ hugetlbfs_read(struct file *filp
 		goto out;
 	}
 out:
+	*ppos = ((loff_t) index << HPAGE_SHIFT) + offset;
 	return retval;
 }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2007-10-02 22:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-02 22:30 Ken Chen [this message]
2007-10-02 22:37 ` Badari Pulavarty

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=b040c32a0710021530o7a8ae28aybd65f8f4d677029@mail.gmail.com \
    --to=kenchen@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=pbadari@us.ibm.com \
    /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