Whamcloud - gitweb
Several bugfixes. Most notably ext2obd_brw is still totally broken,
[fs/lustre-release.git] / lustre / include / linux / obdfs.h
1 /* object based disk file system
2  * 
3  * This software is licensed under the GPL.  See the file COPYING in the
4  * top directory of this distribution for details.
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/list.h>
16
17 /* super.c */
18 void obdfs_read_inode(struct inode *inode);
19
20 /* flush.c */
21 int flushd_init(void);
22
23
24 /* rw.c */
25 int obdfs_do_writepage(struct inode *, struct page *, int sync);
26 int obdfs_init_pgrqcache(void);
27 void obdfs_cleanup_pgrqcache(void);
28 int obdfs_readpage(struct dentry *dentry, struct page *page);
29 int obdfs_writepage(struct dentry *dentry, struct page *page);
30 struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create, int locked);
31 int obdfs_write_one_page(struct file *file, struct page *page, unsigned long offset, unsigned long bytes, const char * buf);
32 void obdfs_dequeue_reqs(struct inode *inode);
33
34 /* namei.c */
35 struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry);
36 int obdfs_create (struct inode * dir, struct dentry * dentry, int mode);
37 int obdfs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
38 int obdfs_rmdir(struct inode *dir, struct dentry *dentry);
39 int obdfs_unlink(struct inode *dir, struct dentry *dentry);
40 int obdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev);
41 int obdfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname);
42 int obdfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry);
43 int obdfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry);
44 /* dir.c */
45 int obdfs_check_dir_entry (const char * function, struct inode * dir,
46                           struct ext2_dir_entry_2 * de, struct page * page,
47                           unsigned long offset);
48 /* symlink.c */
49 int obdfs_readlink (struct dentry *, char *, int);
50 struct dentry *obdfs_follow_link(struct dentry *, struct dentry *, unsigned int); 
51
52
53 /* list of all OBDFS super blocks  */
54 struct list_head obdfs_super_list;
55
56 struct obdfs_pgrq {
57         struct list_head         rq_plist;      /* linked list of req's */
58         unsigned long            rq_jiffies;
59         struct page             *rq_page;       /* page to be written */
60 };
61
62
63 inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq);
64 int obdfs_do_vec_wr(struct inode **inodes, obd_count num_io, obd_count num_oa,
65                     struct obdo **obdos, obd_count *oa_bufs,
66                     struct page **pages, char **bufs, obd_size *counts,
67                     obd_off *offsets, obd_flag *flags);
68
69
70 struct obdfs_sb_info {
71         struct list_head         osi_list;      /* list of supers */
72         struct obd_conn          osi_conn;
73         struct super_block      *osi_super;
74         struct obd_device       *osi_obd;
75         struct obd_ops          *osi_ops;
76         ino_t                    osi_rootino;   /* number of root inode */
77         int                      osi_minor;     /* minor of /dev/obdX */
78         struct list_head         osi_inodes;    /* list of dirty inodes */
79 };
80
81 struct obdfs_inode_info {
82         int              oi_flags;
83         struct list_head oi_inodes;
84         struct list_head oi_pages;
85         char             oi_inline[OBD_INLINESZ];
86 };
87
88 #define OBDFS_INFO(inode) ((struct obdfs_inode_info *)(&(inode)->u.generic_ip))
89
90 static inline struct list_head *obdfs_iplist(struct inode *inode) 
91 {
92         struct obdfs_inode_info *info = (struct obdfs_inode_info *)&inode->u.generic_ip;
93
94         return &info->oi_pages;
95 }
96
97 static inline struct list_head *obdfs_islist(struct inode *inode) 
98 {
99         struct obdfs_inode_info *info = (struct obdfs_inode_info *)&inode->u.generic_ip;
100
101         return &info->oi_inodes;
102 }
103
104 static inline struct list_head *obdfs_slist(struct inode *inode) {
105         struct obdfs_sb_info *sbi = (struct obdfs_sb_info *)(&inode->i_sb->u.generic_sbp);
106         return &sbi->osi_inodes;
107 }
108
109 static inline void obdfs_print_plist(struct inode *inode) {
110         struct list_head *page_list = obdfs_iplist(inode);
111         struct list_head *tmp;
112
113         CDEBUG(D_INODE, "inode %ld: page", inode->i_ino);
114         if (list_empty(page_list)) {
115                 printk(" list empty\n");
116                 return;
117         }
118
119         tmp = page_list;
120         while ( (tmp = tmp->next) != page_list) {
121                 struct obdfs_pgrq *pgrq;
122                 pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist);
123                 printk(" %p", pgrq->rq_page);
124         }
125         printk("\n");
126 }
127
128 void obdfs_sysctl_init(void);
129 void obdfs_sysctl_clean(void);
130
131 extern struct file_operations obdfs_file_operations;
132 extern struct inode_operations obdfs_file_inode_operations;
133 extern struct inode_operations obdfs_dir_inode_operations;
134 extern struct inode_operations obdfs_symlink_inode_operations;
135
136 static inline int obdfs_has_inline(struct inode *inode)
137 {
138         return (OBDFS_INFO(inode)->oi_flags & OBD_FL_INLINEDATA);
139 }
140
141 static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
142 {
143         struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
144
145         CDEBUG(D_INODE, "src inode %ld, dst obdo %ld valid 0x%08x\n",
146                inode->i_ino, (long)oa->o_id, oa->o_valid);
147         obdo_from_inode(oa, inode);
148         if (obdfs_has_inline(inode)) {
149                 CDEBUG(D_INODE, "copying inline data from inode to obdo\n");
150                 memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
151                 oa->o_obdflags |= OBD_FL_INLINEDATA;
152                 oa->o_valid |= OBD_MD_FLINLINE;
153         }
154 } /* obdfs_from_inode */
155
156 static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
157 {
158         struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
159
160         CDEBUG(D_INODE, "src obdo %ld valid 0x%08x, dst inode %ld\n",
161                (long)oa->o_id, oa->o_valid, inode->i_ino);
162         obdo_to_inode(inode, oa);
163
164         if (obdo_has_inline(oa)) {
165                 CDEBUG(D_INODE, "copying inline data from obdo to inode\n");
166                 memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
167                 oinfo->oi_flags |= OBD_FL_INLINEDATA;
168         }
169 } /* obdfs_to_inode */
170
171 #define NOLOCK 0
172 #define LOCKED 1
173
174 #ifdef OPS
175 #warning "*** WARNING redefining OPS"
176 #else
177 #define OPS(sb,op) ((struct obdfs_sb_info *)(& ## sb ## ->u.generic_sbp))->osi_ops->o_ ## op
178 #define IOPS(inode,op) ((struct obdfs_sb_info *)(& ## inode->i_sb ## ->u.generic_sbp))->osi_ops->o_ ## op
179 #endif
180
181 #ifdef ID
182 #warning "*** WARNING redefining ID"
183 #else
184 #define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
185 #define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
186 #endif
187
188 #define OBDFS_SUPER_MAGIC 0x4711
189
190 #endif
191