diff options
author | Matthew Auld <matthew.auld@intel.com> | 2017-10-06 18:18:13 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-10-07 05:11:40 -0400 |
commit | 703321b60b605b1f381f5dcf0bca42703b912e3e (patch) | |
tree | 1023e345ff2f92a5071f99babef8a5a77abbdc4a /mm | |
parent | 279f5a00c9a9b39f4f6e9813e6d4da8c181d34c8 (diff) |
mm/shmem: introduce shmem_file_setup_with_mnt
We are planning to use our own tmpfs mnt in i915 in place of the
shm_mnt, such that we can control the mount options, in particular
huge=, which we require to support huge-gtt-pages. So rather than roll
our own version of __shmem_file_setup, it would be preferred if we could
just give shmem our mnt, and let it do the rest.
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Hugh Dickins <hughd@google.com>
Cc: linux-mm@kvack.org
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171006145041.21673-2-matthew.auld@intel.com
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20171006221833.32439-1-chris@chris-wilson.co.uk
Diffstat (limited to 'mm')
-rw-r--r-- | mm/shmem.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 07a1d22807be..3229d27503ec 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -4183,7 +4183,7 @@ static const struct dentry_operations anon_ops = { | |||
4183 | .d_dname = simple_dname | 4183 | .d_dname = simple_dname |
4184 | }; | 4184 | }; |
4185 | 4185 | ||
4186 | static struct file *__shmem_file_setup(const char *name, loff_t size, | 4186 | static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, loff_t size, |
4187 | unsigned long flags, unsigned int i_flags) | 4187 | unsigned long flags, unsigned int i_flags) |
4188 | { | 4188 | { |
4189 | struct file *res; | 4189 | struct file *res; |
@@ -4192,8 +4192,8 @@ static struct file *__shmem_file_setup(const char *name, loff_t size, | |||
4192 | struct super_block *sb; | 4192 | struct super_block *sb; |
4193 | struct qstr this; | 4193 | struct qstr this; |
4194 | 4194 | ||
4195 | if (IS_ERR(shm_mnt)) | 4195 | if (IS_ERR(mnt)) |
4196 | return ERR_CAST(shm_mnt); | 4196 | return ERR_CAST(mnt); |
4197 | 4197 | ||
4198 | if (size < 0 || size > MAX_LFS_FILESIZE) | 4198 | if (size < 0 || size > MAX_LFS_FILESIZE) |
4199 | return ERR_PTR(-EINVAL); | 4199 | return ERR_PTR(-EINVAL); |
@@ -4205,8 +4205,8 @@ static struct file *__shmem_file_setup(const char *name, loff_t size, | |||
4205 | this.name = name; | 4205 | this.name = name; |
4206 | this.len = strlen(name); | 4206 | this.len = strlen(name); |
4207 | this.hash = 0; /* will go */ | 4207 | this.hash = 0; /* will go */ |
4208 | sb = shm_mnt->mnt_sb; | 4208 | sb = mnt->mnt_sb; |
4209 | path.mnt = mntget(shm_mnt); | 4209 | path.mnt = mntget(mnt); |
4210 | path.dentry = d_alloc_pseudo(sb, &this); | 4210 | path.dentry = d_alloc_pseudo(sb, &this); |
4211 | if (!path.dentry) | 4211 | if (!path.dentry) |
4212 | goto put_memory; | 4212 | goto put_memory; |
@@ -4251,7 +4251,7 @@ put_path: | |||
4251 | */ | 4251 | */ |
4252 | struct file *shmem_kernel_file_setup(const char *name, loff_t size, unsigned long flags) | 4252 | struct file *shmem_kernel_file_setup(const char *name, loff_t size, unsigned long flags) |
4253 | { | 4253 | { |
4254 | return __shmem_file_setup(name, size, flags, S_PRIVATE); | 4254 | return __shmem_file_setup(shm_mnt, name, size, flags, S_PRIVATE); |
4255 | } | 4255 | } |
4256 | 4256 | ||
4257 | /** | 4257 | /** |
@@ -4262,11 +4262,25 @@ struct file *shmem_kernel_file_setup(const char *name, loff_t size, unsigned lon | |||
4262 | */ | 4262 | */ |
4263 | struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags) | 4263 | struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags) |
4264 | { | 4264 | { |
4265 | return __shmem_file_setup(name, size, flags, 0); | 4265 | return __shmem_file_setup(shm_mnt, name, size, flags, 0); |
4266 | } | 4266 | } |
4267 | EXPORT_SYMBOL_GPL(shmem_file_setup); | 4267 | EXPORT_SYMBOL_GPL(shmem_file_setup); |
4268 | 4268 | ||
4269 | /** | 4269 | /** |
4270 | * shmem_file_setup_with_mnt - get an unlinked file living in tmpfs | ||
4271 | * @mnt: the tmpfs mount where the file will be created | ||
4272 | * @name: name for dentry (to be seen in /proc/<pid>/maps | ||
4273 | * @size: size to be set for the file | ||
4274 | * @flags: VM_NORESERVE suppresses pre-accounting of the entire object size | ||
4275 | */ | ||
4276 | struct file *shmem_file_setup_with_mnt(struct vfsmount *mnt, const char *name, | ||
4277 | loff_t size, unsigned long flags) | ||
4278 | { | ||
4279 | return __shmem_file_setup(mnt, name, size, flags, 0); | ||
4280 | } | ||
4281 | EXPORT_SYMBOL_GPL(shmem_file_setup_with_mnt); | ||
4282 | |||
4283 | /** | ||
4270 | * shmem_zero_setup - setup a shared anonymous mapping | 4284 | * shmem_zero_setup - setup a shared anonymous mapping |
4271 | * @vma: the vma to be mmapped is prepared by do_mmap_pgoff | 4285 | * @vma: the vma to be mmapped is prepared by do_mmap_pgoff |
4272 | */ | 4286 | */ |
@@ -4281,7 +4295,7 @@ int shmem_zero_setup(struct vm_area_struct *vma) | |||
4281 | * accessible to the user through its mapping, use S_PRIVATE flag to | 4295 | * accessible to the user through its mapping, use S_PRIVATE flag to |
4282 | * bypass file security, in the same way as shmem_kernel_file_setup(). | 4296 | * bypass file security, in the same way as shmem_kernel_file_setup(). |
4283 | */ | 4297 | */ |
4284 | file = __shmem_file_setup("dev/zero", size, vma->vm_flags, S_PRIVATE); | 4298 | file = shmem_kernel_file_setup("dev/zero", size, vma->vm_flags); |
4285 | if (IS_ERR(file)) | 4299 | if (IS_ERR(file)) |
4286 | return PTR_ERR(file); | 4300 | return PTR_ERR(file); |
4287 | 4301 | ||