Re: [PATCH] cache large files in the page cache

Andrea Arcangeli (andrea@suse.de)
Mon, 24 May 1999 17:27:20 +0200 (CEST)


On 23 May 1999, Eric W. Biederman wrote:

>diff -uNrX /home/eric/projects/linux/linux-ignore-files linux-2.3.3.eb4/drivers/sgi/char/graphics.c linux-2.3.3.eb5/drivers/sgi/char/graphics.c
>--- linux-2.3.3.eb4/drivers/sgi/char/graphics.c Sun Oct 11 13:15:06 1998
>+++ linux-2.3.3.eb5/drivers/sgi/char/graphics.c Sat May 22 17:16:53 1999
>@@ -237,12 +237,20 @@
> };
>
> int
>-sgi_graphics_mmap (struct inode *inode, struct file *file, struct vm_area_struct *vma)
>+sgi_graphics_mmap (struct inode *inode, struct file *file, struct vm_area_struct *vma,
>+ loff_t offset)
> {
> uint size;
>+ unsigned long vm_offset;
>+
>+ if (offset > PAGE_MAX_MEMORY_OFFSET) {
>+ return -EINVAL;
>+ }
>+ vm_offset = offset;
>+ vma->vm_index = vm_offset >> PAGE_SHIFT;
>
> size = vma->vm_end - vma->vm_start;
>- if (vma->vm_offset & ~PAGE_MASK)
>+ if (vm_offset & ~PAGE_MASK)
> return -ENXIO;
>
> /* 1. Set our special graphic virtualizer */
>@@ -252,7 +260,8 @@
> vma->vm_page_prot = PAGE_USERIO;
>
> /* final setup */
>- vma->vm_dentry = dget (file->f_dentry);
>+ vma->vm_file = file;
>+ file->f_count++;
> return 0;

vm_file a and f_count should be just handled by do_mmap().

>@@ -365,8 +370,8 @@
> > (unsigned long) current->rlim[RLIMIT_AS].rlim_cur)
> return -ENOMEM;
> vma->vm_start = address;
>- vma->vm_offset -= grow;
>- vma->vm_mm->total_vm += grow >> PAGE_SHIFT;
>+ vma->vm_index -= grow >> PAGE_SHIFT;
>+ vma->vm_mm->total_vm += grow;
^^^^
grow should still be shifted right of PAGE_SHIFT I think.

I have not understood why PAGE_MAX_MEMORY_OFFSET & PAGE_MAX_FILE_OFFSET
are useful. We should check against too large offset or too high mmap in
the standard code, no? Maybe the offset limit is to forbid somebody to
create a too much large file even if the fs would permit? I am not sure if
it will be useful, at least if it's choosen at compile time and it's not a
sysctl.

Andrea Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/