[PATCH 18/18] VFS: remove dentry_create()

NeilBrown <[email protected]>
Newsgroups gmane.linux.nfs,gmane.linux.file-systems
Message-ID <[email protected]>
From: NeilBrown <neil-+NVA1uvv1dVBDLzU/[email protected]>

dentry_create() is no longer used and can be removed.
vfs_lookup_open() is a better interface.

Signed-off-by: NeilBrown <neil-+NVA1uvv1dVBDLzU/[email protected]>
---
 fs/namei.c         | 80 ----------------------------------------------
 include/linux/fs.h |  2 --
 2 files changed, 82 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index e4f3c0d00c8c..0ccf04056292 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -5067,86 +5067,6 @@ inline struct dentry *start_creating_user_path(
 }
 EXPORT_SYMBOL(start_creating_user_path);
 
-/**
- * dentry_create - Create and open a file
- * @path: path to create
- * @flags: O\_ flags
- * @mode: mode bits for new file
- * @cred: credentials to use
- *
- * Caller must hold the parent directory's lock, and have prepared
- * a negative dentry, placed in @path->dentry, for the new file.
- *
- * Caller sets @path->mnt to the vfsmount of the filesystem where
- * the new file is to be created. The parent directory and the
- * negative dentry must reside on the same filesystem instance.
- *
- * On success, returns a ``struct file *``. Otherwise an ERR_PTR
- * is returned.
- */
-struct file *dentry_create(struct path *path, int flags, umode_t mode,
-			   const struct cred *cred)
-{
-	struct file *file __free(fput) = NULL;
-	struct dentry *dentry = path->dentry;
-	struct dentry *orig_dentry = dentry;
-	struct dentry *dir = dentry->d_parent;
-	struct inode *dir_inode = d_inode(dir);
-	struct mnt_idmap *idmap;
-	int error, create_error;
-
-	file = alloc_empty_file(flags, cred);
-	if (IS_ERR(file))
-		return file;
-
-	idmap = mnt_idmap(path->mnt);
-
-	if (dir_inode->i_op->atomic_open) {
-		path->dentry = dir;
-		mode = vfs_prepare_mode(idmap, dir_inode, mode, S_IALLUGO, S_IFREG);
-
-		create_error = may_o_create(idmap, path, dentry, mode);
-		if (create_error)
-			flags &= ~O_CREAT;
-
-		/* atomic_open will dput(dentry) on error */
-		dget(orig_dentry);
-		dentry = atomic_open(path, dentry, file, flags, mode);
-		error = PTR_ERR_OR_ZERO(dentry);
-
-		if (IS_ERR(dentry))
-			/* keep the original */
-			dentry = orig_dentry;
-		else
-			/* Drop the extra reference */
-			dput(orig_dentry);
-
-		if (unlikely(create_error) && error == -ENOENT)
-			error = create_error;
-
-		if (!error) {
-			if (file->f_mode & FMODE_CREATED)
-				fsnotify_create(dir->d_inode, dentry);
-			if (file->f_mode & FMODE_OPENED)
-				fsnotify_open(file);
-		}
-
-		path->dentry = dentry;
-
-	} else {
-		error = vfs_create(mnt_idmap(path->mnt), path->dentry, mode, NULL);
-		if (!error)
-			error = vfs_open(path, file);
-		if (!error)
-			file->f_mode |= FMODE_CREATED;
-	}
-	if (unlikely(error))
-		return ERR_PTR(error);
-
-	return no_free_ptr(file);
-}
-EXPORT_SYMBOL(dentry_create);
-
 /**
  * vfs_mknod - create device node or file
  * @idmap:		idmap of the mount the inode was found from
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 11559c513dfb..8785302b0ae7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2472,8 +2472,6 @@ struct file *dentry_open(const struct path *path, int flags,
 			 const struct cred *creds);
 struct file *dentry_open_nonotify(const struct path *path, int flags,
 				  const struct cred *cred);
-struct file *dentry_create(struct path *path, int flags, umode_t mode,
-			   const struct cred *cred);
 const struct path *backing_file_user_path(const struct file *f);
 
 #ifdef CONFIG_SECURITY
-- 
2.50.0.107.gf914562f5916.dirty
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.