Whamcloud - gitweb
Over of the changes:
[fs/lustre-release.git] / lustre / obdfs / notes.txt
1 Considerations for an API between OBD's and OBDFS
2
3
4 OBDFS 
5
6 Methods needed:
7
8 struct super_operations {
9         void (*read_inode) (struct inode *);
10         void (*write_inode) (struct inode *);
11         void (*put_inode) (struct inode *);
12         void (*delete_inode) (struct inode *);
13         int (*notify_change) (struct dentry *, struct iattr *);
14         void (*put_super) (struct super_block *);
15         void (*write_super) (struct super_block *);
16         int (*statfs) (struct super_block *, struct statfs *, int);
17 *       int (*remount_fs) (struct super_block *, int *, char *);
18         void (*clear_inode) (struct inode *);
19 *       void (*umount_begin) (struct super_block *);
20 };
21
22
23 read_inode:
24
25 Called from function iget(ino, dev) - through get_new_inode.
26 Typically called only when a VFS inode is instantiated by FS, i.e.
27 upon lookup, create, mkdir, or upon mounting for the / inode.
28
29   -  executed for new inodes and for existing inodes
30   -  for new inodes, avoid traffic to disk
31
32 E.g:
33
34 lookup("name in dir-inode")
35 {
36         get data from dir-inode; 
37         find ino of "name" in this data;
38         iget(sb(dev), ino); 
39         ---> calls read_inode 
40              ----> obd_getattr(obj-no = ino)
41 }
42
43 create("name in dir-inode") 
44 {
45         get ino for name from pre-alloced obj-no's
46         ---> may call obd_prealloc_ids(hint)
47
48         iget(sb(dev), ino)
49         ---> call read_inode 
50              ---> do not contact OBD, fill in from FS
51
52         change data from dir-inode, to contain ("name, ino");
53 }
54
55 mkdir("name in dir-inode")
56 {
57         as above
58 }
59
60 read_super(dev, data)
61 {
62         struct obdfs_sb *sb = ... ;
63         obd_connect(dev, &sb->obdfs_conn_info);
64
65         iget(sb, sb->obdfs_conn_info->conn_ino);
66
67
68 }
69
70 We currently have:
71
72 struct obd_conn_info {
73         unsigned int conn_id;
74         unsigned long conn_ino;
75         unsigned long conn_blocksize;
76         unsigned char conn_blocksize_bits;
77 };
78
79 read_inode(inode)
80 {
81         struct iattr attr;
82
83         
84         if ( inode in inode_attr cache ) {
85                 get_attr_from_cache(inode, &attr);
86         } else {
87                 obd_getattr(conn_id, inode->i_ino, &attr);
88         }               
89
90         inode_setattr(inode, &attr);
91 }
92
93 Write_inode is called from the bdflush (sync_dev) routines, through
94 write_inode, sync_inode, sync_list, sync_inodes etc:
95
96 void sync_dev(kdev_t dev)
97 {
98         sync_buffers(dev, 0);
99         sync_supers(dev);
100         sync_inodes(dev);
101         sync_buffers(dev, 0);
102         DQUOT_SYNC(dev);
103         /*
104          * FIXME(eric) we need to sync the physical devices here.
105          * This is because some (scsi) controllers have huge amounts of
106          * cache onboard (hundreds of Mb), and we need to instruct
107          * them to commit all of the dirty memory to disk, and we should
108          * not return until this has happened.
109          *
110          * This would need to get implemented by going through the assorted
111          * layers so that each block major number can be synced, and this
112          * would call down into the upper and mid-layer scsi.
113          */
114 }
115
116 This sync_inodes function is responsible (for "block" disk file
117 systems) for copying the modified inode metadata into the buffer
118 cache.  The sync_buffers call which follows sync_inodes is responsible
119 for writing back this meta data.  For OBD's this is different.
120
121 I expect the following routine to be there:
122
123 sync_inode_pages(dev,0);
124 sync_supers(dev);
125 sync_inode_metadata(dev);
126
127
128 The statfs function should return simple summary information available 
129 on the disk: %free, total space, etc.    May require a new obd_command.
130
131 Similarly write_super would instruct the disk to commit any pending
132 data.  This is called from do_unmount just before put_super (the
133 latter breaks down the vm super block  structure).  
134
135 Write_super should: 
136 - undo pre-allocated inode numbers
137
138 The disk itself also needs a cleanup function.
139
140 struct file_operations {
141         loff_t (*llseek) (struct file *, loff_t, int);
142         ssize_t (*read) (struct file *, char *, size_t, loff_t *);
143         ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
144         int (*readdir) (struct file *, void *, filldir_t);
145         unsigned int (*poll) (struct file *, struct poll_table_struct *);
146         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
147         int (*mmap) (struct file *, struct vm_area_struct *);
148         int (*open) (struct inode *, struct file *);
149         int (*flush) (struct file *);
150         int (*release) (struct inode *, struct file *);
151         int (*fsync) (struct file *, struct dentry *);
152         int (*fasync) (int, struct file *, int);
153         int (*check_media_change) (kdev_t dev);
154         int (*revalidate) (kdev_t dev);
155         int (*lock) (struct file *, int, struct file_lock *);
156 };
157
158
159 struct inode_operations {
160         struct file_operations * default_file_ops;
161         int (*create) (struct inode *,struct dentry *,int);
162         struct dentry * (*lookup) (struct inode *,struct dentry *);
163         int (*link) (struct dentry *,struct inode *,struct dentry *);
164         int (*unlink) (struct inode *,struct dentry *);
165         int (*symlink) (struct inode *,struct dentry *,const char *);
166         int (*mkdir) (struct inode *,struct dentry *,int);
167         int (*rmdir) (struct inode *,struct dentry *);
168         int (*mknod) (struct inode *,struct dentry *,int,int);
169         int (*rename) (struct inode *, struct dentry *,
170                         struct inode *, struct dentry *);
171         int (*readlink) (struct dentry *, char *,int);
172         struct dentry * (*follow_link) (struct dentry *, struct dentry *, unsigned int);
173         /*
174          * the order of these functions within the VFS template has been
175          * changed because SMP locking has changed: from now on all get_block,
176          * readpage, writepage and flushpage functions are supposed to do
177          * whatever locking they need to get proper SMP operation - for
178          * now in most cases this means a lock/unlock_kernel at entry/exit.
179          * [The new order is also slightly more logical :)]
180          */
181         /*
182          * Generic block allocator exported by the lowlevel fs. All metadata
183          * details are handled by the lowlevel fs, all 'logical data content'
184          * details are handled by the highlevel block layer.
185          */
186         int (*get_block) (struct inode *, long, struct buffer_head *, int);
187
188         int (*readpage) (struct file *, struct page *);
189         int (*writepage) (struct file *, struct page *);
190         int (*flushpage) (struct inode *, struct page *, unsigned long);
191
192         void (*truncate) (struct inode *);
193         int (*permission) (struct inode *, int);
194         int (*smap) (struct inode *,int);
195         int (*revalidate) (struct dentry *);
196 };
197
198