From patchwork Mon Mar 16 04:43:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 6015151 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 45592BF90F for ; Mon, 16 Mar 2015 04:45:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 843EA202F8 for ; Mon, 16 Mar 2015 04:45:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 849E8203E3 for ; Mon, 16 Mar 2015 04:45:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753076AbbCPEpB (ORCPT ); Mon, 16 Mar 2015 00:45:01 -0400 Received: from cantor2.suse.de ([195.135.220.15]:56233 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753066AbbCPEpA (ORCPT ); Mon, 16 Mar 2015 00:45:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B5D2DAAC8; Mon, 16 Mar 2015 04:44:58 +0000 (UTC) From: NeilBrown To: Al Viro Date: Mon, 16 Mar 2015 15:43:20 +1100 Subject: [PATCH 08/13] VFS/namei: enhance follow_link to support RCU-walk. Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <20150316044320.23648.68027.stgit@notabene.brown> In-Reply-To: <20150316043602.23648.52734.stgit@notabene.brown> References: <20150316043602.23648.52734.stgit@notabene.brown> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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=unavailable 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 If LOOKUP_RCU is set, follow_link will not take/drop reference counts. Replace cond_resched() with _cond_resched() as the latter is a no-op if rcu_read_lock() is held while the former will give a warning in that case. Signed-off-by: NeilBrown --- fs/namei.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/namei.c b/fs/namei.c index 1663d21a3eb4..536e0254f5f1 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -906,7 +906,8 @@ follow_link(struct path *link, struct nameidata *nd, void **p) if (unlikely(current->nameidata->total_link_count >= 40)) goto out_put_nd_path; - cond_resched(); + /* If rcu_read_locked(), this will not resched, and will not warn */ + _cond_resched(); current->nameidata->total_link_count++; if (nd->flags & LOOKUP_RCU) { @@ -936,11 +937,17 @@ follow_link(struct path *link, struct nameidata *nd, void **p) return PTR_ERR(s); } if (*s == '/') { - if (!nd->root.mnt) - set_root(nd); - path_put(&nd->path); - nd->path = nd->root; - path_get(&nd->root); + if (nd->flags & LOOKUP_RCU) { + if (!nd->root.mnt) + set_root_rcu(nd); + nd->path = nd->root; + } else { + if (!nd->root.mnt) + set_root(nd); + path_put(&nd->path); + nd->path = nd->root; + path_get(&nd->root); + } nd->flags |= LOOKUP_JUMPED; } nd->inode = nd->path.dentry->d_inode;