From patchwork Fri Nov 22 16:52:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 3223451 Return-Path: X-Original-To: patchwork-linux-btrfs@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 480F1C045B for ; Fri, 22 Nov 2013 16:53:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18CFB207AA for ; Fri, 22 Nov 2013 16:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 055B1207A9 for ; Fri, 22 Nov 2013 16:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932100Ab3KVQxG (ORCPT ); Fri, 22 Nov 2013 11:53:06 -0500 Received: from mail-wi0-f173.google.com ([209.85.212.173]:41997 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932095Ab3KVQxF (ORCPT ); Fri, 22 Nov 2013 11:53:05 -0500 Received: by mail-wi0-f173.google.com with SMTP id hm4so1012466wib.12 for ; Fri, 22 Nov 2013 08:53:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Eprb4wPeHVfq3F0ka+Qdebp5CRFqABo/AjLHxiDsk/w=; b=kT8opFSsxYbt2ZtxMbXMsLhy9F4KzjbN+0Jl1GXu++yzZLwEYdyv7neTQO029Nd+GA cIkdH0DEuQb6+HOVzVXVv2ZtI/IfR0aMAvhH7O4R04tKM5BO84u1hd8vMnYAS22OaUFw 8k9acfnjPFr9UZJ3go1CSkwsWpARg3zZJy4fqjgOpGBQ496w15dFvzI8HGlnPWnKWyFa t6qenHhjcVtTiimj0expPP0seIIuXB0HSrFByA8eLyQMKpeHLiYXcDe5XMZXSoWs0oJQ VMAwIGTLgz8QmUvmnQgeU1jRaxEAi78qt+C0QOdoV/gcGcAKCZKct1VzctIUTGTpM/g/ ybSg== X-Received: by 10.194.143.100 with SMTP id sd4mr1868509wjb.69.1385139183592; Fri, 22 Nov 2013 08:53:03 -0800 (PST) Received: from storm-desktop.lan (bl9-170-14.dsl.telepac.pt. [85.242.170.14]) by mx.google.com with ESMTPSA id y20sm17809634wib.0.2013.11.22.08.53.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:53:03 -0800 (PST) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH] Btrfs: avoid unnecessary ordered extent cache resets Date: Fri, 22 Nov 2013 16:52:43 +0000 Message-Id: <1385139163-7539-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 After an ordered extent completes, don't blindly reset the inode's ordered tree last accessed ordered extent pointer. While running the xfstests I noticed that about 29% of the time the ordered extent to which tree->last pointed was not the same as our just completed ordered extent. After that I ran the following sysbench test (after a prepare phase) and noticed that about 68% of the time tree->last pointed to a different ordered extent too. sysbench --test=fileio --file-num=32 --file-total-size=4G \ --file-test-mode=rndwr --num-threads=512 \ --file-block-size=32768 --max-time=60 --max-requests=0 run Therefore reset tree->last on ordered extent removal only if it pointed to the ordered extent we're removing from the tree. Signed-off-by: Filipe David Borba Manana --- fs/btrfs/ordered-data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 69582d5..b8c2ded 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -520,7 +520,8 @@ void btrfs_remove_ordered_extent(struct inode *inode, spin_lock_irq(&tree->lock); node = &entry->rb_node; rb_erase(node, &tree->tree); - tree->last = NULL; + if (tree->last == node) + tree->last = NULL; set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags); spin_unlock_irq(&tree->lock);