Whamcloud - gitweb
6800db607a8b3e300065977e64619812f0993390
[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_wreqcache(void);
27 int obdfs_readpage(struct dentry *dentry, struct page *page);
28 int obdfs_writepage(struct dentry *dentry, struct page *page);
29 struct page *obdfs_getpage(struct inode *inode, unsigned long offset, int create, int locked);
30 int obdfs_write_one_page(struct file *file, struct page *page, unsigned long offset, unsigned long bytes, const char * buf);
31
32 /* namei.c */
33 struct dentry *obdfs_lookup(struct inode * dir, struct dentry *dentry);
34 int obdfs_create (struct inode * dir, struct dentry * dentry, int mode);
35 int obdfs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
36 int obdfs_rmdir(struct inode *dir, struct dentry *dentry);
37 int obdfs_unlink(struct inode *dir, struct dentry *dentry);
38 int obdfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev);
39 int obdfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname);
40 int obdfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry);
41 int obdfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry);
42 /* dir.c */
43 int obdfs_check_dir_entry (const char * function, struct inode * dir,
44                           struct ext2_dir_entry_2 * de,
45                           struct page * page,
46                            unsigned long offset);
47 /* symlink.c */
48 int obdfs_readlink (struct dentry *, char *, int);
49 struct dentry *obdfs_follow_link(struct dentry *, struct dentry *, unsigned int); 
50
51 struct obdfs_super_entry {
52         struct list_head sl_chain;
53         struct obdfs_sb_info *sbi;
54 };
55
56 struct obdfs_wreq {
57         struct list_head         wb_list;       /* linked list of req's */
58         struct inode            *wb_inode;      /* dentry referenced */
59         struct page             *wb_page;       /* page to be written */
60 };
61
62 struct obdfs_sb_info {
63         struct obd_conn osi_conn;
64         struct super_block *osi_super;
65         struct obd_device *osi_obd;
66         struct obd_ops *osi_ops;     
67         ino_t           osi_rootino; /* which root inode */
68         int             osi_minor;   /* minor of /dev/obdX */
69         struct list_head osi_list;  /* linked list of inodes to write */
70 };
71
72
73 #define WB_NEXT(req)    ((struct obdfs_wreq *) ((req)->wb_list.next))
74 /* XXX page list should go on each inode instead of supberblock */
75 #define OBD_LIST(inode) (((struct obdfs_sb_info *)(&(inode)->i_sb->u.generic_sbp))->osi_list)
76 #define WREQ(entry)     (list_entry(entry, struct obdfs_wreq, wb_list))
77
78 void obdfs_sysctl_init(void);
79 void obdfs_sysctl_clean(void);
80
81
82 extern struct file_operations obdfs_file_operations;
83 extern struct inode_operations obdfs_file_inode_operations;
84 extern struct inode_operations obdfs_dir_inode_operations;
85 extern struct inode_operations obdfs_symlink_inode_operations;
86
87 static inline struct obd_ops *iops(struct inode *i)
88 {
89         struct obdfs_sb_info *sbi = (struct obdfs_sb_info *) &i->i_sb->u.generic_sbp;
90         return sbi->osi_ops;
91 }
92
93 static inline struct obd_conn *iid(struct inode *i)
94 {
95         struct obdfs_sb_info *sbi = (struct obdfs_sb_info *) &i->i_sb->u.generic_sbp;
96         return &sbi->osi_conn;
97 }
98
99 #define NOLOCK 0
100 #define LOCKED 1
101
102 #ifdef OPS
103 #warning "*** WARNING redefining OPS"
104 #else
105 #define OPS(sb,op) ((struct obdfs_sb_info *)(& ## sb ## ->u.generic_sbp))->osi_ops->o_ ## op
106 #define IOPS(inode,op) ((struct obdfs_sb_info *)(& ## inode->i_sb ## ->u.generic_sbp))->osi_ops->o_ ## op
107 #endif
108
109 #ifdef ID
110 #warning "*** WARNING redefining ID"
111 #else
112 #define ID(sb) (&((struct obdfs_sb_info *)( & ## sb ## ->u.generic_sbp))->osi_conn)
113 #define IID(inode) (&((struct obdfs_sb_info *)( & ## inode->i_sb ## ->u.generic_sbp))->osi_conn)
114 #endif
115
116 #define OBDFS_SUPER_MAGIC 0x4711
117
118 #endif
119