/*
* OBDFS Super operations
*
+ * Copyright (C) 1996, 1997, Olaf Kirch <okir@monad.swb.de>
* Copryright (C) 1999 Stelias Computing Inc,
* (author Peter J. Braam <braam@stelias.com>)
* Copryright (C) 1999 Seagate Technology Inc.
int console_loglevel;
-/* VFS super_block ops */
+/* SYNCHRONOUS I/O for an inode */
+int obdfs_brw(int rw, struct inode *inode, struct page *page, int create)
+{
+ struct obdo *obdo;
+ int res;
+
+ obdo = obdo_alloc();
+ if ( ! obdo ) {
+ EXIT;
+ return -ENOMEM;
+ }
+
+ obdo->o_id = inode->i_ino;
+
+ res = IOPS(inode, brw)(rw, IID(inode), obdo,
+ (char *)page_address(page),
+ PAGE_SIZE,
+ (page->index) >> PAGE_SHIFT,
+ create);
+
+ obdo_to_inode(inode, obdo); /* copy o_blocks to i_blocks */
+ obdo_free(obdo);
+
+ if ( res == PAGE_SIZE )
+ res = 0;
+ return res;
+}
-#if 0
-int obdfs_brw(struct inode *dir, int rw, struct page *page, int create)
+/* returns the page unlocked, but with a reference */
+int obdfs_readpage(struct dentry *dentry, struct page *page)
{
- return iops(dir)->o_brw(rw, iid(dir), dir, page, create);
+ struct inode *inode = dentry->d_inode;
+ int rc;
+
+ ENTRY;
+ PDEBUG(page, "READ");
+ rc = obdfs_brw(READ, inode, page, 0);
+ if (!rc) {
+ SetPageUptodate(page);
+ UnlockPage(page);
+ }
+ PDEBUG(page, "READ");
+ EXIT;
+ return rc;
}
-#endif
static kmem_cache_t *obdfs_wreq_cachep;
return 0;
}
+void obdfs_cleanup_wreqcache(void)
+{
+ if (obdfs_wreq_cachep != NULL)
+ kmem_cache_destroy(obdfs_wreq_cachep);
+
+ obdfs_wreq_cachep = NULL;
+}
+
+
/*
* Find a specific page in the page cache. If it is found, we return
* the write request struct associated with it, if not found return NULL.
return NULL;
}
-/* returns the page unlocked, but with a reference */
-int obdfs_readpage(struct dentry *dentry, struct page *page)
-{
- struct inode *inode = dentry->d_inode;
- struct obdfs_wreq *wreq;
- int rc = 0;
-
- ENTRY;
- /* XXX flush stuff */
- wreq = obdfs_find_in_page_cache(inode, page);
- if (!wreq) {
- PDEBUG(page, "READ");
- rc = iops(inode)->o_brw(READ, iid(inode),inode, page, 0);
- if (rc == PAGE_SIZE ) {
- SetPageUptodate(page);
- UnlockPage(page);
- }
- PDEBUG(page, "READ");
- if ( rc == PAGE_SIZE )
- rc = 0;
- }
- EXIT;
- return rc;
-}
/*
* Remove a writeback request from a list
ENTRY;
CDEBUG(D_INODE, "removing inode %ld page %p, wreq: %p\n",
inode->i_ino, page, wreq);
- rc = iops(inode)->o_brw(WRITE, iid(inode), inode, page, 1);
+ rc = obdfs_brw(WRITE, inode, page, 1);
/* XXX probably should handle error here somehow. I think that
* ext2 also does the same thing - discard write even if error?
*/
}
-/* returns the page unlocked, but with a reference */
-int obdfs_writepage(struct dentry *dentry, struct page *page)
+int obdfs_do_writepage(struct inode *inode, struct page *page, int sync)
{
- struct inode *inode = dentry->d_inode;
int rc;
ENTRY;
PDEBUG(page, "WRITEPAGE");
- /* XXX flush stuff */
- rc = obdfs_add_to_page_cache(inode, page);
-
+ if ( sync ) {
+ rc = obdfs_brw(WRITE, inode, page, 1);
+ } else {
+ /* XXX flush stuff */
+ rc = obdfs_add_to_page_cache(inode, page);
+ }
+
if (!rc)
SetPageUptodate(page);
PDEBUG(page,"WRITEPAGE");
return rc;
}
+/* returns the page unlocked, but with a reference */
+int obdfs_writepage(struct dentry *dentry, struct page *page)
+{
+ return obdfs_do_writepage(dentry->d_inode, page, 0);
+}
+
/*
* This does the "real" work of the write. The generic routine has
* allocated the page, locked it, done all the page alignment stuff
ENTRY;
if ( !Page_Uptodate(page) ) {
- status = iops(inode)->o_brw(READ, iid(inode), inode, page, 1);
- if (status == PAGE_SIZE ) {
+ status = obdfs_brw(READ, inode, page, 1);
+ if (!status) {
SetPageUptodate(page);
} else {
return status;
return bytes;
}
-
-
-
-
-void report_inode(struct page * page) {
- struct inode *inode = (struct inode *)0;
- int offset = (int)&inode->i_data;
- inode = (struct inode *)( (char *)page->mapping - offset);
- if ( inode->i_sb->s_magic == 0x4711 )
- printk("----> ino %ld , dev %d\n", inode->i_ino, inode->i_dev);
-}
-
/*
return an up to date page:
- if locked is true then is returned locked
hash = page_hash(&inode->i_data, offset);
page = grab_cache_page(&inode->i_data, offset);
+ /* Yuck, no page */
+ if (! page) {
+ printk("grab_cache_page says no dice ...\n");
+ return 0;
+ }
+
PDEBUG(page, "GETPAGE: got page - before reading\n");
/* now check if the data in the page is up to date */
if ( Page_Uptodate(page)) {
return page;
}
- /* it's not: read it */
- if (! page) {
- printk("get_page_map says no dice ...\n");
- return 0;
- }
+ rc = obdfs_brw(READ, inode, page, create);
- rc = iops(inode)->o_brw(READ, iid(inode), inode, page, create);
if ( rc != PAGE_SIZE ) {
SetPageError(page);
UnlockPage(page);