diff options
author | Seth Jennings <sjenning@linux.vnet.ibm.com> | 2013-04-29 18:08:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 18:54:38 -0400 |
commit | 2f772e6cadf8ad8fca38927b17e6be028be669f5 (patch) | |
tree | 5eac4cfd72c6e8e9b4d48ad7463cdf1a8b97f7b4 /mm | |
parent | e8420a8ece80b3fe810415ecf061d54ca7fab266 (diff) |
mm: break up swap_writepage() for frontswap backends
swap_writepage() is currently where frontswap hooks into the swap write
path to capture pages with the frontswap_store() function. However, if
a frontswap backend wants to "resume" the writeback of a page to the
swap device, it can't call swap_writepage() as the page will simply
reenter the backend.
This patch separates swap_writepage() into a top and bottom half, the
bottom half named __swap_writepage() to allow a frontswap backend, like
zswap, to resume writeback beyond the frontswap_store() hook.
__add_to_swap_cache() is also made non-static so that the page for which
writeback is to be resumed can be added to the swap cache.
Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Bob Liu <bob.liu@oracle.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/page_io.c | 14 | ||||
-rw-r--r-- | mm/swap_state.c | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/mm/page_io.c b/mm/page_io.c index 78eee32ee486..8e6bcf176cfb 100644 --- a/mm/page_io.c +++ b/mm/page_io.c | |||
@@ -185,9 +185,7 @@ bad_bmap: | |||
185 | */ | 185 | */ |
186 | int swap_writepage(struct page *page, struct writeback_control *wbc) | 186 | int swap_writepage(struct page *page, struct writeback_control *wbc) |
187 | { | 187 | { |
188 | struct bio *bio; | 188 | int ret = 0; |
189 | int ret = 0, rw = WRITE; | ||
190 | struct swap_info_struct *sis = page_swap_info(page); | ||
191 | 189 | ||
192 | if (try_to_free_swap(page)) { | 190 | if (try_to_free_swap(page)) { |
193 | unlock_page(page); | 191 | unlock_page(page); |
@@ -199,6 +197,16 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) | |||
199 | end_page_writeback(page); | 197 | end_page_writeback(page); |
200 | goto out; | 198 | goto out; |
201 | } | 199 | } |
200 | ret = __swap_writepage(page, wbc); | ||
201 | out: | ||
202 | return ret; | ||
203 | } | ||
204 | |||
205 | int __swap_writepage(struct page *page, struct writeback_control *wbc) | ||
206 | { | ||
207 | struct bio *bio; | ||
208 | int ret = 0, rw = WRITE; | ||
209 | struct swap_info_struct *sis = page_swap_info(page); | ||
202 | 210 | ||
203 | if (sis->flags & SWP_FILE) { | 211 | if (sis->flags & SWP_FILE) { |
204 | struct kiocb kiocb; | 212 | struct kiocb kiocb; |
diff --git a/mm/swap_state.c b/mm/swap_state.c index 7efcf1525921..fe43fd5578cf 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c | |||
@@ -78,7 +78,7 @@ void show_swap_cache_info(void) | |||
78 | * __add_to_swap_cache resembles add_to_page_cache_locked on swapper_space, | 78 | * __add_to_swap_cache resembles add_to_page_cache_locked on swapper_space, |
79 | * but sets SwapCache flag and private instead of mapping and index. | 79 | * but sets SwapCache flag and private instead of mapping and index. |
80 | */ | 80 | */ |
81 | static int __add_to_swap_cache(struct page *page, swp_entry_t entry) | 81 | int __add_to_swap_cache(struct page *page, swp_entry_t entry) |
82 | { | 82 | { |
83 | int error; | 83 | int error; |
84 | struct address_space *address_space; | 84 | struct address_space *address_space; |