1 /* object based disk file system
3 * This code is issued under the GNU General Public License.
4 * See the file COPYING in this distribution
6 * Copyright (C), 1999, Stelias Computing Inc
14 #include <linux/obd_class.h>
15 #include <linux/obdo.h>
16 #include <linux/list.h>
20 struct list_head rq_plist; /* linked list of req's */
21 unsigned long rq_jiffies;
22 struct page *rq_page; /* page to be written */
25 extern struct list_head obdfs_super_list; /* list of all OBDFS superblocks */
30 extern struct file_operations obdfs_dir_operations;
31 extern struct inode_operations obdfs_dir_inode_operations;
34 extern struct file_operations obdfs_file_operations;
35 extern struct inode_operations obdfs_file_inode_operations;
38 void obdfs_dequeue_pages(struct inode *inode);
39 int obdfs_flushd_init(void);
40 int obdfs_flushd_cleanup(void);
41 int obdfs_flush_reqs(struct list_head *inode_list, unsigned long check_time);
42 int obdfs_flush_dirty_pages(unsigned long check_time);
47 int obdfs_do_writepage(struct page *, int sync);
48 int obdfs_init_pgrqcache(void);
49 void obdfs_cleanup_pgrqcache(void);
50 inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq);
51 int obdfs_readpage(struct file *file, struct page *page);
52 int obdfs_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to);
53 int obdfs_commit_write(struct file *file, struct page *page, unsigned from, unsigned to);
54 int obdfs_writepage(struct page *page);
55 struct page *obdfs_getpage(struct inode *inode, unsigned long offset,
56 int create, int locked);
57 int obdfs_write_one_page(struct file *file, struct page *page,
58 unsigned long offset, unsigned long bytes,
60 int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa,
61 struct obdo **obdos, obd_count *oa_bufs,
62 struct page **pages, char **bufs, obd_size *counts,
63 obd_off *offsets, obd_flag *flags);
64 void obdfs_truncate(struct inode *inode);
67 extern long obdfs_cache_count;
68 extern long obdfs_mutex_start;
71 extern struct inode_operations obdfs_fast_symlink_inode_operations;
72 extern struct inode_operations obdfs_symlink_inode_operations;
75 void obdfs_sysctl_init(void);
76 void obdfs_sysctl_clean(void);
78 static inline struct obdfs_sb_info *obdfs_i2sbi(struct inode *inode)
80 return (struct obdfs_sb_info *) &(inode->i_sb->u.generic_sbp);
83 static inline struct list_head *obdfs_iplist(struct inode *inode)
85 struct obdfs_inode_info *info = obdfs_i2info(inode);
87 return &info->oi_pages;
90 static inline struct list_head *obdfs_islist(struct inode *inode)
92 struct obdfs_inode_info *info = obdfs_i2info(inode);
94 return &info->oi_inodes;
97 static inline struct list_head *obdfs_slist(struct inode *inode)
99 struct obdfs_sb_info *sbi = obdfs_i2sbi(inode);
101 return &sbi->osi_inodes;
104 static void inline obdfs_set_size (struct inode *inode, obd_size size)
106 inode->i_size = size;
107 inode->i_blocks = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
108 inode->i_sb->s_blocksize_bits;
109 } /* obdfs_set_size */
112 #if 0 /* PAGE CACHE DISABLED */
114 #define obd_down(mutex) { \
115 /* CDEBUG(D_INFO, "get lock\n"); */ \
116 obdfs_mutex_start = jiffies; \
118 if (jiffies - obdfs_mutex_start) \
119 CDEBUG(D_CACHE, "waited on mutex %ld jiffies\n", \
120 jiffies - obdfs_mutex_start); \
123 #define obd_up(mutex) { \
125 if (jiffies - obdfs_mutex_start > 1) \
126 CDEBUG(D_CACHE, "held mutex for %ld jiffies\n", \
127 jiffies - obdfs_mutex_start); \
128 /* CDEBUG(D_INFO, "free lock\n"); */ \
131 /* We track if a page has been added to the OBD page cache by stting a
132 * flag on the page. We have chosen a bit that will hopefully not be
135 #define PG_obdcache 29
136 #define OBDAddCachePage(page) test_and_set_bit(PG_obdcache, &(page)->flags)
137 #define OBDClearCachePage(page) clear_bit(PG_obdcache, &(page)->flags)
139 static inline void obdfs_print_plist(struct inode *inode)
141 struct list_head *page_list = obdfs_iplist(inode);
142 struct list_head *tmp;
144 CDEBUG(D_INFO, "inode %ld: page", inode->i_ino);
145 /* obd_down(&obdfs_i2sbi(inode)->osi_list_mutex); */
146 if (list_empty(page_list)) {
147 CDEBUG(D_INFO, " list empty\n");
148 obd_up(&obdfs_i2sbi(inode)->osi_list_mutex);
153 while ( (tmp = tmp->next) != page_list) {
154 struct obdfs_pgrq *pgrq;
155 pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist);
156 CDEBUG(D_INFO, " %p", pgrq->rq_page);
158 CDEBUG(D_INFO, "\n");
159 /* obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); */