[RFC,3/6] btrfs: don't set ->private on swapcache pages
diff mbox

Message ID 320c5b270669c235c5513b5f5763a529abcf88dd.1416219974.git.osandov@osandov.com
State New, archived
Headers show

Commit Message

Omar Sandoval Nov. 17, 2014, 10:36 a.m. UTC
Swapcache pages use ->private to store the swp_entry_t; overwriting it is sure
to cause insanity.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
---
 fs/btrfs/extent_io.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch
diff mbox

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 9b67b37..54b2d00 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2824,6 +2824,7 @@  static int submit_extent_page(int rw, struct extent_io_tree *tree,
 static void attach_extent_buffer_page(struct extent_buffer *eb,
 				      struct page *page)
 {
+	BUG_ON(PageSwapCache(page));
 	if (!PagePrivate(page)) {
 		SetPagePrivate(page);
 		page_cache_get(page);
@@ -2835,6 +2836,7 @@  static void attach_extent_buffer_page(struct extent_buffer *eb,
 
 void set_page_extent_mapped(struct page *page)
 {
+	BUG_ON(PageSwapCache(page));
 	if (!PagePrivate(page)) {
 		SetPagePrivate(page);
 		page_cache_get(page);
@@ -2903,7 +2905,8 @@  static int __do_readpage(struct extent_io_tree *tree,
 	size_t blocksize = inode->i_sb->s_blocksize;
 	unsigned long this_bio_flag = *bio_flags & EXTENT_BIO_PARENT_LOCKED;
 
-	set_page_extent_mapped(page);
+	if (likely(!PageSwapCache(page)))
+		set_page_extent_mapped(page);
 
 	end = page_end;
 	if (!PageUptodate(page)) {