afs: Don't wait for page writeback with the page lock held
authorDavid Howells <dhowells@redhat.com>
Thu, 16 Mar 2017 16:27:49 +0000 (16:27 +0000)
committerDavid Howells <dhowells@redhat.com>
Thu, 16 Mar 2017 16:29:30 +0000 (16:29 +0000)
Drop the page lock before waiting for page writeback.

Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/write.c

index e5f150bccfb5d1ccdaeb11f172c26e8f0bd29130..2d2fccd5044bcd9b02127246824c1221ec502484 100644 (file)
@@ -518,17 +518,16 @@ static int afs_writepages_region(struct address_space *mapping,
                 */
                lock_page(page);
 
-               if (page->mapping != mapping) {
+               if (page->mapping != mapping || !PageDirty(page)) {
                        unlock_page(page);
                        put_page(page);
                        continue;
                }
 
-               if (wbc->sync_mode != WB_SYNC_NONE)
-                       wait_on_page_writeback(page);
-
-               if (PageWriteback(page) || !PageDirty(page)) {
+               if (PageWriteback(page)) {
                        unlock_page(page);
+                       if (wbc->sync_mode != WB_SYNC_NONE)
+                               wait_on_page_writeback(page);
                        put_page(page);
                        continue;
                }