Skip to content

Commit d56e0dd

Browse files
amir73ilbrauner
authored andcommitted
fs: rename {vfs,kernel}_tmpfile_open()
Overlayfs and cachefiles use vfs_open_tmpfile() to open a tmpfile without accounting for nr_files. Rename this helper to kernel_tmpfile_open() to better reflect this helper is used for kernel internal users. Signed-off-by: Amir Goldstein <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Message-Id: <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent f1fcbaa commit d56e0dd

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

fs/cachefiles/namei.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object)
451451

452452
ret = cachefiles_inject_write_error();
453453
if (ret == 0) {
454-
file = vfs_tmpfile_open(&nop_mnt_idmap, &parentpath, S_IFREG,
455-
O_RDWR | O_LARGEFILE | O_DIRECT,
456-
cache->cache_cred);
454+
file = kernel_tmpfile_open(&nop_mnt_idmap, &parentpath, S_IFREG,
455+
O_RDWR | O_LARGEFILE | O_DIRECT,
456+
cache->cache_cred);
457457
ret = PTR_ERR_OR_ZERO(file);
458458
}
459459
if (ret) {

fs/namei.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,7 +3703,7 @@ static int vfs_tmpfile(struct mnt_idmap *idmap,
37033703
}
37043704

37053705
/**
3706-
* vfs_tmpfile_open - open a tmpfile for kernel internal use
3706+
* kernel_tmpfile_open - open a tmpfile for kernel internal use
37073707
* @idmap: idmap of the mount the inode was found from
37083708
* @parentpath: path of the base directory
37093709
* @mode: mode of the new tmpfile
@@ -3714,24 +3714,26 @@ static int vfs_tmpfile(struct mnt_idmap *idmap,
37143714
* hence this is only for kernel internal use, and must not be installed into
37153715
* file tables or such.
37163716
*/
3717-
struct file *vfs_tmpfile_open(struct mnt_idmap *idmap,
3718-
const struct path *parentpath,
3719-
umode_t mode, int open_flag, const struct cred *cred)
3717+
struct file *kernel_tmpfile_open(struct mnt_idmap *idmap,
3718+
const struct path *parentpath,
3719+
umode_t mode, int open_flag,
3720+
const struct cred *cred)
37203721
{
37213722
struct file *file;
37223723
int error;
37233724

37243725
file = alloc_empty_file_noaccount(open_flag, cred);
3725-
if (!IS_ERR(file)) {
3726-
error = vfs_tmpfile(idmap, parentpath, file, mode);
3727-
if (error) {
3728-
fput(file);
3729-
file = ERR_PTR(error);
3730-
}
3726+
if (IS_ERR(file))
3727+
return file;
3728+
3729+
error = vfs_tmpfile(idmap, parentpath, file, mode);
3730+
if (error) {
3731+
fput(file);
3732+
file = ERR_PTR(error);
37313733
}
37323734
return file;
37333735
}
3734-
EXPORT_SYMBOL(vfs_tmpfile_open);
3736+
EXPORT_SYMBOL(kernel_tmpfile_open);
37353737

37363738
static int do_tmpfile(struct nameidata *nd, unsigned flags,
37373739
const struct open_flags *op,

fs/overlayfs/overlayfs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,9 @@ static inline struct file *ovl_do_tmpfile(struct ovl_fs *ofs,
329329
struct dentry *dentry, umode_t mode)
330330
{
331331
struct path path = { .mnt = ovl_upper_mnt(ofs), .dentry = dentry };
332-
struct file *file = vfs_tmpfile_open(ovl_upper_mnt_idmap(ofs), &path, mode,
333-
O_LARGEFILE | O_WRONLY, current_cred());
332+
struct file *file = kernel_tmpfile_open(ovl_upper_mnt_idmap(ofs), &path,
333+
mode, O_LARGEFILE | O_WRONLY,
334+
current_cred());
334335
int err = PTR_ERR_OR_ZERO(file);
335336

336337
pr_debug("tmpfile(%pd2, 0%o) = %i\n", dentry, mode, err);

include/linux/fs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,9 +1672,10 @@ static inline int vfs_whiteout(struct mnt_idmap *idmap,
16721672
WHITEOUT_DEV);
16731673
}
16741674

1675-
struct file *vfs_tmpfile_open(struct mnt_idmap *idmap,
1676-
const struct path *parentpath,
1677-
umode_t mode, int open_flag, const struct cred *cred);
1675+
struct file *kernel_tmpfile_open(struct mnt_idmap *idmap,
1676+
const struct path *parentpath,
1677+
umode_t mode, int open_flag,
1678+
const struct cred *cred);
16781679

16791680
int vfs_mkobj(struct dentry *, umode_t,
16801681
int (*f)(struct dentry *, umode_t, void *),

0 commit comments

Comments
 (0)