Whamcloud - gitweb
Updated parameters for obdfs_writepage() to use struct *dentry instead of
[fs/lustre-release.git] / lustre / obdfs / rw.c
index bceef44..a07cd50 100644 (file)
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 
-#include <../obd/linux/obd_support.h>
-#include <../obd/linux/obd_sim.h>
-#include <obdfs.h>
+#include <linux/obd_support.h>
+#include <linux/obd_sim.h>
+#include <linux/obdfs.h>
 
 int console_loglevel;
 
 /* VFS super_block ops */
 
+#if 0
+int obdfs_brw(struct inode *dir, int rw, struct page *page, int create)
+{
+       return iops(dir)->o_brw(rw, iid(dir), dir, page, create);
+}
+#endif
+
 /* returns the page unlocked, but with a reference */
-int obdfs_readpage(struct file *file, struct page *page)
+int obdfs_readpage(struct dentry *dentry, struct page *page)
 {
-        struct obdfs_sb_info *sbi;
-       struct super_block *sb = file->f_dentry->d_inode->i_sb;
+       struct inode *inode = dentry->d_inode;
        int rc;
 
         ENTRY;
-
        /* XXX flush stuff */
-       sbi = sb->u.generic_sbp;
        PDEBUG(page, "READ");
-       rc =  sbi->osi_ops->o_brw(READ, sbi->osi_conn_info.conn_id, 
-                     file->f_dentry->d_inode, page, 0);
+       rc =  iops(inode)->o_brw(READ, iid(inode),inode, page, 0);
        if (rc == PAGE_SIZE ) {
                SetPageUptodate(page);
                UnlockPage(page);
@@ -61,6 +64,23 @@ int obdfs_readpage(struct file *file, struct page *page)
 
 }
 
+/* returns the page unlocked, but with a reference */
+static int obdfs_writepage(struct dentry *dentry, struct page *page)
+{
+        struct inode *inode = dentry->d_inode;
+       int rc;
+
+        ENTRY;
+       PDEBUG(page, "WRITEPAGE");
+       /* XXX flush stuff */
+
+       rc = iops(inode)->o_brw(WRITE, iid(inode), inode, page, 1);
+
+       SetPageUptodate(page);
+       PDEBUG(page,"WRITEPAGE");
+       return rc;
+}
+
 /*
  * This does the "real" work of the write. The generic routine has
  * allocated the page, locked it, done all the page alignment stuff
@@ -73,14 +93,11 @@ int obdfs_readpage(struct file *file, struct page *page)
 int obdfs_write_one_page(struct file *file, struct page *page, unsigned long offset, unsigned long bytes, const char * buf)
 {
        long status;
-        struct obdfs_sb_info *sbi = file->f_dentry->d_inode->i_sb->u.generic_sbp;
+        struct inode *inode = file->f_dentry->d_inode;
 
        ENTRY;
        if ( !Page_Uptodate(page) ) {
-               status =  sbi->osi_ops->o_brw(READ, 
-                                             sbi->osi_conn_info.conn_id, 
-                                             file->f_dentry->d_inode, 
-                                             page, 1);
+               status =  iops(inode)->o_brw(READ, iid(inode), inode, page, 1);
                if (status == PAGE_SIZE ) {
                        SetPageUptodate(page);
                } else { 
@@ -93,7 +110,7 @@ int obdfs_write_one_page(struct file *file, struct page *page, unsigned long off
        if (bytes) {
 
                lock_kernel();
-               status = obdfs_writepage(file, page);
+               status = obdfs_writepage(file->f_dentry, page);
                unlock_kernel();
        }
        EXIT;
@@ -106,24 +123,6 @@ int obdfs_write_one_page(struct file *file, struct page *page, unsigned long off
 
 
 
-/* returns the page unlocked, but with a reference */
-int obdfs_writepage(struct file *file, struct page *page)
-{
-        struct obdfs_sb_info *sbi = file->f_dentry->d_inode->i_sb->u.generic_sbp;
-       int rc;
-
-        ENTRY;
-       PDEBUG(page, "WRITEPAGE");
-       /* XXX flush stuff */
-
-       rc = sbi->osi_ops->o_brw(WRITE, sbi->osi_conn_info.conn_id, 
-                     file->f_dentry->d_inode, page, 1);
-
-       SetPageUptodate(page);
-       PDEBUG(page,"WRITEPAGE");
-       return rc;
-}
-
 
 void report_inode(struct page * page) {
        struct inode *inode = (struct inode *)0;
@@ -146,14 +145,11 @@ struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create
        struct page *page_cache;
        struct page ** hash;
        struct page * page;
-       struct obdfs_sb_info *sbi;
-       struct super_block *sb = inode->i_sb;
        int rc;
 
         ENTRY;
 
        offset = offset & PAGE_CACHE_MASK;
-       sbi = sb->u.generic_sbp;
        CDEBUG(D_INODE, "\n");
        
        page = NULL;
@@ -202,8 +198,7 @@ struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create
 
 
 
-       rc = sbi->osi_ops->o_brw(READ, sbi->osi_conn_info.conn_id, 
-                                   inode, page, create);
+       rc = iops(inode)->o_brw(READ, iid(inode), inode, page, create);
        if ( rc != PAGE_SIZE ) {
                SetPageError(page);
                UnlockPage(page);
@@ -222,7 +217,7 @@ struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create
 struct file_operations obdfs_file_ops = {
        NULL,                   /* lseek - default */
        generic_file_read,      /* read */
-       obdfs_file_write,     /* write - bad */
+       obdfs_file_write,       /* write - bad */
         obdfs_readdir,         /* readdir */
        NULL,                   /* poll - default */
        NULL,                   /* ioctl */