Re: [PATCH] cachefiles deadlock with 3.10 + fscache-20130702

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Howells <dhowells@xxxxxxxxxx> wrote:

> It seems that your mail client replaced all the tabs in the patch with
> multiple 0xA0 characters plus a space.

Here's a cleaned up patch that applies.

David
---
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
index 25e745b8eb1b..ebeaaf7ac6f0 100644
--- a/fs/cachefiles/rdwr.c
+++ b/fs/cachefiles/rdwr.c
@@ -916,6 +916,19 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
 	} else {
 		ret = -EIO;
 		if (file->f_op->write) {
+			struct address_space *mapping = file->f_mapping;
+			gfp_t gfp_mask = mapping_gfp_mask(mapping);
+			gfp_t gfp_mask_orig = gfp_mask;
+
+			/*
+			 * Clear __GFP_FS to avoid potential deadlock
+			 * during memory reclaim.
+			 */
+			if (gfp_mask & __GFP_FS) {
+				gfp_mask &= ~__GFP_FS;
+				mapping_set_gfp_mask(mapping, gfp_mask);
+			}
+
 			pos = (loff_t) page->index << PAGE_SHIFT;
 
 			/* we mustn't write more data than we have, so we have
@@ -943,6 +956,9 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
 			file_end_write(file);
 			if (ret != len)
 				ret = -EIO;
+
+			if (gfp_mask != gfp_mask_orig)
+				mapping_set_gfp_mask(gfp_mask_orig);
 		}
 		fput(file);
 	}

--
Linux-cachefs mailing list
Linux-cachefs@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/linux-cachefs




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]
  Powered by Linux