2 * OBDFS Super operations
4 * Copryright (C) 1999 Stelias Computing Inc,
5 * (author Peter J. Braam <braam@stelias.com>)
6 * Copryright (C) 1999 Seagate Technology Inc.
10 #include <linux/config.h>
11 #include <linux/kernel.h>
13 #include <linux/string.h>
14 #include <linux/stat.h>
15 #include <linux/errno.h>
16 #include <linux/locks.h>
17 #include <linux/unistd.h>
19 #include <asm/system.h>
20 #include <asm/uaccess.h>
23 #include <linux/stat.h>
24 #include <asm/uaccess.h>
25 #include <linux/vmalloc.h>
26 #include <asm/segment.h>
28 #include <linux/pagemap.h>
29 #include <linux/smp_lock.h>
31 #include <linux/obd_support.h>
32 #include <linux/obd_ext2.h>
33 #include <linux/obdfs.h>
37 /* VFS super_block ops */
40 int obdfs_brw(struct inode *dir, int rw, struct page *page, int create)
42 return iops(dir)->o_brw(rw, iid(dir), dir, page, create);
46 /* returns the page unlocked, but with a reference */
47 int obdfs_readpage(struct dentry *dentry, struct page *page)
49 struct inode *inode = dentry->d_inode;
55 rc = iops(inode)->o_brw(READ, iid(inode),inode, page, 0);
56 if (rc == PAGE_SIZE ) {
57 SetPageUptodate(page);
61 if ( rc == PAGE_SIZE )
67 /* returns the page unlocked, but with a reference */
68 int obdfs_writepage(struct dentry *dentry, struct page *page)
70 struct inode *inode = dentry->d_inode;
74 PDEBUG(page, "WRITEPAGE");
77 rc = iops(inode)->o_brw(WRITE, iid(inode), inode, page, 1);
79 SetPageUptodate(page);
80 PDEBUG(page,"WRITEPAGE");
85 * This does the "real" work of the write. The generic routine has
86 * allocated the page, locked it, done all the page alignment stuff
87 * calculations etc. Now we should just copy the data from user
88 * space and write it back to the real medium..
90 * If the writer ends up delaying the write, the writer needs to
91 * increment the page use counts until he is done with the page.
93 int obdfs_write_one_page(struct file *file, struct page *page, unsigned long offset, unsigned long bytes, const char * buf)
96 struct inode *inode = file->f_dentry->d_inode;
99 if ( !Page_Uptodate(page) ) {
100 status = iops(inode)->o_brw(READ, iid(inode), inode, page, 1);
101 if (status == PAGE_SIZE ) {
102 SetPageUptodate(page);
107 bytes -= copy_from_user((u8*)page_address(page) + offset, buf, bytes);
112 status = obdfs_writepage(file->f_dentry, page);
116 if ( status != PAGE_SIZE )
126 void report_inode(struct page * page) {
127 struct inode *inode = (struct inode *)0;
128 int offset = (int)&inode->i_data;
129 inode = (struct inode *)( (char *)page->mapping - offset);
130 if ( inode->i_sb->s_magic == 0x4711 )
131 printk("----> ino %ld , dev %d\n", inode->i_ino, inode->i_dev);
135 return an up to date page:
136 - if locked is true then is returned locked
137 - if create is true the corresponding disk blocks are created
138 - page is held, i.e. caller must release the page
142 struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create, int locked)
144 struct page *page_cache;
151 offset = offset & PAGE_CACHE_MASK;
152 CDEBUG(D_INODE, "\n");
155 page_cache = page_cache_alloc();
158 CDEBUG(D_INODE, "page_cache %p\n", page_cache);
160 hash = page_hash(&inode->i_data, offset);
161 page = grab_cache_page(&inode->i_data, offset);
163 PDEBUG(page, "GETPAGE: got page - before reading\n");
164 /* now check if the data in the page is up to date */
165 if ( Page_Uptodate(page)) {
172 /* it's not: read it */
174 printk("get_page_map says no dice ...\n");
178 rc = iops(inode)->o_brw(READ, iid(inode), inode, page, create);
179 if ( rc != PAGE_SIZE ) {
187 SetPageUptodate(page);
188 PDEBUG(page,"GETPAGE - after reading");