aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-11-30 08:38:43 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-11 06:34:09 -0500
commitc4caa778157dbbf04116f0ac2111e389b5cd7a29 (patch)
treed8e26c07bacaaa6b1e6b1e57816fd42da94e15f4 /ipc
parent0ec62d290912bb4b989be7563851bc364ec73b56 (diff)
file ->get_unmapped_area() shouldn't duplicate work of get_unmapped_area()
... we should call mm ->get_unmapped_area() instead and let our caller do the final checks. Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/shm.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 464694e0aa4a..11bec626c228 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -290,28 +290,28 @@ static unsigned long shm_get_unmapped_area(struct file *file,
290 unsigned long flags) 290 unsigned long flags)
291{ 291{
292 struct shm_file_data *sfd = shm_file_data(file); 292 struct shm_file_data *sfd = shm_file_data(file);
293 return get_unmapped_area(sfd->file, addr, len, pgoff, flags); 293 return sfd->file->f_op->get_unmapped_area(sfd->file, addr, len,
294} 294 pgoff, flags);
295
296int is_file_shm_hugepages(struct file *file)
297{
298 int ret = 0;
299
300 if (file->f_op == &shm_file_operations) {
301 struct shm_file_data *sfd;
302 sfd = shm_file_data(file);
303 ret = is_file_hugepages(sfd->file);
304 }
305 return ret;
306} 295}
307 296
308static const struct file_operations shm_file_operations = { 297static const struct file_operations shm_file_operations = {
309 .mmap = shm_mmap, 298 .mmap = shm_mmap,
310 .fsync = shm_fsync, 299 .fsync = shm_fsync,
311 .release = shm_release, 300 .release = shm_release,
301};
302
303static const struct file_operations shm_file_operations_huge = {
304 .mmap = shm_mmap,
305 .fsync = shm_fsync,
306 .release = shm_release,
312 .get_unmapped_area = shm_get_unmapped_area, 307 .get_unmapped_area = shm_get_unmapped_area,
313}; 308};
314 309
310int is_file_shm_hugepages(struct file *file)
311{
312 return file->f_op == &shm_file_operations_huge;
313}
314
315static const struct vm_operations_struct shm_vm_ops = { 315static const struct vm_operations_struct shm_vm_ops = {
316 .open = shm_open, /* callback for a new vm-area open */ 316 .open = shm_open, /* callback for a new vm-area open */
317 .close = shm_close, /* callback for when the vm-area is released */ 317 .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)
889 if (!sfd) 889 if (!sfd)
890 goto out_put_dentry; 890 goto out_put_dentry;
891 891
892 file = alloc_file(path.mnt, path.dentry, f_mode, &shm_file_operations); 892 file = alloc_file(path.mnt, path.dentry, f_mode,
893 is_file_hugepages(shp->shm_file) ?
894 &shm_file_operations_huge :
895 &shm_file_operations);
893 if (!file) 896 if (!file)
894 goto out_free; 897 goto out_free;
895 ima_counts_get(file); 898 ima_counts_get(file);