Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2365956imm; Tue, 10 Jul 2018 19:25:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcNVqoWE5LqeaONk/mAXzPu+foSArF9yboSCgMTIO0+WS9xfuior5GzgSVP7rXswRwvorD/ X-Received: by 2002:a63:c60:: with SMTP id 32-v6mr25094200pgm.155.1531275931123; Tue, 10 Jul 2018 19:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531275931; cv=none; d=google.com; s=arc-20160816; b=mTv4rb1lgN+V96FR2KJ7LdQoPFzGW/bz60ZblHSpBXKJxitcW+mq9tnsrBCYMltqvG ba1USxTgCqcRF5elZCmrkTeDDnZVI23IuMnc+ybflkxKVmKUXpIi0nGWoO6nOwzTNSx6 K4QHDrFZmsVbO6rRh0m8O5JEiKAvNWBcMaUJAfI2rldyVMS2A2FA1zptawNqFl5CkvBF rBRNE8SvwA0gEMUKXHdtgqbjKt+EqKk0he6FBjMv0USJesgj8Tg6MMN/ALsS67RMSqnq lb/c9prGiNC4uiFdGSRVblDOLLNIDYzSDLv9XMnID1Sg6waAWcfjGikV692fQDWclYhV D/wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=lhskvCu4zcC86Q+GsXbWoH3dPyoH28t7QKju+uH2fws=; b=bB/XWv0JaerB6On7kElKmziap0ut0iqA1eoYAmCbkUijyCDrFC7FKikzHlGeHTJLMn VMnyRtBDEtJHNumF9MOHbKfN26KC/jJpGTQ5CqfJbMGjaYrAMC4WA7NCFBGK6K26+tUJ gCrx09Xzq7jEPhfsmNYFMy5gZVEaXKM8N3j20yoyqPy8RG6XVPYNNrLprq6cPch3rUIC Sv1mfPgw/92E60lVTPV4tI/3Rpdc4/LrVylzT88VwPXIbfUYDLPwioaX97y+n8zUPLF6 J+UFvTfYTx8uWgGGRQbvXamQ60RToJTV7K8l38djMDaK8UeYDMw7MRVwUl5/oSfFYcw1 oJZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4-v6si18270609pfi.184.2018.07.10.19.25.15; Tue, 10 Jul 2018 19:25:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732580AbeGKCYH (ORCPT + 99 others); Tue, 10 Jul 2018 22:24:07 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45664 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732379AbeGKCYG (ORCPT ); Tue, 10 Jul 2018 22:24:06 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fd4ld-0003Kd-Cn; Wed, 11 Jul 2018 02:22:09 +0000 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Miklos Szeredi Subject: [RFC][PATCH 30/42] ... and switch shmem_file_setup() to alloc_file_pseudo() Date: Wed, 11 Jul 2018 03:21:54 +0100 Message-Id: <20180711022206.12571-30-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180711022206.12571-1-viro@ZenIV.linux.org.uk> References: <20180711021136.GN30522@ZenIV.linux.org.uk> <20180711022206.12571-1-viro@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro Signed-off-by: Al Viro --- mm/shmem.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 1146a48926bc..fd21df189f32 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3896,18 +3896,11 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range); /* common code */ -static const struct dentry_operations anon_ops = { - .d_dname = simple_dname -}; - static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, loff_t size, unsigned long flags, unsigned int i_flags) { - struct file *res; struct inode *inode; - struct path path; - struct super_block *sb; - struct qstr this; + struct file *res; if (IS_ERR(mnt)) return ERR_CAST(mnt); @@ -3918,8 +3911,8 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, l if (shmem_acct_size(flags, size)) return ERR_PTR(-ENOMEM); - sb = mnt->mnt_sb; - inode = shmem_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0, flags); + inode = shmem_get_inode(mnt->mnt_sb, NULL, S_IFREG | S_IRWXUGO, 0, + flags); if (unlikely(!inode)) { shmem_unacct_size(flags, size); return ERR_PTR(-ENOSPC); @@ -3928,28 +3921,12 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, l inode->i_size = size; clear_nlink(inode); /* It is unlinked */ res = ERR_PTR(ramfs_nommu_expand_for_mapping(inode, size)); - if (IS_ERR(res)) { - iput(inode); - return res; - } - - this.name = name; - this.len = strlen(name); - this.hash = 0; /* will go */ - path.mnt = mntget(mnt); - path.dentry = d_alloc_pseudo(sb, &this); - if (!path.dentry) { - iput(inode); - return ERR_PTR(-ENOMEM); - } - d_set_d_op(path.dentry, &anon_ops); - - d_instantiate(path.dentry, inode); - - res = alloc_file(&path, FMODE_WRITE | FMODE_READ, - &shmem_file_operations); + if (!IS_ERR(res)) + res = alloc_file_pseudo(inode, mnt, name, + FMODE_WRITE | FMODE_READ, + &shmem_file_operations); if (IS_ERR(res)) - path_put(&path); + iput(inode); return res; } -- 2.11.0