From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:38130 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754440AbeGIEyV (ORCPT ); Mon, 9 Jul 2018 00:54:21 -0400 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC][PATCH 22/27] anon_inode_getfile(): switch to alloc_file_pseudo() Date: Mon, 9 Jul 2018 05:54:12 +0100 Message-Id: <20180709045417.13988-22-viro@ZenIV.linux.org.uk> In-Reply-To: <20180709045417.13988-1-viro@ZenIV.linux.org.uk> References: <20180709045320.GF30522@ZenIV.linux.org.uk> <20180709045417.13988-1-viro@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Al Viro Signed-off-by: Al Viro --- fs/anon_inodes.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index bf952939a1d3..7e13edd23db1 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c @@ -71,8 +71,6 @@ struct file *anon_inode_getfile(const char *name, const struct file_operations *fops, void *priv, int flags) { - struct qstr this; - struct path path; struct file *file; if (IS_ERR(anon_inode_inode)) @@ -82,29 +80,15 @@ struct file *anon_inode_getfile(const char *name, return ERR_PTR(-ENOENT); /* - * Link the inode to a directory entry by creating a unique name - * using the inode sequence number. - */ - file = ERR_PTR(-ENOMEM); - this.name = name; - this.len = strlen(name); - this.hash = 0; - path.dentry = d_alloc_pseudo(anon_inode_mnt->mnt_sb, &this); - if (!path.dentry) - goto err_module; - - path.mnt = mntget(anon_inode_mnt); - /* * We know the anon_inode inode count is always greater than zero, * so ihold() is safe. */ ihold(anon_inode_inode); - - d_instantiate(path.dentry, anon_inode_inode); - - file = alloc_file(&path, OPEN_FMODE(flags) | FMODE_OPENED, fops); + file = alloc_file_pseudo(anon_inode_inode, anon_inode_mnt, name, + OPEN_FMODE(flags), fops); if (IS_ERR(file)) - goto err_dput; + goto err; + file->f_mapping = anon_inode_inode->i_mapping; file->f_flags = flags & (O_ACCMODE | O_NONBLOCK); @@ -112,9 +96,8 @@ struct file *anon_inode_getfile(const char *name, return file; -err_dput: - path_put(&path); -err_module: +err: + iput(anon_inode_inode); module_put(fops->owner); return file; } -- 2.11.0