Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1085120yba; Fri, 26 Apr 2019 13:52:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCvB6T3q4CJ7o650SURlG+KP2QMN0i+GppowDAjPI/7uA6Qa+Kue0tOhtz1hUK8R05++q+ X-Received: by 2002:a17:902:1024:: with SMTP id b33mr46877223pla.46.1556311940200; Fri, 26 Apr 2019 13:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556311940; cv=none; d=google.com; s=arc-20160816; b=R9bBd9Lh8TJ+3yVNrKlFMY2t/NutuMBV/ROsQugQ+KZZ/XhyxOvHFtDyCW+GVwgeWW Dmeqzfzj0Nefu0QPMZmv+63xDxu5tZHTKiCkRCu6ewemyeO/xzwiqDPsmj+LbFjbOkVJ BbWkMY3DIPGX1CxDLgNzRF9rSsriHmAocKcLlmCoWiwygdmcSJiClhhEmVQZXqBaA/kZ Dy61HyXcYamvJNjmXCDyhrWzCe6MfG7nMll5Bsze5BFneJTOyJYGMMBCxtiUiZVCPaqa 56xdDC0IrAWcCjxn2A5/K5IM3XUdiFMtZwm+OjUwSyXsMgFJ2s0o5QfH/hRYkuMFEXWR yYhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=jaL1DQQFDnDnjgqnXH8WimqMY7KXCBKgV/m/KwiRAWU=; b=h04oJkg/IPsugKLv6lK68a9C3S2BTTEnAQ5I/tuxt6RhLrjXde+2P8p9OlSFtXNZgH fl2XvKq/+43/acehuZu0hYRZvPjQJnfCPU7xvNrJUUYFdSRus8cvHLZZ9HKnlKg1iTc3 0ZgHsl+pzQGAChNByRZRVgThVpxv/bwykskoqf0AMtRyvltLJlM+7Qb+2Nvt6kKN0GB0 aCqpp1pbRly40CN4sQaf9m8JXGhQEzIhlEik41ZZ8YV8QupUWdaycHZLqBK1kIdJAcTP O+k1xZVJSs5UWc/79tZeECVvDzpTTz8GL9c1BX65BiDHi2m56qJbHSd+hOQ6GPktMhSr x+Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X5WsDu+A; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si3464922pln.354.2019.04.26.13.52.04; Fri, 26 Apr 2019 13:52:20 -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; dkim=pass header.i=@kernel.org header.s=default header.b=X5WsDu+A; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbfDZUt2 (ORCPT + 99 others); Fri, 26 Apr 2019 16:49:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:47710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725966AbfDZUt2 (ORCPT ); Fri, 26 Apr 2019 16:49:28 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D9D4F20869; Fri, 26 Apr 2019 20:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556311767; bh=VDya2lOzdc+RdKcdfCo3hUrniD8ewq64O1hFjOcwj48=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=X5WsDu+AGCrVW4BRziq1TQ7sUHhMra2/yLde3Wklx9S/KfV42V4q2buexmb5BnOuH M6s3YaBr3w5noxJdV+MknqAqpkbWiZyCd6KegT+x62L6nKpSSSETx+1GUPgBkLejl6 3ymXXK1sJLRKHPO4yWjhW4vpR5fZ86lulA1/XeMM= Message-ID: Subject: Re: [GIT PULL] Ceph fixes for 5.1-rc7 From: Jeff Layton To: Al Viro , Linus Torvalds Cc: Ilya Dryomov , ceph-devel@vger.kernel.org, Linux List Kernel Mailing Date: Fri, 26 Apr 2019 16:49:24 -0400 In-Reply-To: <20190426170108.GZ2217@ZenIV.linux.org.uk> References: <20190425174739.27604-1-idryomov@gmail.com> <342ef35feb1110197108068d10e518742823a210.camel@kernel.org> <20190425200941.GW2217@ZenIV.linux.org.uk> <86674e79e9f24e81feda75bc3c0dd4215604ffa5.camel@kernel.org> <20190426170108.GZ2217@ZenIV.linux.org.uk> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-04-26 at 18:01 +0100, Al Viro wrote: > On Fri, Apr 26, 2019 at 09:36:00AM -0700, Linus Torvalds wrote: > > On Fri, Apr 26, 2019 at 9:25 AM Jeff Layton wrote: > > > Is it really ok to union the count and rcu_head there? > > > > It should be fine, because the rcu_count should only ever be used once > > the count has gone to zero and the name cannot be found any more. > > > > And while RCU path walking may find and use the *name* after the > > dentry has been killed off (but not free'd yet), all the actual > > external_name() accesses should be serialized by the dentry lock, so > > there's no access to those fields once the dentry is dead. > > It's not quite that; access to external_name contents is fine, > ->d_lock or not. __d_lookup_rcu() does read it under rcu_read_lock > alone. > > However: > * we never free it without an RCU delay after the final > drop of refcount. RCU delay might happen on dentry->d_rcu (if > it's dentry_free()) or on name->p.rcu (if it's release_dentry_name_snapshot() > or d_move() dropping the final reference). > * it's never observed in ->d_name after the refcount > reaches zero. > * no lockless access ever looks at the refcount. It > can look at ->name[], but that's it. > Got it, thanks. Why use an atomic_t for the refcount if it's always accessed under spinlock? > What I don't understand is why would anyone want to mess with > name snapshots for dentry_path() lookalikes... Mostly because the place where the ceph code needs to use and free these strings is rather far removed from where they are created. It simplifies that part if we can access and free them all in the same way. I was planning to just use name_snapshots universally for that purpose, but they have a rather specific method of freeing things that is hard to duplicate if you don't have a dentry to clone. Probably that means I'm approaching this problem in the wrong way and need to do it differently. -- Jeff Layton