linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: linux-btrfs@vger.kernel.org
Cc: Mel Gorman <mgorman@suse.de>,
	linux-kernel@vger.kernel.org, <linux-fsdevel@vger.kernel.org>,
	Omar Sandoval <osandov@osandov.com>
Subject: [RFC PATCH 3/6] btrfs: don't set ->private on swapcache pages
Date: Mon, 17 Nov 2014 02:36:56 -0800	[thread overview]
Message-ID: <320c5b270669c235c5513b5f5763a529abcf88dd.1416219974.git.osandov@osandov.com> (raw)
In-Reply-To: <cover.1416219974.git.osandov@osandov.com>
In-Reply-To: <cover.1416219974.git.osandov@osandov.com>

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(-)

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


  parent reply	other threads:[~2014-11-17 10:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-17 10:36 [RFC PATCH 0/6] btrfs: implement swap file support Omar Sandoval
2014-11-17 10:36 ` [RFC PATCH 1/6] btrfs: convert uses of ->mapping and ->index to wrappers Omar Sandoval
2014-11-17 10:36 ` [RFC PATCH 2/6] btrfs: don't allow -C or +c chattrs on a swap file Omar Sandoval
2014-11-17 10:36 ` Omar Sandoval [this message]
2014-11-17 10:36 ` [RFC PATCH 4/6] btrfs: don't check the cleancache for swapcache pages Omar Sandoval
2014-11-17 10:36 ` [RFC PATCH 5/6] btrfs: don't mark extents used for swap as up to date Omar Sandoval
2014-11-17 10:36 ` [RFC PATCH 6/6] btrfs: enable swap file support Omar Sandoval
2014-11-17 15:48 ` [RFC PATCH 0/6] btrfs: implement " Christoph Hellwig
2014-11-19  7:22   ` Omar Sandoval
2014-11-21 10:06     ` Christoph Hellwig
2014-11-21 10:12       ` Omar Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=320c5b270669c235c5513b5f5763a529abcf88dd.1416219974.git.osandov@osandov.com \
    --to=osandov@osandov.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).