From patchwork Wed Dec 9 05:34:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 7804671 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 88FBE9F39B for ; Wed, 9 Dec 2015 05:37:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A29DB204B0 for ; Wed, 9 Dec 2015 05:37:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A70B204AE for ; Wed, 9 Dec 2015 05:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751954AbbLIFg5 (ORCPT ); Wed, 9 Dec 2015 00:36:57 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:46498 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751989AbbLIFe5 (ORCPT ); Wed, 9 Dec 2015 00:34:57 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1a6XOy-0005Lw-Gy; Wed, 09 Dec 2015 05:34:56 +0000 From: Al Viro To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Neil Brown , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 10/11] teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode Date: Wed, 9 Dec 2015 05:34:54 +0000 Message-Id: <1449639295-20512-10-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20151209053209.GV20997@ZenIV.linux.org.uk> References: <20151209053209.GV20997@ZenIV.linux.org.uk> 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 From: Al Viro Signed-off-by: Al Viro --- fs/proc/self.c | 8 +++----- fs/proc/thread_self.c | 9 ++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/fs/proc/self.c b/fs/proc/self.c index 9dd0ae6..7a8b19e 100644 --- a/fs/proc/self.c +++ b/fs/proc/self.c @@ -25,14 +25,12 @@ static const char *proc_self_get_link(struct dentry *dentry, pid_t tgid = task_tgid_nr_ns(current, ns); char *name; - if (!dentry) - return ERR_PTR(-ECHILD); if (!tgid) return ERR_PTR(-ENOENT); /* 11 for max length of signed int in decimal + NULL term */ - name = kmalloc(12, GFP_KERNEL); - if (!name) - return ERR_PTR(-ENOMEM); + name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC); + if (unlikely(!name)) + return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); sprintf(name, "%d", tgid); return *cookie = name; } diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c index 50eef6f..03eaa84 100644 --- a/fs/proc/thread_self.c +++ b/fs/proc/thread_self.c @@ -27,13 +27,12 @@ static const char *proc_thread_self_get_link(struct dentry *dentry, pid_t pid = task_pid_nr_ns(current, ns); char *name; - if (!dentry) - return ERR_PTR(-ECHILD); if (!pid) return ERR_PTR(-ENOENT); - name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL); - if (!name) - return ERR_PTR(-ENOMEM); + name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, + dentry ? GFP_KERNEL : GFP_ATOMIC); + if (unlikely(!name)) + return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); sprintf(name, "%d/task/%d", tgid, pid); return *cookie = name; }