Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2365706imm; Tue, 10 Jul 2018 19:25:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpelx+hgUZy8z4pBr9iGKgx7qvO9oWSSTztwCWCejwOOMABmB1xIz5HFcBz+FVXl1gwoOSdr X-Received: by 2002:a62:b0c:: with SMTP id t12-v6mr5366376pfi.36.1531275906034; Tue, 10 Jul 2018 19:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531275906; cv=none; d=google.com; s=arc-20160816; b=c8Ht1ikBAIrQ2DjIyXXqcn2U1WPaT3ilM9hE9qWeXqRNlkfpwQF1oOg/45xTBUsZbo AQhhG77x8dQPs3K1PXWWFDqMhoTc0jf0wAeXz7k2ZRuWng/AlEZPtP/EjILrkkQ5qQCj i4+Has2bUGQURLf9JwTHLhGZtBNMKbl/cu+4QQ3YjITktqV/z26gb6+jAPKCqflgGE++ 4IkzJ58JxNuAPUyJr9IK6xtJ/vFqpbsfwvQDMVIG1m7SJTBYswe/xvrjqzkhuhB7MCrD jpUK8miwU6+M15StygSSDN6KecjI8Ix94+S5p7e3h7Vtjj6FZ+rMXxLh1omziQpNPTwB gNcA== 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=48kqqzksLyB4LQjZYbiCetwUZP+7t0wjlIQuzEl2rwE=; b=lMBJLK1e8mPJlc5cBhRBP7NC/RKdwTHgdwKvjbWB8+la4QXrEwPPU+T7S5wZc97TlE jyFmDrSdAHTGX5viXqHWqlQUjTtMRdFcS/hSzkBBFWz4s8RBmtdc6aaIbz54Mr5Gw3bp B8aYSeikiPa93OcsJtvRjAdwjFFP2s4/tUsxef8wbVDXf+yN3M8ub8ObB8CESH0pajNd fDfD9yPRhOgTZChSfVS76TYkSQxBuBAa61GyEYkBDbdWmF2Ks6L6WmneASUYBnR+R/O5 XAdeyCG4jI0eIVPpaCj5mVVYRzsNLvCcfghrNjDQm1vfpufz+4VlgjThFAzzUOF4BT/d T3Gg== 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 u9-v6si19657421pfg.62.2018.07.10.19.24.50; Tue, 10 Jul 2018 19:25:06 -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 S1732630AbeGKCYI (ORCPT + 99 others); Tue, 10 Jul 2018 22:24:08 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45686 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732550AbeGKCYH (ORCPT ); Tue, 10 Jul 2018 22:24:07 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fd4le-0003L0-5U; Wed, 11 Jul 2018 02:22:10 +0000 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Miklos Szeredi Subject: [RFC][PATCH 33/42] hugetlb_file_setup(): switch to alloc_file_pseudo() Date: Wed, 11 Jul 2018 03:21:57 +0100 Message-Id: <20180711022206.12571-33-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 --- fs/hugetlbfs/inode.c | 55 ++++++++++++++++------------------------------------ 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index d508c7844681..86ffe04f73d6 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1308,10 +1308,6 @@ static int get_hstate_idx(int page_size_log) return h - hstates; } -static const struct dentry_operations anon_ops = { - .d_dname = simple_dname -}; - /* * Note that size should be aligned to proper hugepage size in caller side, * otherwise hugetlb_reserve_pages reserves one less hugepages than intended. @@ -1320,19 +1316,18 @@ struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag, struct user_struct **user, int creat_flags, int page_size_log) { - struct file *file = ERR_PTR(-ENOMEM); struct inode *inode; - struct path path; - struct super_block *sb; - struct qstr quick_string; + struct vfsmount *mnt; int hstate_idx; + struct file *file; hstate_idx = get_hstate_idx(page_size_log); if (hstate_idx < 0) return ERR_PTR(-ENODEV); *user = NULL; - if (!hugetlbfs_vfsmount[hstate_idx]) + mnt = hugetlbfs_vfsmount[hstate_idx]; + if (!mnt) return ERR_PTR(-ENOENT); if (creat_flags == HUGETLB_SHMFS_INODE && !can_do_hugetlb_shm()) { @@ -1348,45 +1343,29 @@ struct file *hugetlb_file_setup(const char *name, size_t size, } } - sb = hugetlbfs_vfsmount[hstate_idx]->mnt_sb; - quick_string.name = name; - quick_string.len = strlen(quick_string.name); - quick_string.hash = 0; - path.dentry = d_alloc_pseudo(sb, &quick_string); - if (!path.dentry) - goto out_shm_unlock; - - d_set_d_op(path.dentry, &anon_ops); - path.mnt = mntget(hugetlbfs_vfsmount[hstate_idx]); file = ERR_PTR(-ENOSPC); - inode = hugetlbfs_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0); + inode = hugetlbfs_get_inode(mnt->mnt_sb, NULL, S_IFREG | S_IRWXUGO, 0); if (!inode) - goto out_dentry; + goto out; if (creat_flags == HUGETLB_SHMFS_INODE) inode->i_flags |= S_PRIVATE; - file = ERR_PTR(-ENOMEM); - if (hugetlb_reserve_pages(inode, 0, - size >> huge_page_shift(hstate_inode(inode)), NULL, - acctflag)) - goto out_inode; - - d_instantiate(path.dentry, inode); inode->i_size = size; clear_nlink(inode); - file = alloc_file(&path, FMODE_WRITE | FMODE_READ, - &hugetlbfs_file_operations); - if (IS_ERR(file)) - goto out_dentry; /* inode is already attached */ - - return file; + if (hugetlb_reserve_pages(inode, 0, + size >> huge_page_shift(hstate_inode(inode)), NULL, + acctflag)) + file = ERR_PTR(-ENOMEM); + else + file = alloc_file_pseudo(inode, mnt, name, + FMODE_WRITE | FMODE_READ, + &hugetlbfs_file_operations); + if (!IS_ERR(file)) + return file; -out_inode: iput(inode); -out_dentry: - path_put(&path); -out_shm_unlock: +out: if (*user) { user_shm_unlock(size, *user); *user = NULL; -- 2.11.0