Skip to content

Commit 84ade7c

Browse files
jankaratorvalds
authored andcommitted
mm: migrate: move migrate_page_lock_buffers()
buffer_migrate_page() is the only caller of migrate_page_lock_buffers() move it close to it and also drop the now unused stub for !CONFIG_BLOCK. Link: http://lkml.kernel.org/r/20181211172143.7358-4-jack@suse.cz Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Mel Gorman <mgorman@suse.de> Cc: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cc4f11e commit 84ade7c

File tree

1 file changed

+42
-50
lines changed

1 file changed

+42
-50
lines changed

mm/migrate.c

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -374,56 +374,6 @@ void pmd_migration_entry_wait(struct mm_struct *mm, pmd_t *pmd)
374374
}
375375
#endif
376376

377-
#ifdef CONFIG_BLOCK
378-
/* Returns true if all buffers are successfully locked */
379-
static bool buffer_migrate_lock_buffers(struct buffer_head *head,
380-
enum migrate_mode mode)
381-
{
382-
struct buffer_head *bh = head;
383-
384-
/* Simple case, sync compaction */
385-
if (mode != MIGRATE_ASYNC) {
386-
do {
387-
get_bh(bh);
388-
lock_buffer(bh);
389-
bh = bh->b_this_page;
390-
391-
} while (bh != head);
392-
393-
return true;
394-
}
395-
396-
/* async case, we cannot block on lock_buffer so use trylock_buffer */
397-
do {
398-
get_bh(bh);
399-
if (!trylock_buffer(bh)) {
400-
/*
401-
* We failed to lock the buffer and cannot stall in
402-
* async migration. Release the taken locks
403-
*/
404-
struct buffer_head *failed_bh = bh;
405-
put_bh(failed_bh);
406-
bh = head;
407-
while (bh != failed_bh) {
408-
unlock_buffer(bh);
409-
put_bh(bh);
410-
bh = bh->b_this_page;
411-
}
412-
return false;
413-
}
414-
415-
bh = bh->b_this_page;
416-
} while (bh != head);
417-
return true;
418-
}
419-
#else
420-
static inline bool buffer_migrate_lock_buffers(struct buffer_head *head,
421-
enum migrate_mode mode)
422-
{
423-
return true;
424-
}
425-
#endif /* CONFIG_BLOCK */
426-
427377
static int expected_page_refs(struct page *page)
428378
{
429379
int expected_count = 1;
@@ -751,6 +701,48 @@ int migrate_page(struct address_space *mapping,
751701
EXPORT_SYMBOL(migrate_page);
752702

753703
#ifdef CONFIG_BLOCK
704+
/* Returns true if all buffers are successfully locked */
705+
static bool buffer_migrate_lock_buffers(struct buffer_head *head,
706+
enum migrate_mode mode)
707+
{
708+
struct buffer_head *bh = head;
709+
710+
/* Simple case, sync compaction */
711+
if (mode != MIGRATE_ASYNC) {
712+
do {
713+
get_bh(bh);
714+
lock_buffer(bh);
715+
bh = bh->b_this_page;
716+
717+
} while (bh != head);
718+
719+
return true;
720+
}
721+
722+
/* async case, we cannot block on lock_buffer so use trylock_buffer */
723+
do {
724+
get_bh(bh);
725+
if (!trylock_buffer(bh)) {
726+
/*
727+
* We failed to lock the buffer and cannot stall in
728+
* async migration. Release the taken locks
729+
*/
730+
struct buffer_head *failed_bh = bh;
731+
put_bh(failed_bh);
732+
bh = head;
733+
while (bh != failed_bh) {
734+
unlock_buffer(bh);
735+
put_bh(bh);
736+
bh = bh->b_this_page;
737+
}
738+
return false;
739+
}
740+
741+
bh = bh->b_this_page;
742+
} while (bh != head);
743+
return true;
744+
}
745+
754746
/*
755747
* Migration function for pages with buffers. This function can only be used
756748
* if the underlying filesystem guarantees that no other references to "page"

0 commit comments

Comments
 (0)