From patchwork Tue Nov 17 23:00:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 7643651 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 7D5359F7CA for ; Tue, 17 Nov 2015 23:04:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB2CC2058A for ; Tue, 17 Nov 2015 23:04:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C40862057E for ; Tue, 17 Nov 2015 23:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932626AbbKQXBq (ORCPT ); Tue, 17 Nov 2015 18:01:46 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:54388 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754979AbbKQXAs (ORCPT ); Tue, 17 Nov 2015 18:00:48 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1ZypF1-0006Pf-CO; Tue, 17 Nov 2015 23:00:47 +0000 From: Al Viro To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Neil Brown , linux-fsdevel@vger.kernel.org Subject: [PATCH 10/10] teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode Date: Tue, 17 Nov 2015 23:00:46 +0000 Message-Id: <1447801246-24588-10-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20151117225752.GZ22011@ZenIV.linux.org.uk> References: <20151117225752.GZ22011@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=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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; }