Skip to contentSkip to conversation

xip: export xip_file_fault

PATCH In review Marco Stornelli 2 participants 3 messages Sep 17, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xip: export xip_file_fault

From: Marco Stornelli <[email protected]>

There aren't sufficient sync points for a fs for xip operations. In particular for the mmap case. It can be not sufficient to lock/unlock to do some operation inside get_xip_mem callback. For xip_file_read it's really easy to write a fs specific wrapper, xip_file_write hold i_mutex so no problem. With this patch it's possible to reuse the generic xip_file_fault, using a wrapper function in a fs, without to reinvent the wheel.

---

mm/filemap_xip.c renamed from mm/filemap_xip.c.orig +2 -1
@@ -218,7 +218,7 @@ retry:
  *
  * This function is derived from filemap_fault, but used for execute in place
  */
-static int xip_file_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+int xip_file_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	struct file *file = vma->vm_file;
 	struct address_space *mapping = file->f_mapping;
@@ -296,6 +296,7 @@ out:
 		return ret;
 	}
 }
+EXPORT_SYMBOL_GPL(xip_file_fault);
 
 static const struct vm_operations_struct xip_file_vm_ops = {
 	.fault	= xip_file_fault,
include/linux/fs.h renamed from include/linux/fs.h.orig +2 -0
@@ -409,6 +409,7 @@ struct pipe_inode_info;
 struct poll_table_struct;
 struct kstatfs;
 struct vm_area_struct;
+struct vm_fault;
 struct vfsmount;
 struct cred;
 
@@ -2403,6 +2404,7 @@ extern int nonseekable_open(struct inode
 extern ssize_t xip_file_read(struct file *filp, char __user *buf, size_t len,
 			     loff_t *ppos);
 extern int xip_file_mmap(struct file * file, struct vm_area_struct * vma);
+extern int xip_file_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 extern ssize_t xip_file_write(struct file *filp, const char __user *buf,
 			      size_t len, loff_t *ppos);
 extern int xip_truncate_page(struct address_space *mapping, loff_t from);
#1 lore raw
Quoted 9 lines · Marco Stornelli

From: Marco Stornelli <[email protected]>

There aren't sufficient sync points for a fs for xip operations. In particular for the mmap case. It can be not sufficient to lock/unlock to do some operation inside get_xip_mem callback. For xip_file_read it's really easy to write a fs specific wrapper, xip_file_write hold i_mutex so no problem. With this patch it's possible to reuse the generic xip_file_fault, using a wrapper function in a fs, without to reinvent the wheel.

As usual please send patches to add exports only while adding callers for it.

#2 lore raw

Il 17/09/2011 15:53, Christoph Hellwig ha scritto:

Quoted 11 lines · Marco Stornelli
Quoted 9 lines

From: Marco Stornelli<[email protected]>

There aren't sufficient sync points for a fs for xip operations. In particular for the mmap case. It can be not sufficient to lock/unlock to do some operation inside get_xip_mem callback. For xip_file_read it's really easy to write a fs specific wrapper, xip_file_write hold i_mutex so no problem. With this patch it's possible to reuse the generic xip_file_fault, using a wrapper function in a fs, without to reinvent the wheel.

Quoted 4 lines

As usual please send patches to add exports only while adding callers for it.

Actually the module is not currently in mainline even if I hope soon. No problem. I'll resend it at the right moment.

Marco