The patch titled
Fixes to hugetlbfs_read() support
has been added to the -mm tree. Its filename is
hugetlbfs-read-support-fix-2-fix.patch
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this
------------------------------------------------------
Subject: Fixes to hugetlbfs_read() support
From: Badari Pulavarty <[EMAIL PROTECTED]>
Various fixes to hugetlbfs_read() support
- handle HOLES correcty
- clean up weird looking loop condition reported by Ken Chen
- integrated "not updating file offset after read" fix by Ken Chen
- holding i_mutex to prevent any unwanted interactions with truncate
Signed-off-by: Badari Pulavarty <[EMAIL PROTECTED]>
Cc: William Irwin <[EMAIL PROTECTED]>
Cc: Nishanth Aravamudan <[EMAIL PROTECTED]>
Cc: Nick Piggin <[EMAIL PROTECTED]>
Acked-by: Ken Chen <[EMAIL PROTECTED]>
Cc: Adam Litke <[EMAIL PROTECTED]>
Cc: David Gibson <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---
diff -puN fs/hugetlbfs/inode.c~hugetlbfs-read-support-fix-2-fix
fs/hugetlbfs/inode.c
--- a/fs/hugetlbfs/inode.c~hugetlbfs-read-support-fix-2-fix
+++ a/fs/hugetlbfs/inode.c
@@ -228,11 +228,13 @@ static ssize_t hugetlbfs_read(struct fil
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;
+ mutex_lock(&inode->i_mutex);
+
/* validate length */
if (len == 0)
goto out;
@@ -241,7 +243,6 @@ static ssize_t hugetlbfs_read(struct fil
if (!isize)
goto out;
- offset = *ppos & ~HPAGE_MASK;
end_index = (isize - 1) >> HPAGE_SHIFT;
for (;;) {
struct page *page;
@@ -263,18 +264,23 @@ static ssize_t hugetlbfs_read(struct fil
page = find_get_page(mapping, index);
if (unlikely(page == NULL)) {
/*
- * We can't find the page in the cache - bail out ?
+ * We have a HOLE, zero out the user-buffer for the
+ * length of the hole or request.
*/
- goto out;
+ ret = len < nr ? len : nr;
+ if (clear_user(buf, ret))
+ ret = -EFAULT;
+ } else {
+ /*
+ * We have the page, copy it to user space buffer.
+ */
+ ret = hugetlbfs_read_actor(page, offset, buf, len, nr);
}
- /*
- * Ok, we have the page, copy it to user space buffer.
- */
- ret = hugetlbfs_read_actor(page, offset, buf, len, nr);
if (ret < 0) {
if (retval == 0)
retval = ret;
- page_cache_release(page);
+ if (page)
+ page_cache_release(page);
goto out;
}
@@ -284,12 +290,16 @@ static ssize_t hugetlbfs_read(struct fil
index += offset >> HPAGE_SHIFT;
offset &= ~HPAGE_MASK;
- page_cache_release(page);
- if (ret == nr && len)
- continue;
- goto out;
+ if (page)
+ page_cache_release(page);
+
+ /* short read or no more work */
+ if ((ret != nr) || (len == 0))
+ break;
}
out:
+ *ppos = ((loff_t) index << HPAGE_SHIFT) + offset;
+ mutex_unlock(&inode->i_mutex);
return retval;
}
_
Patches currently in -mm which might be from [EMAIL PROTECTED] are
ppc64-sparsemem_vmemmap-support-vmemmap-ppc64-convert-vmm_-macros-to-a-real-function-fix.patch
ext3-convert-to-new-aops.patch
ext4-convert-to-new-aops.patch
memory-unplug-v7-memory-hotplug-cleanup-fix.patch
hugetlb-move-update_and_free_page.patch
hugetlb-try-to-grow-hugetlb-pool-for-map_private-mappings.patch
hugetlb-try-to-grow-hugetlb-pool-for-map_shared-mappings.patch
hugetlb-add-hugetlb_dynamic_pool-sysctl.patch
hugetlbfs-read-support.patch
hugetlbfs-read-support-fix.patch
hugetlbfs-read-support-fix-2-fix.patch
ext2-statfs-improvement-for-block-and-inode-free-count.patch
aio-account-i-o-wait-time-properly.patch
fix-for-ext2-reservation.patch
sysctl-remove-the-binary-interface-for-aio-nr-aio-max-nr-acpi_video_flags.patch
mem-controller-gfp-mask-fix.patch
powerpc-add-scaled-time-accounting-speedup.patch
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html