aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-08-29 14:05:54 -0400
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-09-30 14:31:19 -0400
commitcf9a2ae8d49948f861b56e5333530e491a9da190 (patch)
tree21f0b0d781b3e60cc60464d39b6d95681201b37e /mm
parent4090959aee403817ff386415f9bc602c1a0882ef (diff)
[PATCH] BLOCK: Move functions out of buffer code [try #6]
Move some functions out of the buffering code that aren't strictly buffering specific. This is a precursor to being able to disable the block layer. (*) Moved some stuff out of fs/buffer.c: (*) The file sync and general sync stuff moved to fs/sync.c. (*) The superblock sync stuff moved to fs/super.c. (*) do_invalidatepage() moved to mm/truncate.c. (*) try_to_release_page() moved to mm/filemap.c. (*) Moved some related declarations between header files: (*) declarations for do_invalidatepage() and try_to_release_page() moved to linux/mm.h. (*) __set_page_dirty_buffers() moved to linux/buffer_head.h. Signed-Off-By: David Howells <dhowells@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'mm')
-rw-r--r--mm/filemap.c30
-rw-r--r--mm/page-writeback.c1
-rw-r--r--mm/truncate.c24
3 files changed, 55 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 3277f3b23524..d6846de08887 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2491,3 +2491,33 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
2491 } 2491 }
2492 return retval; 2492 return retval;
2493} 2493}
2494
2495/**
2496 * try_to_release_page() - release old fs-specific metadata on a page
2497 *
2498 * @page: the page which the kernel is trying to free
2499 * @gfp_mask: memory allocation flags (and I/O mode)
2500 *
2501 * The address_space is to try to release any data against the page
2502 * (presumably at page->private). If the release was successful, return `1'.
2503 * Otherwise return zero.
2504 *
2505 * The @gfp_mask argument specifies whether I/O may be performed to release
2506 * this page (__GFP_IO), and whether the call may block (__GFP_WAIT).
2507 *
2508 * NOTE: @gfp_mask may go away, and this function may become non-blocking.
2509 */
2510int try_to_release_page(struct page *page, gfp_t gfp_mask)
2511{
2512 struct address_space * const mapping = page->mapping;
2513
2514 BUG_ON(!PageLocked(page));
2515 if (PageWriteback(page))
2516 return 0;
2517
2518 if (mapping && mapping->a_ops->releasepage)
2519 return mapping->a_ops->releasepage(page, gfp_mask);
2520 return try_to_free_buffers(page);
2521}
2522
2523EXPORT_SYMBOL(try_to_release_page);
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 488b7088557c..9fdcc7903956 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -30,6 +30,7 @@
30#include <linux/sysctl.h> 30#include <linux/sysctl.h>
31#include <linux/cpu.h> 31#include <linux/cpu.h>
32#include <linux/syscalls.h> 32#include <linux/syscalls.h>
33#include <linux/buffer_head.h>
33 34
34/* 35/*
35 * The maximum number of pages to writeout in a single bdflush/kupdate 36 * The maximum number of pages to writeout in a single bdflush/kupdate
diff --git a/mm/truncate.c b/mm/truncate.c
index a654928323dc..cd3e34b816db 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -17,6 +17,30 @@
17 do_invalidatepage */ 17 do_invalidatepage */
18 18
19 19
20/**
21 * do_invalidatepage - invalidate part of all of a page
22 * @page: the page which is affected
23 * @offset: the index of the truncation point
24 *
25 * do_invalidatepage() is called when all or part of the page has become
26 * invalidated by a truncate operation.
27 *
28 * do_invalidatepage() does not have to release all buffers, but it must
29 * ensure that no dirty buffer is left outside @offset and that no I/O
30 * is underway against any of the blocks which are outside the truncation
31 * point. Because the caller is about to free (and possibly reuse) those
32 * blocks on-disk.
33 */
34void do_invalidatepage(struct page *page, unsigned long offset)
35{
36 void (*invalidatepage)(struct page *, unsigned long);
37 invalidatepage = page->mapping->a_ops->invalidatepage;
38 if (!invalidatepage)
39 invalidatepage = block_invalidatepage;
40 if (invalidatepage)
41 (*invalidatepage)(page, offset);
42}
43
20static inline void truncate_partial_page(struct page *page, unsigned partial) 44static inline void truncate_partial_page(struct page *page, unsigned partial)
21{ 45{
22 memclear_highpage_flush(page, partial, PAGE_CACHE_SIZE-partial); 46 memclear_highpage_flush(page, partial, PAGE_CACHE_SIZE-partial);