From patchwork Mon Apr 3 00:43:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 9658687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D93F860353 for ; Mon, 3 Apr 2017 00:43:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEA7A28409 for ; Mon, 3 Apr 2017 00:43:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1E9B28419; Mon, 3 Apr 2017 00:43:25 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63E9828409 for ; Mon, 3 Apr 2017 00:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751303AbdDCAnS (ORCPT ); Sun, 2 Apr 2017 20:43:18 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:48160 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750992AbdDCAnR (ORCPT ); Sun, 2 Apr 2017 20:43:17 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1cuq5S-0006Bg-Rh; Mon, 03 Apr 2017 00:43:14 +0000 Date: Mon, 3 Apr 2017 01:43:14 +0100 From: Al Viro To: Linus Torvalds Cc: Linux Kernel Mailing List , linux-fsdevel Subject: Re: [git pull] vfs fixes Message-ID: <20170403004314.GL29622@ZenIV.linux.org.uk> References: <20170402170148.GI29622@ZenIV.linux.org.uk> <20170403003045.GK29622@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170403003045.GK29622@ZenIV.linux.org.uk> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Apr 03, 2017 at 01:30:45AM +0100, Al Viro wrote: > Currently true and almost certainly will remain so. Point taken, what you > are suggesting is better. Actually, the invariant to watch for is > "no d_can_lookup() withtout DCACHE_RCUACCESS" and that we can trivially > enforce by one-liner change in d_flags_for_inode() - > s/DCACHE_DIRECTORY_TYPE/& | DCACHE_RCUACCESS/ > > OK... Do you have any objections against the following (still untested) variant? I don't see any point in checking for flags & LOOKUP_RCU in case of !*s - flags is in register at that point, so... diff --git a/fs/dcache.c b/fs/dcache.c index 95d71eda8142..05550139a8a6 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1757,7 +1757,13 @@ static unsigned d_flags_for_inode(struct inode *inode) return DCACHE_MISS_TYPE; if (S_ISDIR(inode->i_mode)) { - add_flags = DCACHE_DIRECTORY_TYPE; + /* + * Any potential starting point of lookup should have + * DCACHE_RCUACCESS; currently directory dentries + * come from d_alloc() anyway, but it costs us nothing + * to enforce it here. + */ + add_flags = DCACHE_DIRECTORY_TYPE | DCACHE_RCUACCESS; if (unlikely(!(inode->i_opflags & IOP_LOOKUP))) { if (unlikely(!inode->i_op->lookup)) add_flags = DCACHE_AUTODIR_TYPE; diff --git a/fs/namei.c b/fs/namei.c index d41fab78798b..19dcf62133cc 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2145,6 +2145,9 @@ static const char *path_init(struct nameidata *nd, unsigned flags) int retval = 0; const char *s = nd->name->name; + if (!*s) + flags &= ~LOOKUP_RCU; + nd->last_type = LAST_ROOT; /* if there are only slashes... */ nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT; nd->depth = 0;