Re: [PATCH 4/8] btrfs: Warn if direct reclaim tries to writeback pages

Johannes Weiner
2011-08-03T11:10:59Z

On Thu, Jul 21, 2011 at 05:28:46PM +0100, Mel Gorman wrote:
> Direct reclaim should never writeback pages. Warn if an attempt is
> made. By rights, btrfs should be allowing writepage from kswapd if
> it is failing to reclaim pages by any other means but it's outside
> the scope of this patch.
>
> Signed-off-by: Mel Gorman <mgorman@suse.de>
> ---
> fs/btrfs/disk-io.c | 2 ++
> fs/btrfs/inode.c | 2 ++
> 2 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 1ac8db5d..cc9c9cf 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -829,6 +829,8 @@ static int btree_writepage(struct page *page, struct writeback_control *wbc)
>
> tree = &BTRFS_I(page->mapping->host)->io_tree;
> if (!(current->flags & PF_MEMALLOC)) {
> + WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) ==
> + PF_MEMALLOC);

Since it is branch for PF_MEMALLOC being set, why not just
WARN_ON_ONCE(!(current->flags & PF_KSWAPD)) instead?

Minor nitpick, though, and I can understand if you just want to have
the conditionals be the same in every fs.

Acked-by: Johannes Weiner <jweiner@redhat.com>