truncate.c (b73077eb03f510a84b102fb97640e595a958403c) truncate.c (c515e1fd361c2a08a9c2eb139396ec30a4f477dc)
1/*
2 * mm/truncate.c - code for taking down pages from address_spaces
3 *
4 * Copyright (C) 2002, Linus Torvalds
5 *
6 * 10Sep2002 Andrew Morton
7 * Initial version.
8 */

--- 5 unchanged lines hidden (view full) ---

14#include <linux/swap.h>
15#include <linux/module.h>
16#include <linux/pagemap.h>
17#include <linux/highmem.h>
18#include <linux/pagevec.h>
19#include <linux/task_io_accounting_ops.h>
20#include <linux/buffer_head.h> /* grr. try_to_release_page,
21 do_invalidatepage */
1/*
2 * mm/truncate.c - code for taking down pages from address_spaces
3 *
4 * Copyright (C) 2002, Linus Torvalds
5 *
6 * 10Sep2002 Andrew Morton
7 * Initial version.
8 */

--- 5 unchanged lines hidden (view full) ---

14#include <linux/swap.h>
15#include <linux/module.h>
16#include <linux/pagemap.h>
17#include <linux/highmem.h>
18#include <linux/pagevec.h>
19#include <linux/task_io_accounting_ops.h>
20#include <linux/buffer_head.h> /* grr. try_to_release_page,
21 do_invalidatepage */
22#include <linux/cleancache.h>
22#include "internal.h"
23
24
25/**
26 * do_invalidatepage - invalidate part or all of a page
27 * @page: the page which is affected
28 * @offset: the index of the truncation point
29 *

--- 16 unchanged lines hidden (view full) ---

46#endif
47 if (invalidatepage)
48 (*invalidatepage)(page, offset);
49}
50
51static inline void truncate_partial_page(struct page *page, unsigned partial)
52{
53 zero_user_segment(page, partial, PAGE_CACHE_SIZE);
23#include "internal.h"
24
25
26/**
27 * do_invalidatepage - invalidate part or all of a page
28 * @page: the page which is affected
29 * @offset: the index of the truncation point
30 *

--- 16 unchanged lines hidden (view full) ---

47#endif
48 if (invalidatepage)
49 (*invalidatepage)(page, offset);
50}
51
52static inline void truncate_partial_page(struct page *page, unsigned partial)
53{
54 zero_user_segment(page, partial, PAGE_CACHE_SIZE);
55 cleancache_flush_page(page->mapping, page);
54 if (page_has_private(page))
55 do_invalidatepage(page, partial);
56}
57
58/*
59 * This cancels just the dirty bit on the kernel page itself, it
60 * does NOT actually remove dirty bits on any mmap's that may be
61 * around. It also leaves the page tagged dirty, so any sync

--- 147 unchanged lines hidden (view full) ---

209{
210 const pgoff_t start = (lstart + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
211 pgoff_t end;
212 const unsigned partial = lstart & (PAGE_CACHE_SIZE - 1);
213 struct pagevec pvec;
214 pgoff_t next;
215 int i;
216
56 if (page_has_private(page))
57 do_invalidatepage(page, partial);
58}
59
60/*
61 * This cancels just the dirty bit on the kernel page itself, it
62 * does NOT actually remove dirty bits on any mmap's that may be
63 * around. It also leaves the page tagged dirty, so any sync

--- 147 unchanged lines hidden (view full) ---

211{
212 const pgoff_t start = (lstart + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
213 pgoff_t end;
214 const unsigned partial = lstart & (PAGE_CACHE_SIZE - 1);
215 struct pagevec pvec;
216 pgoff_t next;
217 int i;
218
219 cleancache_flush_inode(mapping);
217 if (mapping->nrpages == 0)
218 return;
219
220 BUG_ON((lend & (PAGE_CACHE_SIZE - 1)) != (PAGE_CACHE_SIZE - 1));
221 end = (lend >> PAGE_CACHE_SHIFT);
222
223 pagevec_init(&pvec, 0);
224 next = start;

--- 61 unchanged lines hidden (view full) ---

286 if (page->index > next)
287 next = page->index;
288 next++;
289 unlock_page(page);
290 }
291 pagevec_release(&pvec);
292 mem_cgroup_uncharge_end();
293 }
220 if (mapping->nrpages == 0)
221 return;
222
223 BUG_ON((lend & (PAGE_CACHE_SIZE - 1)) != (PAGE_CACHE_SIZE - 1));
224 end = (lend >> PAGE_CACHE_SHIFT);
225
226 pagevec_init(&pvec, 0);
227 next = start;

--- 61 unchanged lines hidden (view full) ---

289 if (page->index > next)
290 next = page->index;
291 next++;
292 unlock_page(page);
293 }
294 pagevec_release(&pvec);
295 mem_cgroup_uncharge_end();
296 }
297 cleancache_flush_inode(mapping);
294}
295EXPORT_SYMBOL(truncate_inode_pages_range);
296
297/**
298 * truncate_inode_pages - truncate *all* the pages from an offset
299 * @mapping: mapping to truncate
300 * @lstart: offset from which to truncate
301 *

--- 133 unchanged lines hidden (view full) ---

435 struct pagevec pvec;
436 pgoff_t next;
437 int i;
438 int ret = 0;
439 int ret2 = 0;
440 int did_range_unmap = 0;
441 int wrapped = 0;
442
298}
299EXPORT_SYMBOL(truncate_inode_pages_range);
300
301/**
302 * truncate_inode_pages - truncate *all* the pages from an offset
303 * @mapping: mapping to truncate
304 * @lstart: offset from which to truncate
305 *

--- 133 unchanged lines hidden (view full) ---

439 struct pagevec pvec;
440 pgoff_t next;
441 int i;
442 int ret = 0;
443 int ret2 = 0;
444 int did_range_unmap = 0;
445 int wrapped = 0;
446
447 cleancache_flush_inode(mapping);
443 pagevec_init(&pvec, 0);
444 next = start;
445 while (next <= end && !wrapped &&
446 pagevec_lookup(&pvec, mapping, next,
447 min(end - next, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) {
448 mem_cgroup_uncharge_start();
449 for (i = 0; i < pagevec_count(&pvec); i++) {
450 struct page *page = pvec.pages[i];

--- 42 unchanged lines hidden (view full) ---

493 if (ret2 < 0)
494 ret = ret2;
495 unlock_page(page);
496 }
497 pagevec_release(&pvec);
498 mem_cgroup_uncharge_end();
499 cond_resched();
500 }
448 pagevec_init(&pvec, 0);
449 next = start;
450 while (next <= end && !wrapped &&
451 pagevec_lookup(&pvec, mapping, next,
452 min(end - next, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) {
453 mem_cgroup_uncharge_start();
454 for (i = 0; i < pagevec_count(&pvec); i++) {
455 struct page *page = pvec.pages[i];

--- 42 unchanged lines hidden (view full) ---

498 if (ret2 < 0)
499 ret = ret2;
500 unlock_page(page);
501 }
502 pagevec_release(&pvec);
503 mem_cgroup_uncharge_end();
504 cond_resched();
505 }
506 cleancache_flush_inode(mapping);
501 return ret;
502}
503EXPORT_SYMBOL_GPL(invalidate_inode_pages2_range);
504
505/**
506 * invalidate_inode_pages2 - remove all pages from an address_space
507 * @mapping: the address_space
508 *

--- 91 unchanged lines hidden ---
507 return ret;
508}
509EXPORT_SYMBOL_GPL(invalidate_inode_pages2_range);
510
511/**
512 * invalidate_inode_pages2 - remove all pages from an address_space
513 * @mapping: the address_space
514 *

--- 91 unchanged lines hidden ---