From patchwork Thu Apr 11 01:34:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tobin C. Harding" X-Patchwork-Id: 10894987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C44D717E1 for ; Thu, 11 Apr 2019 01:37:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B32492022C for ; Thu, 11 Apr 2019 01:37:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6FBA288F6; Thu, 11 Apr 2019 01:37:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F2952022C for ; Thu, 11 Apr 2019 01:37:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C77E6B026F; Wed, 10 Apr 2019 21:37:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 077CD6B0270; Wed, 10 Apr 2019 21:37:28 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E81C26B0271; Wed, 10 Apr 2019 21:37:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id C85786B026F for ; Wed, 10 Apr 2019 21:37:27 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id k13so4065658qtc.23 for ; Wed, 10 Apr 2019 18:37:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Tq6hWwswYs/S8V9g57LOLmjTNN0NoV+f6Q5VLbbSnZY=; b=Hweduz0GbrmX/qU9oEvCXkU1eKPFFByZS8SEoYnbgBZZ6k8Nuh62Mb9GKkAr5i6Adc rjGnNw10uSpTYKS0ODwqFiYIcOl/DXvJbCzR48S7aNzU/wYOx24JBYVkWG2sjdvRrhGE crwf80L+1j6Hmja1aqZFH/8hLLd5oLTigJ5o3A3HqFjGNbkR+OIKwAsrBmjweRk2G11J z2Xkc1CRYB5DTmKhcEG4Ipeohw2fa23yJoPn0I5yb1EP+dPHE4tglt79reimLep3XWaT gG09NI7mtt5YC6oA9YYu42Hfxc2UtFL4KaOvnjen/miod6+smI2m+XBe6HMKof01CKdZ 9IVA== X-Gm-Message-State: APjAAAWwB0fhs5ahlWDdMTZo/VBWAMbdeOGw3mZy9HU8frGRSmM11Jdw AEbKVmU5K/hJjd4j1CzG/ayhez8ri5Nr4nzkvkNhgCpDNGcHEPGsS0U6735Wpfqu/8KeuAcTLiG Wr6u91vY3K84gztNwNPjMggbbIn9HjFxdDrZYbmWgxiz30xluzKCOswHVHPSFIGc= X-Received: by 2002:ac8:3786:: with SMTP id d6mr39089124qtc.328.1554946647597; Wed, 10 Apr 2019 18:37:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqybuh9vh6d3bvcMWQjQHH+D6K8Mrnjk4PfmltQd9sSBT6JOUW+a8htXR1MQd0aGETpP8q7a X-Received: by 2002:ac8:3786:: with SMTP id d6mr39089064qtc.328.1554946646637; Wed, 10 Apr 2019 18:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554946646; cv=none; d=google.com; s=arc-20160816; b=spZgO+DEGaptUajRw94cZIzz5IPJXcuznf7+g73bAZja92FAhE4YBvM32MlijF3/lB +6djgXNWeT0NJvu2uWyW8xKJW6ESf68Dp3b8nDhesLixnVbIRS5uJCzDPfbIb6I/sT6A Nff20zgQ5mEHEtHc5cCKLautLcu7MwYJRlvkmG82puQQ0Xn3JyrCMSMLxPuWv6CxDDBg OF97uwH04uASPstYaAJfy4iEN0k6818RzYxHerQIi/kgjwrJTAlf81MruokSo++mzFOH CHSMR1pBJFW+TuKcNDCYCpYQIRdpnRayKzwC8xrWCYSk3ED2S1GHRGndHNiNpX5ngsZW 4oZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Tq6hWwswYs/S8V9g57LOLmjTNN0NoV+f6Q5VLbbSnZY=; b=j5mY2Ww4tYndtaESviWk1ptpn/m8x8uwBuvvMEI33B6Iy28vtuNSmjZABaK93g0O2s DFfh9pLS9sRMxsNxl97Ed5mnlZOENbwBnc/kLNlcWVge4FQ+MSqNaCABRRSsu4uXZ1H8 /HxQgYbrW4IGGPWS9ud/tQjXSrUZ7H4NSDCAEBlC/5YleRMS1Y+sNwZiMELi/Hyg5SAn GmBzrQhTbAu5jwh7DQaqHIkblKLRBM/ltdBUYBdPtlTU62q/s1pgrzYJxPaG8CfMLHNK bN5CxuXa1eYU/h0zX+t1oDCIg+LOAkEmuhERo76N42TXPdzUZsiqbeBcMeDldJj1TzBK xWiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=2CRQThrQ; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.230 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com. [66.111.4.230]) by mx.google.com with ESMTPS id f50si33950qtk.357.2019.04.10.18.37.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 18:37:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.230 as permitted sender) client-ip=66.111.4.230; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=2CRQThrQ; spf=softfail (google.com: domain of transitioning tobin@kernel.org does not designate 66.111.4.230 as permitted sender) smtp.mailfrom=tobin@kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 59C58B79A; Wed, 10 Apr 2019 21:37:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 10 Apr 2019 21:37:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=Tq6hWwswYs/S8V9g57LOLmjTNN0NoV+f6Q5VLbbSnZY=; b=2CRQThrQ eRsRFpQwkExGuy4vU8Wmq+XtUbO/D19tvIhEaDKMVcNYwDQ46PNrEAI8EH8/HKx7 FTIM1nhNO2pXs4zZKFKogUkU1Z6hCDQD9Zwn4jUDztIlyNa/kBlLxB10AXVs2B9r /COdMWuyRClZFWnN24mFPzhXKsiV+cU9aItt0t4fyZzSfQ4e8YWiQMv8tm9xFVu+ DXPS5uvMffVixFrAjqTvzdxbdvXap+uO7hpIIAIu+cHzXJyRdYn3Wew5OKX41vf9 sRPV41XoTj7YNB0Tj+ixOAUbqElipOaRs0ZJSRekdMJGWlQ6nyG5gZCye3z//aPn 2fQUbHpFdTBFkw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudekgdegvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddvgedrudejuddrudelrdduleegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehtohgs ihhnsehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from eros.localdomain (124-171-19-194.dyn.iinet.net.au [124.171.19.194]) by mail.messagingengine.com (Postfix) with ESMTPA id 5A211E408B; Wed, 10 Apr 2019 21:37:18 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Roman Gushchin , Alexander Viro , Christoph Hellwig , Pekka Enberg , David Rientjes , Joonsoo Kim , Christopher Lameter , Matthew Wilcox , Miklos Szeredi , Andreas Dilger , Waiman Long , Tycho Andersen , "Theodore Ts'o" , Andi Kleen , David Chinner , Nick Piggin , Rik van Riel , Hugh Dickins , Jonathan Corbet , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v3 13/15] dcache: Provide a dentry constructor Date: Thu, 11 Apr 2019 11:34:39 +1000 Message-Id: <20190411013441.5415-14-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190411013441.5415-1-tobin@kernel.org> References: <20190411013441.5415-1-tobin@kernel.org> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP In order to support object migration on the dentry cache we need to have a determined object state at all times. Without a constructor the object would have a random state after allocation. Provide a dentry constructor. Signed-off-by: Tobin C. Harding --- fs/dcache.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index aac41adf4743..606cfca20d42 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1603,6 +1603,16 @@ void d_invalidate(struct dentry *dentry) } EXPORT_SYMBOL(d_invalidate); +static void dcache_ctor(void *p) +{ + struct dentry *dentry = p; + + /* Mimic lockref_mark_dead() */ + dentry->d_lockref.count = -128; + + spin_lock_init(&dentry->d_lock); +} + /** * __d_alloc - allocate a dcache entry * @sb: filesystem it will belong to @@ -1658,7 +1668,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) dentry->d_lockref.count = 1; dentry->d_flags = 0; - spin_lock_init(&dentry->d_lock); + seqcount_init(&dentry->d_seq); dentry->d_inode = NULL; dentry->d_parent = dentry; @@ -3091,14 +3101,17 @@ static void __init dcache_init_early(void) static void __init dcache_init(void) { - /* - * A constructor could be added for stable state like the lists, - * but it is probably not worth it because of the cache nature - * of the dcache. - */ - dentry_cache = KMEM_CACHE_USERCOPY(dentry, - SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|SLAB_MEM_SPREAD|SLAB_ACCOUNT, - d_iname); + slab_flags_t flags = + SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | SLAB_MEM_SPREAD | SLAB_ACCOUNT; + + dentry_cache = + kmem_cache_create_usercopy("dentry", + sizeof(struct dentry), + __alignof__(struct dentry), + flags, + offsetof(struct dentry, d_iname), + sizeof_field(struct dentry, d_iname), + dcache_ctor); /* Hash may have been set up in dcache_init_early */ if (!hashdist)