Skip to contentSkip to conversation

file_operations belong to file.c

PATCH New Christoph Hellwig 1 participant 1 message Jun 20, 2004 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 file_operations belong to file.c

allows lots of function to become static in there. The only problem is the 2.4 aio support which uses file operations for what should be address_space operations. They're misplaced in both inode.c and file.c so they'll get a file of their own one day.

inode.c +11 -44
Index: src/inode.c
===================================================================
@@ -41,12 +41,10 @@
 #include "ocfs.h"
 
 #include "alloc.h"
-#include "dir.h"
 #include "dlm.h"
 #include "extmap.h"
 #include "file.h"
 #include "inode.h"
-#include "ioctl.h"
 #include "lockres.h"
 #include "namei.h"
 #include "super.h"
@@ -106,12 +104,6 @@
 #endif
 #endif
 
-#ifdef AIO_ENABLED
-int ocfs_kvec_read(struct file *file, kvec_cb_t cb, size_t size, loff_t pos); 
-int ocfs_kvec_write(struct file *file, kvec_cb_t cb, size_t size, loff_t pos); 
-int ocfs_kvec_rw(struct file *filp, int rw, kvec_cb_t cb, size_t size, loff_t pos);
-#endif /* AIO_ENABLED */
-
 static void __ocfs_read_inode2(struct inode *inode, 
 			       ocfs_find_inode_args *args);
 
@@ -131,31 +123,6 @@
 #endif
 };
 
-static struct file_operations ocfs_fops = {
-	.read = ocfs_file_read,
-	.write = ocfs_file_write,
-	.mmap = generic_file_mmap,
-	.fsync = ocfs_sync_file,
-	.flush = ocfs_flush,
-	.release = ocfs_file_release,
-	.open = ocfs_file_open,
-	.ioctl = ocfs_ioctl,
-#ifdef AIO_ENABLED
-	.kvec_read = ocfs_kvec_read,
-	.kvec_write = ocfs_kvec_write,
-	.aio_read = generic_file_aio_read,
-	.aio_write = generic_file_aio_write,
-#endif
-};
-
-static struct file_operations ocfs_dops = {
-	.read = generic_read_dir,
-	.readdir = ocfs_readdir,
-	.fsync = ocfs_sync_file,
-	.release = ocfs_file_release,
-	.ioctl = ocfs_ioctl
-};
-
 static struct inode_operations ocfs_dir_iops = {
 	.create = ocfs_create,
 	.lookup = ocfs_lookup,
@@ -1761,18 +1728,9 @@
 #endif /* 2.4.x kernel */
 
 #ifdef AIO_ENABLED
-int ocfs_kvec_read(struct file *file, kvec_cb_t cb, size_t size, loff_t pos) 
+static int ocfs_kvec_rw(struct file *filp, int rw, kvec_cb_t cb,
+		size_t size, loff_t pos)
 {
-	return ocfs_kvec_rw(file, READ, cb, size, pos);
-}
-
-int ocfs_kvec_write(struct file *file, kvec_cb_t cb, size_t size, loff_t pos) 
-{
-	return ocfs_kvec_rw(file, WRITE, cb, size, pos);
-}
-
-int ocfs_kvec_rw(struct file *filp, int rw, kvec_cb_t cb, size_t size, loff_t pos) 
-{
 	int	     err = 0;
 	int max_sectors = 25000;
 	struct inode *inode = filp->f_dentry->d_inode;
@@ -1863,6 +1821,15 @@
 
 }
 
+int ocfs_kvec_read(struct file *file, kvec_cb_t cb, size_t size, loff_t pos) 
+{
+	return ocfs_kvec_rw(file, READ, cb, size, pos);
+}
+
+int ocfs_kvec_write(struct file *file, kvec_cb_t cb, size_t size, loff_t pos) 
+{
+	return ocfs_kvec_rw(file, WRITE, cb, size, pos);
+}
 #endif
 
 /*
inode.h +5 -0
Index: src/inode.h
===================================================================
@@ -50,4 +50,9 @@
 int ocfs_verify_update_inode(ocfs_super *osb, struct inode *inode,
 			     int *needs_trunc, int lockres_locked);
 
+#ifdef AIO_ENABLED
+int ocfs_kvec_read(struct file *file, kvec_cb_t cb, size_t size, loff_t pos); 
+int ocfs_kvec_write(struct file *file, kvec_cb_t cb, size_t size, loff_t pos); 
+#endif
+
 #endif /* OCFS2_INODE_H */
file.c +36 -6

95 lines not on this page · raw message

file.h +3 -12
Index: src/file.h
===================================================================
@@ -29,29 +29,20 @@
 #ifndef OCFS2_FILE_H
 #define OCFS2_FILE_H
 
+extern struct file_operations ocfs_fops;
+extern struct file_operations ocfs_dops;
+
 int ocfs_extend_file (ocfs_super * osb, __u64 file_size, __u64 file_off, 
 		      ocfs_journal_handle *passed_handle, 
 		      struct inode *inode, struct iattr *attr, 
 		      int system_file, struct buffer_head *fe_bh);
-int ocfs_file_open(struct inode *inode, struct file *file);
-ssize_t ocfs_file_read(struct file *filp, char *buf, size_t count,
-		       loff_t * ppos);
-int ocfs_file_release(struct inode *inode, struct file *file);
-ssize_t ocfs_file_write(struct file *filp, const char *buf,
-			size_t count, loff_t *ppos);
-int ocfs_flush(struct file *file);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 int ocfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
 		 struct kstat *stat);
-#else
-int ocfs_getattr(struct dentry *dentry, struct iattr *attr);
-#endif
 int ocfs_inode_fill_ext_map(ocfs_super *osb, struct buffer_head *fe_bh,
 			    struct inode *inode);
 int ocfs_inode_notify_open(ocfs_super *osb, struct buffer_head *fe_bh, 
 			   ocfs_journal_handle *handle,
 			   struct inode *inode);
 int ocfs_setattr(struct dentry *dentry, struct iattr *attr);
-int ocfs_sync_file(struct file *file, struct dentry *dentry, int datasync);
 
 #endif /* OCFS2_FILE_H */