The patch titled Subject: hugetlbfs: add O_TMPFILE support has been added to the -mm tree. Its filename is hugetlbfs-add-o_tmpfile-support.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/hugetlbfs-add-o_tmpfile-support.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/hugetlbfs-add-o_tmpfile-support.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Piotr Sarna <p.sarna@xxxxxxx> Subject: hugetlbfs: add O_TMPFILE support O_TMPFILE is an option used to create an unnamed temporary regular file. Currently, libhugetlbfs and Seastar use a combination of mkstemp and unlink to accomplish similar functionality on hugetlbfs. Add O_TMPFILE support to hugetlbfs so that it can potentially be used by existing users (Seastar) and new users (Oracle DB). Support is added by simply using the d_tmpfile utility function to instantiate the dcache entry for a temporary file. Tested manually by successfully creating a temporary file by opening it with (O_TMPFILE|O_RDWR) on mounted hugetlbfs and successfully mapping 2M huge pages with it. Without the patch, trying to open a file with O_TMPFILE results in -ENOSUP. [mike.kravetz@xxxxxxxxxx: changelog updates] Link: http://lkml.kernel.org/r/22c29acf9c51dae17802e1b05c9e5e4051448c5c.1571129593.git.p.sarna@xxxxxxx Signed-off-by: Piotr Sarna <p.sarna@xxxxxxx> Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/hugetlbfs/inode.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) --- a/fs/hugetlbfs/inode.c~hugetlbfs-add-o_tmpfile-support +++ a/fs/hugetlbfs/inode.c @@ -815,8 +815,11 @@ static struct inode *hugetlbfs_get_inode /* * File creation. Allocate an inode, and we're done.. */ -static int hugetlbfs_mknod(struct inode *dir, - struct dentry *dentry, umode_t mode, dev_t dev) +static int do_hugetlbfs_mknod(struct inode *dir, + struct dentry *dentry, + umode_t mode, + dev_t dev, + bool tmpfile) { struct inode *inode; int error = -ENOSPC; @@ -824,13 +827,22 @@ static int hugetlbfs_mknod(struct inode inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev); if (inode) { dir->i_ctime = dir->i_mtime = current_time(dir); - d_instantiate(dentry, inode); + if (tmpfile) + d_tmpfile(dentry, inode); + else + d_instantiate(dentry, inode); dget(dentry); /* Extra count - pin the dentry in core */ error = 0; } return error; } +static int hugetlbfs_mknod(struct inode *dir, + struct dentry *dentry, umode_t mode, dev_t dev) +{ + return do_hugetlbfs_mknod(dir, dentry, mode, dev, false); +} + static int hugetlbfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { int retval = hugetlbfs_mknod(dir, dentry, mode | S_IFDIR, 0); @@ -844,6 +856,12 @@ static int hugetlbfs_create(struct inode return hugetlbfs_mknod(dir, dentry, mode | S_IFREG, 0); } +static int hugetlbfs_tmpfile(struct inode *dir, + struct dentry *dentry, umode_t mode) +{ + return do_hugetlbfs_mknod(dir, dentry, mode | S_IFREG, 0, true); +} + static int hugetlbfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) { @@ -1102,6 +1120,7 @@ static const struct inode_operations hug .mknod = hugetlbfs_mknod, .rename = simple_rename, .setattr = hugetlbfs_setattr, + .tmpfile = hugetlbfs_tmpfile, }; static const struct inode_operations hugetlbfs_inode_operations = { _ Patches currently in -mm which might be from p.sarna@xxxxxxx are hugetlbfs-add-o_tmpfile-support.patch