2013/6/8 Michael Holzheu <holz...@linux.vnet.ibm.com>: <cut> > @@ -225,6 +251,56 @@ static ssize_t read_vmcore(struct file *file, char > __user *buffer, > return acc; > } > > +static ssize_t read_vmcore(struct file *file, char __user *buffer, > + size_t buflen, loff_t *fpos) > +{ > + return __read_vmcore(buffer, buflen, fpos, 1); > +} > + > +/* > + * The vmcore fault handler uses the page cache and fills data using the > + * standard __vmcore_read() function. > + */ > +static int mmap_vmcore_fault(struct vm_area_struct *vma, struct vm_fault > *vmf) > +{ > + struct address_space *mapping = vma->vm_private_data; > + pgoff_t index = vmf->pgoff; > + struct page *page; > + loff_t src; > + char *buf; > + int rc; > + > +find_page: > + page = find_lock_page(mapping, index); > + if (page) { > + unlock_page(page); > + rc = VM_FAULT_MINOR; > + } else { > + page = page_cache_alloc_cold(mapping); > + if (!page) > + return VM_FAULT_OOM; > + rc = add_to_page_cache_lru(page, mapping, index, GFP_KERNEL); > + if (rc) { > + page_cache_release(page); > + if (rc == -EEXIST) > + goto find_page; > + /* Probably ENOMEM for radix tree node */ > + return VM_FAULT_OOM; > + } > + buf = (void *) (page_to_pfn(page) << PAGE_SHIFT); > + src = index << PAGE_CACHE_SHIFT; > + __read_vmcore(buf, PAGE_SIZE, &src, 0); > + unlock_page(page); > + rc = VM_FAULT_MAJOR; > + } > + vmf->page = page; > + return rc; > +}
How about reusing find_or_create_page()? Thanks. HATAYAMA, Daisuke -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/