From patchwork Wed Dec 10 01:45:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 5466231 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BB0F1BEEBA for ; Wed, 10 Dec 2014 01:52:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC9D220121 for ; Wed, 10 Dec 2014 01:52:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0E6DF2012B for ; Wed, 10 Dec 2014 01:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754233AbaLJBqu (ORCPT ); Tue, 9 Dec 2014 20:46:50 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:53424 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754190AbaLJBqs (ORCPT ); Tue, 9 Dec 2014 20:46:48 -0500 Received: by mail-pa0-f45.google.com with SMTP id lf10so1123840pab.4 for ; Tue, 09 Dec 2014 17:46:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=pGr30Cu5H5I9DC+SCO1hvDEKU52BXlJXymx4PCXPJsg=; b=j7mctVUKImBriNWpQPe2u96baZ5AJFkOoxREyP0sPbAtlvbS3hfrBkOZPyUFMr5Nq5 e+2PkA6qQAucK2u3U1EeZIuViZqM4oTPFd9Z1LYUeo51SYCaviH2FnnatSongIZp3vIh YoE3+Z/oX3teD+d7bLHJ5ne+Ec7oLMYyPSmMgfU5RW9EPAbN0nnwn8Fe/Du0z8skTq8F t8PVdtd3mREERD1zIkadqT41BWCbhNlyJsHEADWEX95cegjcy9769i9z2zJCKczzzbnA RfCp2CtvNPUFbp07Zsiyk2F/xxyZv5bjhN40FvdcV4mvI9HisHoMks/wuICHpxcC3H7J B0Ag== X-Gm-Message-State: ALoCoQl7e4nZwiS2KocGBe3grMzK3XSAj5MDLbqB4eibs8wN9TUl5vJfxj18uYoCvevRcrHh3qgJ X-Received: by 10.70.102.35 with SMTP id fl3mr2674814pdb.30.1418176007781; Tue, 09 Dec 2014 17:46:47 -0800 (PST) Received: from mew.localdomain (c-24-19-133-29.hsd1.wa.comcast.net. [24.19.133.29]) by mx.google.com with ESMTPSA id on1sm2602957pdb.32.2014.12.09.17.46.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Dec 2014 17:46:47 -0800 (PST) From: Omar Sandoval To: Alexander Viro , Andrew Morton , Chris Mason , Josef Bacik , Trond Myklebust , Christoph Hellwig , David Sterba , linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Omar Sandoval Subject: [RFC PATCH v3 6/7] btrfs: add EXTENT_FLAG_SWAPFILE Date: Tue, 9 Dec 2014 17:45:47 -0800 Message-Id: X-Mailer: git-send-email 2.1.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Extents mapping a swap file should remain pinned in memory in order to avoid doing allocations to look up an extent when we're already low on memory. Rather than overloading EXTENT_FLAG_PINNED, add a new flag specifically for this purpose. Signed-off-by: Omar Sandoval Reviewed-by: David Sterba --- fs/btrfs/extent_io.c | 1 + fs/btrfs/extent_map.h | 1 + fs/btrfs/inode.c | 1 + include/trace/events/btrfs.h | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index bf3f424..36166d0 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4244,6 +4244,7 @@ int try_release_extent_mapping(struct extent_map_tree *map, break; } if (test_bit(EXTENT_FLAG_PINNED, &em->flags) || + test_bit(EXTENT_FLAG_SWAPFILE, &em->flags) || em->start != start) { write_unlock(&map->lock); free_extent_map(em); diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h index b2991fd..93b9548 100644 --- a/fs/btrfs/extent_map.h +++ b/fs/btrfs/extent_map.h @@ -16,6 +16,7 @@ #define EXTENT_FLAG_LOGGING 4 /* Logging this extent */ #define EXTENT_FLAG_FILLING 5 /* Filling in a preallocated extent */ #define EXTENT_FLAG_FS_MAPPING 6 /* filesystem extent mapping type */ +#define EXTENT_FLAG_SWAPFILE 7 /* this extent maps a swap file */ struct extent_map { struct rb_node rb_node; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d23362f..7c2dfb2 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6353,6 +6353,7 @@ again: else goto out; } + WARN_ON_ONCE(IS_SWAPFILE(inode)); em = alloc_extent_map(); if (!em) { err = -ENOMEM; diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index 1faecea..5c5f9de 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -164,7 +164,8 @@ DEFINE_EVENT(btrfs__inode, btrfs_inode_evict, { (1 << EXTENT_FLAG_PREALLOC), "PREALLOC" },\ { (1 << EXTENT_FLAG_LOGGING), "LOGGING" },\ { (1 << EXTENT_FLAG_FILLING), "FILLING" },\ - { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" }) + { (1 << EXTENT_FLAG_FS_MAPPING), "FS_MAPPING" },\ + { (1 << EXTENT_FLAG_SWAPFILE), "SWAPFILE" }) TRACE_EVENT_CONDITION(btrfs_get_extent,