aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fscache/page.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-09-22 20:52:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-09-22 20:52:16 -0400
commite2519c2c85c376666c96705239c5c7d1aef14b2d (patch)
tree7faec5ebe379aabe81d98a6f9f71d73449776793 /fs/fscache/page.c
parentb0e2a55c6536f255ebe80bc84c3f565c2a8f2a9d (diff)
parente2cf1f1cc7636bd860e47cd0ad6194da8975f8b5 (diff)
Merge tag 'fscache-fixes-20140917' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
Pull fs-cache fixes from David Howells: - Put a timeout in releasepage() to deal with a recursive hang between the memory allocator, writeback, ext4 and fscache under memory pressure. - Fix a pair of refcount bugs in the fscache error handling. - Remove a couple of unused pagevecs. - The cachefiles requirement that the base directory support rename should permit rename2 as an alternative - otherwise certain filesystems cannot now be used as backing stores (such as ext4). * tag 'fscache-fixes-20140917' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: CacheFiles: Handle rename2 cachefiles: remove two unused pagevecs. FS-Cache: refcount becomes corrupt under vma pressure. FS-Cache: Reduce cookie ref count if submit fails. FS-Cache: Timeout for releasepage()
Diffstat (limited to 'fs/fscache/page.c')
-rw-r--r--fs/fscache/page.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index 85332b9d19d1..de33b3fccca6 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -44,6 +44,19 @@ void __fscache_wait_on_page_write(struct fscache_cookie *cookie, struct page *pa
44EXPORT_SYMBOL(__fscache_wait_on_page_write); 44EXPORT_SYMBOL(__fscache_wait_on_page_write);
45 45
46/* 46/*
47 * wait for a page to finish being written to the cache. Put a timeout here
48 * since we might be called recursively via parent fs.
49 */
50static
51bool release_page_wait_timeout(struct fscache_cookie *cookie, struct page *page)
52{
53 wait_queue_head_t *wq = bit_waitqueue(&cookie->flags, 0);
54
55 return wait_event_timeout(*wq, !__fscache_check_page_write(cookie, page),
56 HZ);
57}
58
59/*
47 * decide whether a page can be released, possibly by cancelling a store to it 60 * decide whether a page can be released, possibly by cancelling a store to it
48 * - we're allowed to sleep if __GFP_WAIT is flagged 61 * - we're allowed to sleep if __GFP_WAIT is flagged
49 */ 62 */
@@ -115,7 +128,10 @@ page_busy:
115 } 128 }
116 129
117 fscache_stat(&fscache_n_store_vmscan_wait); 130 fscache_stat(&fscache_n_store_vmscan_wait);
118 __fscache_wait_on_page_write(cookie, page); 131 if (!release_page_wait_timeout(cookie, page))
132 _debug("fscache writeout timeout page: %p{%lx}",
133 page, page->index);
134
119 gfp &= ~__GFP_WAIT; 135 gfp &= ~__GFP_WAIT;
120 goto try_again; 136 goto try_again;
121} 137}
@@ -182,7 +198,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
182{ 198{
183 struct fscache_operation *op; 199 struct fscache_operation *op;
184 struct fscache_object *object; 200 struct fscache_object *object;
185 bool wake_cookie; 201 bool wake_cookie = false;
186 202
187 _enter("%p", cookie); 203 _enter("%p", cookie);
188 204
@@ -212,15 +228,16 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
212 228
213 __fscache_use_cookie(cookie); 229 __fscache_use_cookie(cookie);
214 if (fscache_submit_exclusive_op(object, op) < 0) 230 if (fscache_submit_exclusive_op(object, op) < 0)
215 goto nobufs; 231 goto nobufs_dec;
216 spin_unlock(&cookie->lock); 232 spin_unlock(&cookie->lock);
217 fscache_stat(&fscache_n_attr_changed_ok); 233 fscache_stat(&fscache_n_attr_changed_ok);
218 fscache_put_operation(op); 234 fscache_put_operation(op);
219 _leave(" = 0"); 235 _leave(" = 0");
220 return 0; 236 return 0;
221 237
222nobufs: 238nobufs_dec:
223 wake_cookie = __fscache_unuse_cookie(cookie); 239 wake_cookie = __fscache_unuse_cookie(cookie);
240nobufs:
224 spin_unlock(&cookie->lock); 241 spin_unlock(&cookie->lock);
225 kfree(op); 242 kfree(op);
226 if (wake_cookie) 243 if (wake_cookie)