Skip to content

Commit 8a9d2e1

Browse files
committed
Merge tag 'afs-cachefiles-fixes-20210323' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
Pull cachefiles and afs fixes from David Howells: "Fixes from Matthew Wilcox for page waiting-related issues in cachefiles and afs as extracted from his folio series[1]: - In cachefiles, remove the use of the wait_bit_key struct to access something that's actually in wait_page_key format. The proper struct is now available in the header, so that should be used instead. - Add a proper wait function for waiting killably on the page writeback flag. This includes a recent bugfix[2] that's not in the afs code. - In afs, use the function added in (2) rather than using wait_on_page_bit_killable() which doesn't provide the aforementioned bugfix" Link: https://lore.kernel.org/r/20210320054104.1300774-1-willy@infradead.org[1] Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c2407cf7d22d0c0d94cf20342b3b8f06f1d904e7 [2] Link: https://lore.kernel.org/r/20210323120829.GC1719932@casper.infradead.org/ # v1 * tag 'afs-cachefiles-fixes-20210323' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: afs: Use wait_on_page_writeback_killable mm/writeback: Add wait_on_page_writeback_killable fs/cachefiles: Remove wait_bit_key layout dependency
2 parents bf1c82a + 75b6979 commit 8a9d2e1

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

fs/afs/write.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,7 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
851851
fscache_wait_on_page_write(vnode->cache, vmf->page);
852852
#endif
853853

854-
if (PageWriteback(vmf->page) &&
855-
wait_on_page_bit_killable(vmf->page, PG_writeback) < 0)
854+
if (wait_on_page_writeback_killable(vmf->page))
856855
return VM_FAULT_RETRY;
857856

858857
if (lock_page_killable(vmf->page) < 0)

fs/cachefiles/rdwr.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ static int cachefiles_read_waiter(wait_queue_entry_t *wait, unsigned mode,
2424
container_of(wait, struct cachefiles_one_read, monitor);
2525
struct cachefiles_object *object;
2626
struct fscache_retrieval *op = monitor->op;
27-
struct wait_bit_key *key = _key;
27+
struct wait_page_key *key = _key;
2828
struct page *page = wait->private;
2929

3030
ASSERT(key);
3131

3232
_enter("{%lu},%u,%d,{%p,%u}",
3333
monitor->netfs_page->index, mode, sync,
34-
key->flags, key->bit_nr);
34+
key->page, key->bit_nr);
3535

36-
if (key->flags != &page->flags ||
37-
key->bit_nr != PG_locked)
36+
if (key->page != page || key->bit_nr != PG_locked)
3837
return 0;
3938

4039
_debug("--- monitor %p %lx ---", page, page->flags);

include/linux/pagemap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
559559
return pgoff;
560560
}
561561

562-
/* This has the same layout as wait_bit_key - see fs/cachefiles/rdwr.c */
563562
struct wait_page_key {
564563
struct page *page;
565564
int bit_nr;
@@ -683,6 +682,7 @@ static inline int wait_on_page_locked_killable(struct page *page)
683682

684683
int put_and_wait_on_page_locked(struct page *page, int state);
685684
void wait_on_page_writeback(struct page *page);
685+
int wait_on_page_writeback_killable(struct page *page);
686686
extern void end_page_writeback(struct page *page);
687687
void wait_for_stable_page(struct page *page);
688688

mm/page-writeback.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,22 @@ void wait_on_page_writeback(struct page *page)
28332833
}
28342834
EXPORT_SYMBOL_GPL(wait_on_page_writeback);
28352835

2836+
/*
2837+
* Wait for a page to complete writeback. Returns -EINTR if we get a
2838+
* fatal signal while waiting.
2839+
*/
2840+
int wait_on_page_writeback_killable(struct page *page)
2841+
{
2842+
while (PageWriteback(page)) {
2843+
trace_wait_on_page_writeback(page, page_mapping(page));
2844+
if (wait_on_page_bit_killable(page, PG_writeback))
2845+
return -EINTR;
2846+
}
2847+
2848+
return 0;
2849+
}
2850+
EXPORT_SYMBOL_GPL(wait_on_page_writeback_killable);
2851+
28362852
/**
28372853
* wait_for_stable_page() - wait for writeback to finish, if necessary.
28382854
* @page: The page to wait on.

0 commit comments

Comments
 (0)