]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fadvise(POSIX_FADV_DONTNEED) fixups
authorAndrew Morton <akpm@osdl.org>
Fri, 12 Mar 2004 00:17:41 +0000 (16:17 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 12 Mar 2004 00:17:41 +0000 (16:17 -0800)
From: WU Fengguang <wfg@mail.ustc.edu.cn>

- In sys_fadvise64_64(): if the start and/or end offsets do not fall on
  page boundaries, preserve the partial pages.  The thinking here is that it
  is better to preserve needed memory than to not shoot down unneeded memory.

- In invalidate_mapping_pages(): we were invalidating an entire pagevec's
  worth of pages each time around, even if that went beyond the part of the
  file which the caller asked to be invalidated.  Fix that up.

mm/fadvise.c
mm/truncate.c

index d20bf2a93064ef8f2972c12313295fc4aab07286..63f71a712b4633c1655cc63c814e95f19daafdf0 100644 (file)
@@ -65,9 +65,8 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
        case POSIX_FADV_DONTNEED:
                if (!bdi_write_congested(mapping->backing_dev_info))
                        filemap_flush(mapping);
-               start_index = offset >> PAGE_CACHE_SHIFT;
-               end_index = (offset + len + PAGE_CACHE_SIZE - 1) >>
-                                               PAGE_CACHE_SHIFT;
+               start_index = (offset + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
+               end_index = ((offset + len) >> PAGE_CACHE_SHIFT) - 1;
                invalidate_mapping_pages(mapping, start_index, end_index);
                break;
        default:
index 33f7b51c3504c882a1c630cd34c02f0574a6029d..d94d6bf56d80a34bb4a0613f8e05b48304dba076 100644 (file)
@@ -219,6 +219,8 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
                        ret += invalidate_complete_page(mapping, page);
 unlock:
                        unlock_page(page);
+                       if (next > end)
+                               break;
                }
                pagevec_release(&pvec);
                cond_resched();