linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yehuda Sadeh <yehuda@hq.newdream.net>
To: linux-mm@kvack.org
Cc: Yehuda Sadeh <yehuda@hq.newdream.net>,
	linux-btrfs@vger.kernel.org, sage@newdream.net
Subject: [PATCH 1/1] mm: invalidate_mapping_pages checks boundaries when lock fails
Date: Thu, 18 Feb 2010 17:22:17 -0800	[thread overview]
Message-ID: <1266542537-5040-1-git-send-email-yehuda@hq.newdream.net> (raw)

Not sure that I'm not missing something obvious. When invalidate_mapping_pages
fails to lock the page, we continue to the next iteration, skipping the
next > end check. This can lead to a case where we invalidate a page that is
beyond the requested boundaries. Currently there are two callers that might be
affected, one is btrfs and the second one is the fadvice syscall.
Does that look right, or am I just missing something?

------

[PATCH 1/1] mm: invalidate_mapping_pages checks boundaries when lock fails

When we failed to lock the page, we continued to the next
iteration, skipping the next > end check. This might cause
throwing away a page that is beyond the requested boundaries.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
---
 mm/truncate.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/mm/truncate.c b/mm/truncate.c
index 450cebd..abb67d4 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -345,11 +345,12 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
 				next = index;
 			next++;
 			if (lock_failed)
-				continue;
+				goto unlocked;
 
 			ret += invalidate_inode_page(page);
 
 			unlock_page(page);
+unlocked:
 			if (next > end)
 				break;
 		}
-- 
1.5.6.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2010-02-19  1:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-19  1:22 Yehuda Sadeh [this message]
2010-02-19  3:58 ` Johannes Weiner

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=1266542537-5040-1-git-send-email-yehuda@hq.newdream.net \
    --to=yehuda@hq.newdream.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sage@newdream.net \
    /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