From patchwork Wed Dec 9 05:34:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 7804711 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 070589F39B for ; Wed, 9 Dec 2015 05:38:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B179204B0 for ; Wed, 9 Dec 2015 05:38:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 388A6204AE for ; Wed, 9 Dec 2015 05:38:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752369AbbLIFhq (ORCPT ); Wed, 9 Dec 2015 00:37:46 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:46483 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751431AbbLIFe5 (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 1a6XOx-0005LW-RE; Wed, 09 Dec 2015 05:34:55 +0000 From: Al Viro To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Neil Brown , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 05/11] namei: page_getlink() and page_follow_link_light() are the same thing Date: Wed, 9 Dec 2015 05:34:49 +0000 Message-Id: <1449639295-20512-5-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/namei.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 0c3974c..4bae5cb 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4518,7 +4518,7 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen) EXPORT_SYMBOL(generic_readlink); /* get the link contents into pagecache */ -static char *page_getlink(struct dentry * dentry, struct page **ppage) +static const char *page_getlink(struct dentry * dentry, void **cookie) { char *kaddr; struct page *page; @@ -4526,31 +4526,15 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage) page = read_mapping_page(mapping, 0, NULL); if (IS_ERR(page)) return (char*)page; - *ppage = page; + *cookie = page; kaddr = kmap(page); nd_terminate_link(kaddr, dentry->d_inode->i_size, PAGE_SIZE - 1); return kaddr; } -int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) -{ - struct page *page = NULL; - int res = readlink_copy(buffer, buflen, page_getlink(dentry, &page)); - if (page) { - kunmap(page); - page_cache_release(page); - } - return res; -} -EXPORT_SYMBOL(page_readlink); - const char *page_follow_link_light(struct dentry *dentry, void **cookie) { - struct page *page = NULL; - char *res = page_getlink(dentry, &page); - if (!IS_ERR(res)) - *cookie = page; - return res; + return page_getlink(dentry, cookie); } EXPORT_SYMBOL(page_follow_link_light); @@ -4562,6 +4546,16 @@ void page_put_link(struct inode *unused, void *cookie) } EXPORT_SYMBOL(page_put_link); +int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) +{ + void *cookie = NULL; + int res = readlink_copy(buffer, buflen, page_getlink(dentry, &cookie)); + if (cookie) + page_put_link(NULL, cookie); + return res; +} +EXPORT_SYMBOL(page_readlink); + /* * The nofs argument instructs pagecache_write_begin to pass AOP_FLAG_NOFS */