Whamcloud - gitweb
More 'rpc_register_service' removal
[fs/lustre-release.git] / lustre / include / linux / obdfs.h
1 /* object based disk file system
2  * 
3  * This code is issued under the GNU General Public License.
4  * See the file COPYING in this distribution
5  * 
6  * Copyright (C), 1999, Stelias Computing Inc
7  *
8  *
9  */
10
11
12 #ifndef _OBDFS_H
13 #define _OBDFS_H
14 #include <linux/obd_class.h>
15 #include <linux/obdo.h>
16 #include <linux/list.h>
17
18 /* super.c */ 
19 struct obdfs_pgrq {
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 */
23 };
24
25 extern struct list_head obdfs_super_list;       /* list of all OBDFS superblocks */
26
27
28
29 /* dir.c */
30 extern struct file_operations obdfs_dir_operations;
31 extern struct inode_operations obdfs_dir_inode_operations;
32
33 /* file.c */
34 extern struct file_operations obdfs_file_operations;
35 extern struct inode_operations obdfs_file_inode_operations;
36
37 /* flush.c */
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);
43
44 /* namei.c */
45
46 /* rw.c */
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,
59                          const char * buf);
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);
65
66 /* super.c */
67 extern long obdfs_cache_count;
68 extern long obdfs_mutex_start;
69
70 /* symlink.c */
71 extern struct inode_operations obdfs_fast_symlink_inode_operations;
72 extern struct inode_operations obdfs_symlink_inode_operations;
73
74 /* sysctl.c */
75 void obdfs_sysctl_init(void);
76 void obdfs_sysctl_clean(void);
77
78 static inline struct obdfs_sb_info *obdfs_i2sbi(struct inode *inode)
79 {
80         return (struct obdfs_sb_info *) &(inode->i_sb->u.generic_sbp);
81 }
82
83 static inline struct list_head *obdfs_iplist(struct inode *inode) 
84 {
85         struct obdfs_inode_info *info = obdfs_i2info(inode);
86
87         return &info->oi_pages;
88 }
89
90 static inline struct list_head *obdfs_islist(struct inode *inode) 
91 {
92         struct obdfs_inode_info *info = obdfs_i2info(inode);
93
94         return &info->oi_inodes;
95 }
96
97 static inline struct list_head *obdfs_slist(struct inode *inode) 
98 {
99         struct obdfs_sb_info *sbi = obdfs_i2sbi(inode);
100
101         return &sbi->osi_inodes;
102 }
103
104 static void inline obdfs_set_size (struct inode *inode, obd_size size)
105 {  
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 */
110
111
112 #if 0   /* PAGE CACHE DISABLED */
113
114 #define obd_down(mutex) {                                               \
115         /* CDEBUG(D_INFO, "get lock\n"); */                             \
116         obdfs_mutex_start = jiffies;                                    \
117         down(mutex);                                                    \
118         if (jiffies - obdfs_mutex_start)                                \
119                 CDEBUG(D_CACHE, "waited on mutex %ld jiffies\n",        \
120                        jiffies - obdfs_mutex_start);                    \
121 }
122
123 #define obd_up(mutex) {                                                 \
124         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"); */                            \
129 }
130
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
133  * used for a while.
134  */
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)
138
139 static inline void obdfs_print_plist(struct inode *inode) 
140 {
141         struct list_head *page_list = obdfs_iplist(inode);
142         struct list_head *tmp;
143
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);
149                 return;
150         }
151
152         tmp = page_list;
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);
157         }
158         CDEBUG(D_INFO, "\n");
159         /* obd_up(&obdfs_i2sbi(inode)->osi_list_mutex); */
160 }
161 #endif
162
163
164 #endif
165