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

From: Omar Sandoval
Date: Mon Nov 17 2014 - 05:41:15 EST


Swapcache pages use ->private to store the swp_entry_t; overwriting it is sure
to cause insanity.

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

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)) {
--
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/