aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ncpfs
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-07-19 04:47:03 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:41 -0400
commitd0217ac04ca6591841e5665f518e38064f4e65bd (patch)
treed3309094bb734d34773f97d642593e298a5cfcfc /fs/ncpfs
parented2f2f9b3ff8debdf512f7687b232c3c1d7d60d7 (diff)
mm: fault feedback #1
Change ->fault prototype. We now return an int, which contains VM_FAULT_xxx code in the low byte, and FAULT_RET_xxx code in the next byte. FAULT_RET_ code tells the VM whether a page was found, whether it has been locked, and potentially other things. This is not quite the way he wanted it yet, but that's changed in the next patch (which requires changes to arch code). This means we no longer set VM_CAN_INVALIDATE in the vma in order to say that a page is locked which requires filemap_nopage to go away (because we can no longer remain backward compatible without that flag), but we were going to do that anyway. struct fault_data is renamed to struct vm_fault as Linus asked. address is now a void __user * that we should firmly encourage drivers not to use without really good reason. The page is now returned via a page pointer in the vm_fault struct. Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ncpfs')
-rw-r--r--fs/ncpfs/mmap.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/fs/ncpfs/mmap.c b/fs/ncpfs/mmap.c
index af48b792ca04..a94473d3072c 100644
--- a/fs/ncpfs/mmap.c
+++ b/fs/ncpfs/mmap.c
@@ -24,33 +24,35 @@
24 24
25/* 25/*
26 * Fill in the supplied page for mmap 26 * Fill in the supplied page for mmap
27 * XXX: how are we excluding truncate/invalidate here? Maybe need to lock
28 * page?
27 */ 29 */
28static struct page* ncp_file_mmap_fault(struct vm_area_struct *area, 30static int ncp_file_mmap_fault(struct vm_area_struct *area,
29 struct fault_data *fdata) 31 struct vm_fault *vmf)
30{ 32{
31 struct file *file = area->vm_file; 33 struct file *file = area->vm_file;
32 struct dentry *dentry = file->f_path.dentry; 34 struct dentry *dentry = file->f_path.dentry;
33 struct inode *inode = dentry->d_inode; 35 struct inode *inode = dentry->d_inode;
34 struct page* page;
35 char *pg_addr; 36 char *pg_addr;
36 unsigned int already_read; 37 unsigned int already_read;
37 unsigned int count; 38 unsigned int count;
38 int bufsize; 39 int bufsize;
39 int pos; 40 int pos; /* XXX: loff_t ? */
40 41
41 page = alloc_page(GFP_HIGHUSER); /* ncpfs has nothing against high pages 42 /*
42 as long as recvmsg and memset works on it */ 43 * ncpfs has nothing against high pages as long
43 if (!page) { 44 * as recvmsg and memset works on it
44 fdata->type = VM_FAULT_OOM; 45 */
45 return NULL; 46 vmf->page = alloc_page(GFP_HIGHUSER);
46 } 47 if (!vmf->page)
47 pg_addr = kmap(page); 48 return VM_FAULT_OOM;
48 pos = fdata->pgoff << PAGE_SHIFT; 49 pg_addr = kmap(vmf->page);
50 pos = vmf->pgoff << PAGE_SHIFT;
49 51
50 count = PAGE_SIZE; 52 count = PAGE_SIZE;
51 if (fdata->address + PAGE_SIZE > area->vm_end) { 53 if ((unsigned long)vmf->virtual_address + PAGE_SIZE > area->vm_end) {
52 WARN_ON(1); /* shouldn't happen? */ 54 WARN_ON(1); /* shouldn't happen? */
53 count = area->vm_end - fdata->address; 55 count = area->vm_end - (unsigned long)vmf->virtual_address;
54 } 56 }
55 /* what we can read in one go */ 57 /* what we can read in one go */
56 bufsize = NCP_SERVER(inode)->buffer_size; 58 bufsize = NCP_SERVER(inode)->buffer_size;
@@ -85,17 +87,16 @@ static struct page* ncp_file_mmap_fault(struct vm_area_struct *area,
85 87
86 if (already_read < PAGE_SIZE) 88 if (already_read < PAGE_SIZE)
87 memset(pg_addr + already_read, 0, PAGE_SIZE - already_read); 89 memset(pg_addr + already_read, 0, PAGE_SIZE - already_read);
88 flush_dcache_page(page); 90 flush_dcache_page(vmf->page);
89 kunmap(page); 91 kunmap(vmf->page);
90 92
91 /* 93 /*
92 * If I understand ncp_read_kernel() properly, the above always 94 * If I understand ncp_read_kernel() properly, the above always
93 * fetches from the network, here the analogue of disk. 95 * fetches from the network, here the analogue of disk.
94 * -- wli 96 * -- wli
95 */ 97 */
96 fdata->type = VM_FAULT_MAJOR;
97 count_vm_event(PGMAJFAULT); 98 count_vm_event(PGMAJFAULT);
98 return page; 99 return VM_FAULT_MAJOR;
99} 100}
100 101
101static struct vm_operations_struct ncp_file_mmap = 102static struct vm_operations_struct ncp_file_mmap =
@@ -124,7 +125,6 @@ int ncp_mmap(struct file *file, struct vm_area_struct *vma)
124 return -EFBIG; 125 return -EFBIG;
125 126
126 vma->vm_ops = &ncp_file_mmap; 127 vma->vm_ops = &ncp_file_mmap;
127 vma->vm_flags |= VM_CAN_INVALIDATE;
128 file_accessed(file); 128 file_accessed(file);
129 return 0; 129 return 0;
130} 130}