From patchwork Thu Dec 3 16:56:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 7761851 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A83169F350 for ; Thu, 3 Dec 2015 16:58:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4F232051D for ; Thu, 3 Dec 2015 16:58:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D69FB204E0 for ; Thu, 3 Dec 2015 16:58:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752701AbbLCQ6Y (ORCPT ); Thu, 3 Dec 2015 11:58:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:44512 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752692AbbLCQ6X (ORCPT ); Thu, 3 Dec 2015 11:58:23 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BE25CADD8 for ; Thu, 3 Dec 2015 16:58:22 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id BF641DA8E4; Thu, 3 Dec 2015 17:56:32 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 04/12] btrfs: change how delay_iput is tracked in btrfs_delalloc_work Date: Thu, 3 Dec 2015 17:56:32 +0100 Message-Id: X-Mailer: git-send-email 2.6.2 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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=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 The dellaloc work is not frequently used, the delayed status is once set and read so it looks quite safe to drop the member and store the status in the lowest bit of the inode pointer. Combined with the removal of 'wait' we got +2 objects per 4k slab. Signed-off-by: David Sterba --- fs/btrfs/ctree.h | 5 ++++- fs/btrfs/inode.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index a61c53bce162..d5e250a65725 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3901,8 +3901,11 @@ void btrfs_extent_item_to_extent_map(struct inode *inode, /* inode.c */ struct btrfs_delalloc_work { + /* + * Note: lowest bit of inode tracks if the iput is delayed, + * do not access the pointer directly. + */ struct inode *inode; - int delay_iput; struct completion completion; struct list_head list; struct btrfs_work work; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 15b29e879ffc..529a53b80ca0 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9436,16 +9436,21 @@ static void btrfs_run_delalloc_work(struct btrfs_work *work) { struct btrfs_delalloc_work *delalloc_work; struct inode *inode; + int delay_iput; delalloc_work = container_of(work, struct btrfs_delalloc_work, work); inode = delalloc_work->inode; + /* Lowest bit of inode pointer tracks the delayed status */ + delay_iput = ((unsigned long)inode & 1UL); + inode = (struct inode *)((unsigned long)inode & ~1UL); + filemap_flush(inode->i_mapping); if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT, &BTRFS_I(inode)->runtime_flags)) filemap_flush(inode->i_mapping); - if (delalloc_work->delay_iput) + if (delay_iput) btrfs_add_delayed_iput(inode); else iput(inode); @@ -9464,7 +9469,9 @@ struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode, init_completion(&work->completion); INIT_LIST_HEAD(&work->list); work->inode = inode; - work->delay_iput = delay_iput; + /* Lowest bit of inode pointer tracks the delayed status */ + if (delay_iput) + *((unsigned long *)work->inode) |= 1UL; WARN_ON_ONCE(!inode); btrfs_init_work(&work->work, btrfs_flush_delalloc_helper, btrfs_run_delalloc_work, NULL, NULL);