1 /* object based disk file system
3 * This software is licensed under the GPL. See the file COPYING in the
4 * top directory of this distribution for details.
6 * Copyright (C), 1999, Stelias Computing Inc
14 #include <linux/obd_class.h>
15 #include <linux/list.h>
18 void obdfs_read_inode(struct inode *inode);
21 int flushd_init(void);
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);
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);
44 int obdfs_check_dir_entry (const char * function, struct inode * dir,
45 struct ext2_dir_entry_2 * de,
47 unsigned long offset);
49 int obdfs_readlink (struct dentry *, char *, int);
50 struct dentry *obdfs_follow_link(struct dentry *, struct dentry *, unsigned int);
53 /* list of all OBDFS super blocks */
54 struct list_head obdfs_super_list;
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 */
63 void obdfs_print_list(struct list_head *page_list) {
64 struct list_head *tmp = page_list;
66 while ( (tmp = tmp->next) != page_list) {
67 struct obdfs_pgrq *pgrq;
68 pgrq = list_entry(tmp, struct obdfs_pgrq, rq_plist);
69 CDEBUG(D_INODE, "page %p\n", pgrq->rq_page);
74 inline void obdfs_pgrq_del(struct obdfs_pgrq *pgrq);
75 int obdfs_do_vec_wr(struct super_block *sb, obd_count num_io, obd_count num_oa,
76 struct obdo **obdos, obd_count *oa_bufs,
77 struct page **pages, char **bufs, obd_size *counts,
78 obd_off *offsets, obd_flag *flags);
81 struct obdfs_sb_info {
82 struct list_head osi_list; /* list of supers */
83 struct obd_conn osi_conn;
84 struct super_block *osi_super;
85 struct obd_device *osi_obd;
86 struct obd_ops *osi_ops;
87 ino_t osi_rootino; /* which root inode */
88 int osi_minor; /* minor of /dev/obdX */
89 struct list_head osi_inodes; /* linked list of dirty inodes */
92 struct obdfs_inode_info {
94 struct list_head oi_inodes;
95 struct list_head oi_pages;
96 char oi_inline[OBD_INLINESZ];
99 static inline struct list_head *obdfs_iplist(struct inode *inode)
101 struct obdfs_inode_info *info = (struct obdfs_inode_info *)&inode->u.generic_ip;
103 return &info->oi_pages;
106 static inline struct list_head *obdfs_islist(struct inode *inode)
108 struct obdfs_inode_info *info = (struct obdfs_inode_info *)&inode->u.generic_ip;
110 return &info->oi_inodes;
113 static inline struct list_head *obdfs_slist(struct inode *inode) {
114 struct obdfs_sb_info *sbi = (struct obdfs_sb_info *)(&inode->i_sb->u.generic_sbp);
115 return &sbi->osi_inodes;
118 #define OBDFS_INFO(inode) ((struct obdfs_inode_info *)(&(inode)->u.generic_ip))
120 void obdfs_sysctl_init(void);
121 void obdfs_sysctl_clean(void);
123 extern struct file_operations obdfs_file_operations;
124 extern struct inode_operations obdfs_file_inode_operations;
125 extern struct inode_operations obdfs_dir_inode_operations;
126 extern struct inode_operations obdfs_symlink_inode_operations;
128 static inline int obdfs_has_inline(struct inode *inode)
130 return (OBDFS_INFO(inode)->oi_flags & OBD_FL_INLINEDATA);
133 static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
135 struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
137 CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
138 obdo_from_inode(oa, inode);
139 if (obdfs_has_inline(inode)) {
140 CDEBUG(D_INODE, "inode has inline data\n");
141 memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
142 oa->o_obdflags |= OBD_FL_INLINEDATA;
143 oa->o_valid |= OBD_MD_FLINLINE;
145 } /* obdfs_from_inode */
147 static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
149 struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
151 CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
152 obdo_to_inode(inode, oa);
154 if (obdo_has_inline(oa)) {
155 CDEBUG(D_INODE, "obdo has inline data\n");
156 memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
157 oinfo->oi_flags |= OBD_FL_INLINEDATA;
159 } /* obdfs_to_inode */
165 #warning "*** WARNING redefining OPS"
167 #define OPS(sb,op) ((struct obdfs_sb_info *)(& ## sb ## ->u.generic_sbp))->osi_ops->o_ ## op
168 #define IOPS(inode,op) ((struct obdfs_sb_info *)(& ## inode->i_sb ## ->u.generic_sbp))->osi_ops->o_ ## op
172 #warning "*** WARNING redefining ID"
174 #define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
175 #define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
178 #define OBDFS_SUPER_MAGIC 0x4711