Skip to content

Commit

Permalink
mm: migrate: make buffer_migrate_page_norefs() actually succeed
Browse files Browse the repository at this point in the history
Currently, buffer_migrate_page_norefs() was constantly failing because
buffer_migrate_lock_buffers() grabbed reference on each buffer.  In
fact, there's no reason for buffer_migrate_lock_buffers() to grab any
buffer references as the page is locked during all our operation and
thus nobody can reclaim buffers from the page.

So remove grabbing of buffer references which also makes
buffer_migrate_page_norefs() succeed.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 89cb088 "mm: migrate: provide buffer_migrate_page_norefs()"
Signed-off-by: Jan Kara <[email protected]>
Cc: Sergey Senozhatsky <[email protected]>
Cc: Pavel Machek <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Zi Yan <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jankara authored and torvalds committed Feb 1, 2019
1 parent 8fb335e commit 80409c6
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ static bool buffer_migrate_lock_buffers(struct buffer_head *head,
/* Simple case, sync compaction */
if (mode != MIGRATE_ASYNC) {
do {
get_bh(bh);
lock_buffer(bh);
bh = bh->b_this_page;

Expand All @@ -720,18 +719,15 @@ static bool buffer_migrate_lock_buffers(struct buffer_head *head,

/* async case, we cannot block on lock_buffer so use trylock_buffer */
do {
get_bh(bh);
if (!trylock_buffer(bh)) {
/*
* We failed to lock the buffer and cannot stall in
* async migration. Release the taken locks
*/
struct buffer_head *failed_bh = bh;
put_bh(failed_bh);
bh = head;
while (bh != failed_bh) {
unlock_buffer(bh);
put_bh(bh);
bh = bh->b_this_page;
}
return false;
Expand Down Expand Up @@ -818,7 +814,6 @@ static int __buffer_migrate_page(struct address_space *mapping,
bh = head;
do {
unlock_buffer(bh);
put_bh(bh);
bh = bh->b_this_page;

} while (bh != head);
Expand Down

0 comments on commit 80409c6

Please sign in to comment.