aboutsummaryrefslogtreecommitdiff
path: root/ipc/shm.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-11 12:23:29 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-11 12:23:29 -0800
commitaad3bf04dca5a2147a8406f7aef5703ee5259a52 (patch)
tree558d5915ddceab6bb47ed844dea9386c6036d087 /ipc/shm.c
parent11bd04f6f35621193311c32e0721142b073a7794 (diff)
parentaa65607373a4daf2010e8c3867b6317619f3c1a3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/viro/mmap
* git://git.kernel.org/pub/scm/linux/kernel/git/viro/mmap: Add missing alignment check in arch/score sys_mmap() fix broken aliasing checks for MAP_FIXED on sparc32, mips, arm and sh Get rid of open-coding in ia64_brk() sparc_brk() is not needed anymore switch do_brk() to get_unmapped_area() Take arch_mmap_check() into get_unmapped_area() fix a struct file leak in do_mmap_pgoff() Unify sys_mmap* Cut hugetlb case early for 32bit on ia64 arch_mmap_check() on mn10300 Kill ancient crap in s390 compat mmap arm: add arch_mmap_check(), get rid of sys_arm_mremap() file ->get_unmapped_area() shouldn't duplicate work of get_unmapped_area() kill useless checks in sparc mremap variants fix pgoff in "have to relocate" case of mremap() fix the arch checks in MREMAP_FIXED case fix checks for expand-in-place mremap do_mremap() untangling, part 3 do_mremap() untangling, part 2 untangling do_mremap(), part 1
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 464694e0aa4..11bec626c22 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -290,28 +290,28 @@ static unsigned long shm_get_unmapped_area(struct file *file,
unsigned long flags)
{
struct shm_file_data *sfd = shm_file_data(file);
- return get_unmapped_area(sfd->file, addr, len, pgoff, flags);
-}
-
-int is_file_shm_hugepages(struct file *file)
-{
- int ret = 0;
-
- if (file->f_op == &shm_file_operations) {
- struct shm_file_data *sfd;
- sfd = shm_file_data(file);
- ret = is_file_hugepages(sfd->file);
- }
- return ret;
+ return sfd->file->f_op->get_unmapped_area(sfd->file, addr, len,
+ pgoff, flags);
}
static const struct file_operations shm_file_operations = {
.mmap = shm_mmap,
.fsync = shm_fsync,
.release = shm_release,
+};
+
+static const struct file_operations shm_file_operations_huge = {
+ .mmap = shm_mmap,
+ .fsync = shm_fsync,
+ .release = shm_release,
.get_unmapped_area = shm_get_unmapped_area,
};
+int is_file_shm_hugepages(struct file *file)
+{
+ return file->f_op == &shm_file_operations_huge;
+}
+
static const struct vm_operations_struct shm_vm_ops = {
.open = shm_open, /* callback for a new vm-area open */
.close = shm_close, /* callback for when the vm-area is released */
@@ -889,7 +889,10 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
if (!sfd)
goto out_put_dentry;
- file = alloc_file(path.mnt, path.dentry, f_mode, &shm_file_operations);
+ file = alloc_file(path.mnt, path.dentry, f_mode,
+ is_file_hugepages(shp->shm_file) ?
+ &shm_file_operations_huge :
+ &shm_file_operations);
if (!file)
goto out_free;
ima_counts_get(file);