Revert "FROMLIST: fs/buffer.c: Revoke LRU when trying to drop buffers"

This reverts commit 7d212a5102.

This commit is superseded by commit a0a0b3f42e ("FROMLIST: mm: fs:
Invalidate BH LRU during page migration").

Conflicts:
    fs/buffer.c

1. In fs/buffer.c had to keep invalidate_bh_lrus_cpu() function that was
introduced in commit a0a0b3f42e as well as in the reverted commit.

Bug: 174118021
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I60d0a4e8beb35389727f29fea6ca4640ecee40a7
This commit is contained in:
Chris Goldsworthy 2021-03-17 17:15:27 -07:00 committed by Suren Baghdasaryan
parent 2934fc6a03
commit 434df9f35d

View File

@ -48,7 +48,6 @@
#include <linux/sched/mm.h>
#include <trace/events/block.h>
#include <linux/fscrypt.h>
#include <linux/xarray.h>
#include "internal.h"
@ -1449,55 +1448,12 @@ bool has_bh_in_lru(int cpu, void *dummy)
return false;
}
static void __evict_bhs_lru(void *arg)
{
struct bh_lru *b = &get_cpu_var(bh_lrus);
struct xarray *busy_bhs = arg;
struct buffer_head *bh;
unsigned long i, xarray_index;
xa_for_each(busy_bhs, xarray_index, bh) {
for (i = 0; i < BH_LRU_SIZE; i++) {
if (b->bhs[i] == bh) {
brelse(b->bhs[i]);
b->bhs[i] = NULL;
break;
}
}
}
put_cpu_var(bh_lrus);
}
static bool page_has_bhs_in_lru(int cpu, void *arg)
{
struct bh_lru *b = per_cpu_ptr(&bh_lrus, cpu);
struct xarray *busy_bhs = arg;
struct buffer_head *bh;
unsigned long i, xarray_index;
xa_for_each(busy_bhs, xarray_index, bh) {
for (i = 0; i < BH_LRU_SIZE; i++) {
if (b->bhs[i] == bh)
return true;
}
}
return false;
}
void invalidate_bh_lrus(void)
{
on_each_cpu_cond(has_bh_in_lru, invalidate_bh_lru, NULL, 1);
}
EXPORT_SYMBOL_GPL(invalidate_bh_lrus);
static void evict_bh_lrus(struct xarray *busy_bhs)
{
on_each_cpu_cond(page_has_bhs_in_lru, __evict_bhs_lru,
busy_bhs, 1);
}
void invalidate_bh_lrus_cpu(int cpu)
{
struct bh_lru *b;
@ -3268,38 +3224,14 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free)
{
struct buffer_head *head = page_buffers(page);
struct buffer_head *bh;
struct xarray busy_bhs;
int bh_count = 0;
int xa_ret, ret = 0;
xa_init(&busy_bhs);
bh = head;
do {
if (buffer_busy(bh)) {
xa_ret = xa_err(xa_store(&busy_bhs, bh_count++,
bh, GFP_ATOMIC));
if (xa_ret)
goto out;
}
if (buffer_busy(bh))
goto failed;
bh = bh->b_this_page;
} while (bh != head);
if (bh_count) {
/*
* Check if the busy failure was due to an outstanding
* LRU reference
*/
evict_bh_lrus(&busy_bhs);
do {
if (buffer_busy(bh))
goto out;
bh = bh->b_this_page;
} while (bh != head);
}
ret = 1;
do {
struct buffer_head *next = bh->b_this_page;
@ -3309,10 +3241,9 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free)
} while (bh != head);
*buffers_to_free = head;
detach_page_private(page);
out:
xa_destroy(&busy_bhs);
return ret;
return 1;
failed:
return 0;
}
int try_to_free_buffers(struct page *page)