Whamcloud - gitweb
ext2obd/ext2obd.c: fixed brw I/O to have array of iobufs, not pointer
[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
33 /* namei.c */
34 struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry);
35 int obdfs_create (struct inode * dir, struct dentry * dentry, int mode);
36 int obdfs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
37 int obdfs_rmdir(struct inode *dir, struct dentry *dentry);
38 int obdfs_unlink(struct inode *dir, struct dentry *dentry);
39 int obdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev);
40 int obdfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname);
41 int obdfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry);
42 int obdfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry);
43 /* dir.c */
44 int obdfs_check_dir_entry (const char * function, struct inode * dir,
45                           struct ext2_dir_entry_2 * de,
46                           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_ilist;      /* linked list of req's */
58         struct list_head         rq_slist;      /* linked list of req's */
59         unsigned long          rq_jiffies;
60         struct inode            *rq_inode;      /* dentry referenced */
61         struct page             *rq_page;       /* page to be written */
62 };
63 inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq);
64 int obdfs_do_vec_wr(struct super_block *sb, obd_count *num_io, 
65                            struct obdo **obdos,
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; /* which root inode */
77         int                      osi_minor;   /* minor of /dev/obdX */
78         struct list_head         osi_pages;  /* linked list of inodes to write */
79 };
80
81 struct obdfs_inode_info {
82         int              oi_flags;
83         struct list_head oi_pages;
84         char             oi_inline[OBD_INLINESZ];
85 };
86
87 #define MAX_IOVEC       16
88
89 static inline struct list_head *obdfs_ilist(struct inode *inode) 
90 {
91         struct obdfs_inode_info *info = (struct obdfs_inode_info *)&inode->u.generic_ip;
92
93         return &info->oi_pages;
94 }
95
96 static inline struct list_head *obdfs_slist(struct inode *inode) {
97         struct obdfs_sb_info *sbi = (struct obdfs_sb_info *)(&inode->i_sb->u.generic_sbp);
98         return &sbi->osi_pages;
99 }
100
101 #define OBDFS_INFO(inode) ((struct obdfs_inode_info *)(&(inode)->u.generic_ip))
102
103 void obdfs_sysctl_init(void);
104 void obdfs_sysctl_clean(void);
105
106 extern struct file_operations obdfs_file_operations;
107 extern struct inode_operations obdfs_file_inode_operations;
108 extern struct inode_operations obdfs_dir_inode_operations;
109 extern struct inode_operations obdfs_symlink_inode_operations;
110
111 static inline int obdfs_has_inline(struct inode *inode)
112 {
113         return (OBDFS_INFO(inode)->oi_flags & OBD_FL_INLINEDATA);
114 }
115
116 static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
117 {
118         struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
119
120         CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
121         obdo_from_inode(oa, inode);
122         if (obdfs_has_inline(inode)) {
123                 CDEBUG(D_INODE, "inode has inline data\n");
124                 memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
125                 oa->o_obdflags |= OBD_FL_INLINEDATA;
126                 oa->o_valid |= OBD_MD_FLINLINE;
127         }
128 } /* obdfs_from_inode */
129
130 static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
131 {
132         struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
133
134         CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
135         obdo_to_inode(inode, oa);
136
137         if (obdo_has_inline(oa)) {
138                 CDEBUG(D_INODE, "obdo has inline data\n");
139                 memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
140                 oinfo->oi_flags |= OBD_FL_INLINEDATA;
141         }
142 } /* obdfs_to_inode */
143
144 #define NOLOCK 0
145 #define LOCKED 1
146
147 #ifdef OPS
148 #warning "*** WARNING redefining OPS"
149 #else
150 #define OPS(sb,op) ((struct obdfs_sb_info *)(& ## sb ## ->u.generic_sbp))->osi_ops->o_ ## op
151 #define IOPS(inode,op) ((struct obdfs_sb_info *)(& ## inode->i_sb ## ->u.generic_sbp))->osi_ops->o_ ## op
152 #endif
153
154 #ifdef ID
155 #warning "*** WARNING redefining ID"
156 #else
157 #define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
158 #define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
159 #endif
160
161 #define OBDFS_SUPER_MAGIC 0x4711
162
163 #endif
164