Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp398230yba; Wed, 3 Apr 2019 10:50:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvfPCnFZriG1n+XH7zt/YQ/DQeu3yvel5HNGz28AMZg3UjoeVdOdX8WDs+ahzR7tki4Z+z X-Received: by 2002:a63:36ce:: with SMTP id d197mr1042895pga.180.1554313818938; Wed, 03 Apr 2019 10:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554313818; cv=none; d=google.com; s=arc-20160816; b=jnHeqWv5m8Qae08gmUdMmxOedidQLCLOBwGnfIaII7eRbHCTO92ypzovN7KFrOAZrf HvYAdZndj3OW5ykZpmpZY1TlxcPwgr9HSu325YloLgQ6zAfZuMusCLXIWt0SxE+0VkT7 rkYVoUcRWdY/WmkIAFF6LOv5hLLgyekx/9EP3dvqpYon0NtqZGi2QlOMvY9bYrVSYRD5 HGuRGeVFa/qXogCMjPOyEPOwl1Fso1kJg0tl8BXfVA65LsUA1PGjGT2vtGSV6YGZVFns ncDxveEH7lIb3B5mZ2F6eSlosH0s/uW7+/aFVs/yAK4Ch92hg4YE1l+FKqUWjGt3XDGR NhNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IXX7H07x0qVGMSb+Zrza7jNHJu1+IltRuSWsNvh53z4=; b=qtxZxzmyz2Tlt+NGiujFG4JsMkoTqlyf66MQc2CYwC0RIm6YGxFw+c4AMUGuMWeXHk rHVfJSdbHos+oynYiR04mb9JemdIT5o7908c/WYSh2AJ4hdCNWkmToTJ84FIGPZDmi7f Ax+8Gvio5cqPgCDmpk54yGX8E6k/23xRGG15/96jYwZweFR38UjlmR/8/cGKsT0gpGnh DDM+3tZNIO+mxqEe7O39kScUZvRNmiNNcmhg3KsMiZsuHBcRMTm8CB2gPEgADjCV9oDr x28F0QLquoD3zBszHAe12TBLzy+QNpvu+uxQcYtobfCYtURfVAIOQ4vFYPojVtK7uvrq Xmtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay8si8218604plb.202.2019.04.03.10.50.03; Wed, 03 Apr 2019 10:50:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726425AbfDCRtX (ORCPT + 99 others); Wed, 3 Apr 2019 13:49:23 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:34218 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbfDCRtX (ORCPT ); Wed, 3 Apr 2019 13:49:23 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hBk0N-0004qz-VD; Wed, 03 Apr 2019 17:48:56 +0000 Date: Wed, 3 Apr 2019 18:48:55 +0100 From: Al Viro To: "Tobin C. Harding" Cc: Andrew Morton , 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 , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds Subject: Re: [RFC PATCH v2 14/14] dcache: Implement object migration Message-ID: <20190403174855.GT2217@ZenIV.linux.org.uk> References: <20190403042127.18755-1-tobin@kernel.org> <20190403042127.18755-15-tobin@kernel.org> <20190403170811.GR2217@ZenIV.linux.org.uk> <20190403171920.GS2217@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190403171920.GS2217@ZenIV.linux.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 03, 2019 at 06:19:21PM +0100, Al Viro wrote: > On Wed, Apr 03, 2019 at 06:08:11PM +0100, Al Viro wrote: > > > Oh, *brilliant* > > > > Let's do d_invalidate() on random dentries and hope they go away. > > With convoluted and brittle logics for deciding which ones to > > spare, which is actually wrong. This will pick mountpoints > > and tear them out, to start with. > > > > NAKed-by: Al Viro > > > > And this is a NAK for the entire approach; if it has a positive refcount, > > LEAVE IT ALONE. Period. Don't play this kind of games, they are wrong. > > d_invalidate() is not something that can be done to an arbitrary dentry. > > PS: "try to evict what can be evicted out of this set" can be done, but > you want something like > start with empty list > go through your array of references > grab dentry->d_lock > if dentry->d_lockref.count is not zero > unlock and continue > if dentry->d_flags & DCACHE_SHRINK_LIST > ditto, it's not for us to play with > if (dentry->d_flags & DCACHE_LRU_LIST) > d_lru_del(dentry); > d_shrink_add(dentry, &list); > unlock > > on the collection phase and > if the list is not empty by the end of that loop > shrink_dentry_list(&list); > on the disposal. Note, BTW, that your constructor is wrong - all it really needs to do is spin_lock_init() and setting ->d_lockref.count same as lockref_mark_dead() does, to match the state of dentries being torn down. __d_alloc() is not holding ->d_lock, since the object is not visible to anybody else yet; with your changes it *is* visible. However, if the assignment to ->d_lockref.count in __d_alloc() is guaranteed to be non-zero to non-zero, the above should be safe.