Whamcloud - gitweb
merge b_devel into HEAD, which will become 0.7.3
[fs/lustre-release.git] / lustre / obdclass / fsfilt_ext3.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  lustre/lib/fsfilt_ext3.c
5  *  Lustre filesystem abstraction routines
6  *
7  *  Copyright (C) 2002, 2003 Cluster File Systems, Inc.
8  *   Author: Andreas Dilger <adilger@clusterfs.com>
9  *
10  *   This file is part of Lustre, http://www.lustre.org.
11  *
12  *   Lustre is free software; you can redistribute it and/or
13  *   modify it under the terms of version 2 of the GNU General Public
14  *   License as published by the Free Software Foundation.
15  *
16  *   Lustre is distributed in the hope that it will be useful,
17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *   GNU General Public License for more details.
20  *
21  *   You should have received a copy of the GNU General Public License
22  *   along with Lustre; if not, write to the Free Software
23  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26 #define DEBUG_SUBSYSTEM S_FILTER
27
28 #include <linux/fs.h>
29 #include <linux/jbd.h>
30 #include <linux/slab.h>
31 #include <linux/pagemap.h>
32 #include <linux/quotaops.h>
33 #include <linux/ext3_fs.h>
34 #include <linux/ext3_jbd.h>
35 #include <linux/version.h>
36 /* XXX ugh */
37 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
38  #include <linux/ext3_xattr.h>
39 #else 
40  #include <linux/../../fs/ext3/xattr.h>
41 #endif
42 #include <linux/kp30.h>
43 #include <linux/lustre_fsfilt.h>
44 #include <linux/obd.h>
45 #include <linux/obd_class.h>
46 #include <linux/module.h>
47
48 static kmem_cache_t *fcb_cache;
49 static atomic_t fcb_cache_count = ATOMIC_INIT(0);
50
51 struct fsfilt_cb_data {
52         struct journal_callback cb_jcb; /* jbd private data - MUST BE FIRST */
53         fsfilt_cb_t cb_func;            /* MDS/OBD completion function */
54         struct obd_device *cb_obd;      /* MDS/OBD completion device */
55         __u64 cb_last_rcvd;             /* MDS/OST last committed operation */
56         void *cb_data;                  /* MDS/OST completion function data */
57 };
58
59 #define EXT3_XATTR_INDEX_LUSTRE         5
60 #define XATTR_LUSTRE_MDS_OBJID          "system.lustre_mds_objid"
61
62 /*
63  * We don't currently need any additional blocks for rmdir and
64  * unlink transactions because we are storing the OST oa_id inside
65  * the inode (which we will be changing anyways as part of this
66  * transaction).
67  */
68 static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private)
69 {
70         /* For updates to the last recieved file */
71         int nblocks = EXT3_DATA_TRANS_BLOCKS;
72         void *handle;
73
74         switch(op) {
75         case FSFILT_OP_CREATE_LOG:
76                 nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS+EXT3_DATA_TRANS_BLOCKS;
77                 op = FSFILT_OP_CREATE;
78                 break;
79         case FSFILT_OP_UNLINK_LOG:
80                 nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS+EXT3_DATA_TRANS_BLOCKS;
81                 op = FSFILT_OP_UNLINK;
82                 break;
83         }
84
85         switch(op) {
86         case FSFILT_OP_RMDIR:
87         case FSFILT_OP_UNLINK:
88                 nblocks += EXT3_DELETE_TRANS_BLOCKS;
89                 break;
90         case FSFILT_OP_RENAME:
91                 /* modify additional directory */
92                 nblocks += EXT3_DATA_TRANS_BLOCKS;
93                 /* no break */
94         case FSFILT_OP_SYMLINK:
95                 /* additional block + block bitmap + GDT for long symlink */
96                 nblocks += 3;
97                 /* no break */
98         case FSFILT_OP_CREATE:
99         case FSFILT_OP_MKDIR:
100         case FSFILT_OP_MKNOD:
101                 /* modify one inode + block bitmap + GDT */
102                 nblocks += 3;
103                 /* no break */
104         case FSFILT_OP_LINK:
105                 /* modify parent directory */
106                 nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS+EXT3_DATA_TRANS_BLOCKS;
107                 break;
108         case FSFILT_OP_SETATTR:
109                 /* Setattr on inode */
110                 nblocks += 1;
111                 break;
112         default: CERROR("unknown transaction start op %d\n", op);
113                  LBUG();
114         }
115
116         LASSERT(current->journal_info == desc_private);
117         lock_kernel();
118         handle = journal_start(EXT3_JOURNAL(inode), nblocks);
119         unlock_kernel();
120
121         return handle;
122 }
123
124 /*
125  * Calculate the number of buffer credits needed to write multiple pages in
126  * a single ext3 transaction.  No, this shouldn't be here, but as yet ext3
127  * doesn't have a nice API for calculating this sort of thing in advance.
128  *
129  * See comment above ext3_writepage_trans_blocks for details.  We assume
130  * no data journaling is being done, but it does allow for all of the pages
131  * being non-contiguous.  If we are guaranteed contiguous pages we could
132  * reduce the number of (d)indirect blocks a lot.
133  *
134  * With N blocks per page and P pages, for each inode we have at most:
135  * N*P indirect
136  * min(N*P, blocksize/4 + 1) dindirect blocks
137  * niocount tindirect
138  *
139  * For the entire filesystem, we have at most:
140  * min(sum(nindir + P), ngroups) bitmap blocks (from the above)
141  * min(sum(nindir + P), gdblocks) group descriptor blocks (from the above)
142  * objcount inode blocks
143  * 1 superblock
144  * 2 * EXT3_SINGLEDATA_TRANS_BLOCKS for the quota files
145  *
146  * 1 EXT3_DATA_TRANS_BLOCKS for the last_rcvd update.
147  */
148 static int fsfilt_ext3_credits_needed(int objcount, struct fsfilt_objinfo *fso)
149 {
150         struct super_block *sb = fso->fso_dentry->d_inode->i_sb;
151         int blockpp = 1 << (PAGE_CACHE_SHIFT - sb->s_blocksize_bits);
152         int addrpp = EXT3_ADDR_PER_BLOCK(sb) * blockpp;
153         int nbitmaps = 0;
154         int ngdblocks = 0;
155         int needed = objcount + 1;
156         int i;
157
158         for (i = 0; i < objcount; i++, fso++) {
159                 int nblocks = fso->fso_bufcnt * blockpp;
160                 int ndindirect = min(nblocks, addrpp + 1);
161                 int nindir = nblocks + ndindirect + 1;
162
163                 nbitmaps += nindir + nblocks;
164                 ngdblocks += nindir + nblocks;
165
166                 needed += nindir;
167         }
168
169         /* Assumes ext3 and ext3 have same sb_info layout at the start. */
170         if (nbitmaps > EXT3_SB(sb)->s_groups_count)
171                 nbitmaps = EXT3_SB(sb)->s_groups_count;
172         if (ngdblocks > EXT3_SB(sb)->s_gdb_count)
173                 ngdblocks = EXT3_SB(sb)->s_gdb_count;
174
175         needed += nbitmaps + ngdblocks;
176
177         /* last_rcvd update */
178         needed += EXT3_DATA_TRANS_BLOCKS;
179
180 #ifdef CONFIG_QUOTA
181         /* We assume that there will be 1 bit set in s_dquot.flags for each
182          * quota file that is active.  This is at least true for now.
183          */
184         needed += hweight32(sb_any_quota_enabled(sb)) *
185                 EXT3_SINGLEDATA_TRANS_BLOCKS;
186 #endif
187
188         return needed;
189 }
190
191 /* We have to start a huge journal transaction here to hold all of the
192  * metadata for the pages being written here.  This is necessitated by
193  * the fact that we do lots of prepare_write operations before we do
194  * any of the matching commit_write operations, so even if we split
195  * up to use "smaller" transactions none of them could complete until
196  * all of them were opened.  By having a single journal transaction,
197  * we eliminate duplicate reservations for common blocks like the
198  * superblock and group descriptors or bitmaps.
199  *
200  * We will start the transaction here, but each prepare_write will
201  * add a refcount to the transaction, and each commit_write will
202  * remove a refcount.  The transaction will be closed when all of
203  * the pages have been written.
204  */
205 static void *fsfilt_ext3_brw_start(int objcount, struct fsfilt_objinfo *fso,
206                                    int niocount, void *desc_private)
207 {
208         journal_t *journal;
209         handle_t *handle;
210         int needed;
211         ENTRY;
212
213         LASSERT(current->journal_info == desc_private);
214         journal = EXT3_SB(fso->fso_dentry->d_inode->i_sb)->s_journal;
215         needed = fsfilt_ext3_credits_needed(objcount, fso);
216
217         /* The number of blocks we could _possibly_ dirty can very large.
218          * We reduce our request if it is absurd (and we couldn't get that
219          * many credits for a single handle anyways).
220          *
221          * At some point we have to limit the size of I/Os sent at one time,
222          * increase the size of the journal, or we have to calculate the
223          * actual journal requirements more carefully by checking all of
224          * the blocks instead of being maximally pessimistic.  It remains to
225          * be seen if this is a real problem or not.
226          */
227         if (needed > journal->j_max_transaction_buffers) {
228                 CERROR("want too many journal credits (%d) using %d instead\n",
229                        needed, journal->j_max_transaction_buffers);
230                 needed = journal->j_max_transaction_buffers;
231         }
232
233         lock_kernel();
234         handle = journal_start(journal, needed);
235         unlock_kernel();
236         if (IS_ERR(handle))
237                 CERROR("can't get handle for %d credits: rc = %ld\n", needed,
238                        PTR_ERR(handle));
239         else
240                 LASSERT(handle->h_buffer_credits >= needed);
241
242         RETURN(handle);
243 }
244
245 static int fsfilt_ext3_commit(struct inode *inode, void *h, int force_sync)
246 {
247         int rc;
248         handle_t *handle = h;
249
250         if (force_sync)
251                 handle->h_sync = 1; /* recovery likes this */
252
253         lock_kernel();
254         rc = journal_stop(handle);
255         unlock_kernel();
256
257         return rc;
258 }
259
260 static int fsfilt_ext3_setattr(struct dentry *dentry, void *handle,
261                                struct iattr *iattr, int do_trunc)
262 {
263         struct inode *inode = dentry->d_inode;
264         int rc;
265
266         lock_kernel();
267
268         /* A _really_ horrible hack to avoid removing the data stored
269          * in the block pointers; this is really the "small" stripe MD data.
270          * We can avoid further hackery by virtue of the MDS file size being
271          * zero all the time (which doesn't invoke block truncate at unlink
272          * time), so we assert we never change the MDS file size from zero. */
273         if (iattr->ia_valid & ATTR_SIZE && !do_trunc) {
274                 /* ATTR_SIZE would invoke truncate: clear it */
275                 iattr->ia_valid &= ~ATTR_SIZE;
276                 EXT3_I(inode)->i_disksize = inode->i_size = iattr->ia_size;
277
278                 /* make sure _something_ gets set - so new inode
279                  * goes to disk (probably won't work over XFS */
280                 if (!(iattr->ia_valid & (ATTR_MODE | ATTR_MTIME | ATTR_CTIME))){
281                         iattr->ia_valid |= ATTR_MODE;
282                         iattr->ia_mode = inode->i_mode;
283                 }
284         }
285
286         /* Don't allow setattr to change file type */
287         iattr->ia_mode = (inode->i_mode & S_IFMT)|(iattr->ia_mode & ~S_IFMT);
288
289         if (inode->i_op->setattr) {
290                 rc = inode->i_op->setattr(dentry, iattr);
291         } else {
292                 rc = inode_change_ok(inode, iattr);
293                 if (!rc)
294                         rc = inode_setattr(inode, iattr);
295         }
296
297         unlock_kernel();
298
299         return rc;
300 }
301
302 static int fsfilt_ext3_set_md(struct inode *inode, void *handle,
303                               void *lmm, int lmm_size)
304 {
305         int rc;
306
307         /* Nasty hack city - store stripe MD data in the block pointers if
308          * it will fit, because putting it in an EA currently kills the MDS
309          * performance.  We'll fix this with "fast EAs" in the future.
310          */
311         if (inode->i_blocks == 0 && lmm_size <= sizeof(EXT3_I(inode)->i_data) -
312                                             sizeof(EXT3_I(inode)->i_data[0])) {
313                 /* XXX old_size is debugging only */
314                 int old_size = EXT3_I(inode)->i_data[0];
315                 if (old_size != 0) {
316                         LASSERT(old_size < sizeof(EXT3_I(inode)->i_data));
317                         CERROR("setting EA on %lu again... interesting\n",
318                                inode->i_ino);
319                 }
320
321                 EXT3_I(inode)->i_data[0] = cpu_to_le32(lmm_size);
322                 memcpy(&EXT3_I(inode)->i_data[1], lmm, lmm_size);
323                 mark_inode_dirty(inode);
324                 return 0;
325         } else {
326                 down(&inode->i_sem);
327                 lock_kernel();
328 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
329                 rc = ext3_xattr_set(handle, inode, EXT3_XATTR_INDEX_LUSTRE,
330                                     XATTR_LUSTRE_MDS_OBJID, lmm, lmm_size, 0);
331 #else
332                 rc = ext3_xattr_set_handle(handle, inode, 
333                                            EXT3_XATTR_INDEX_LUSTRE,
334                                            XATTR_LUSTRE_MDS_OBJID, lmm, 
335                                            lmm_size, 0);
336 #endif
337                 unlock_kernel();
338                 up(&inode->i_sem);
339         }
340
341         if (rc)
342                 CERROR("error adding MD data to inode %lu: rc = %d\n",
343                        inode->i_ino, rc);
344         return rc;
345 }
346
347 static int fsfilt_ext3_get_md(struct inode *inode, void *lmm, int lmm_size)
348 {
349         int rc;
350
351         if (inode->i_blocks == 0 && EXT3_I(inode)->i_data[0]) {
352                 int size = le32_to_cpu(EXT3_I(inode)->i_data[0]);
353                 LASSERT(size < sizeof(EXT3_I(inode)->i_data));
354                 if (lmm) {
355                         if (size > lmm_size)
356                                 return -ERANGE;
357                         memcpy(lmm, &EXT3_I(inode)->i_data[1], size);
358                 }
359                 return size;
360         }
361
362         down(&inode->i_sem);
363         lock_kernel();
364         rc = ext3_xattr_get(inode, EXT3_XATTR_INDEX_LUSTRE,
365                             XATTR_LUSTRE_MDS_OBJID, lmm, lmm_size);
366         unlock_kernel();
367         up(&inode->i_sem);
368
369         /* This gives us the MD size */
370         if (lmm == NULL)
371                 return (rc == -ENODATA) ? 0 : rc;
372
373         if (rc < 0) {
374                 CDEBUG(D_INFO, "error getting EA %s from inode %lu: "
375                        "rc = %d\n", XATTR_LUSTRE_MDS_OBJID, inode->i_ino, rc);
376                 memset(lmm, 0, lmm_size);
377                 return (rc == -ENODATA) ? 0 : rc;
378         }
379
380         return rc;
381 }
382
383 static ssize_t fsfilt_ext3_readpage(struct file *file, char *buf, size_t count,
384                                     loff_t *off)
385 {
386         struct inode *inode = file->f_dentry->d_inode;
387         int rc = 0;
388
389         if (S_ISREG(inode->i_mode))
390                 rc = file->f_op->read(file, buf, count, off);
391         else {
392                 const int blkbits = inode->i_sb->s_blocksize_bits;
393                 const int blksize = inode->i_sb->s_blocksize;
394
395                 CDEBUG(D_EXT2, "reading "LPSZ" at dir %lu+%llu\n",
396                        count, inode->i_ino, *off);
397                 while (count > 0) {
398                         struct buffer_head *bh;
399
400                         bh = NULL;
401                         if (*off < inode->i_size) {
402                                 int err = 0;
403
404                                 bh = ext3_bread(NULL, inode, *off >> blkbits,
405                                                 0, &err);
406
407                                 CDEBUG(D_EXT2, "read %u@%llu\n", blksize, *off);
408
409                                 if (bh) {
410                                         memcpy(buf, bh->b_data, blksize);
411                                         brelse(bh);
412                                 } else if (err) {
413                                         /* XXX in theory we should just fake
414                                          * this buffer and continue like ext3,
415                                          * especially if this is a partial read
416                                          */
417                                         CERROR("error read dir %lu+%llu: %d\n",
418                                                inode->i_ino, *off, err);
419                                         RETURN(err);
420                                 }
421                         }
422                         if (!bh) {
423                                 struct ext3_dir_entry_2 *fake = (void *)buf;
424
425                                 CDEBUG(D_EXT2, "fake %u@%llu\n", blksize, *off);
426                                 memset(fake, 0, sizeof(*fake));
427                                 fake->rec_len = cpu_to_le32(blksize);
428                         }
429                         count -= blksize;
430                         buf += blksize;
431                         *off += blksize;
432                         rc += blksize;
433                 }
434         }
435
436         return rc;
437 }
438
439 static void fsfilt_ext3_cb_func(struct journal_callback *jcb, int error)
440 {
441         struct fsfilt_cb_data *fcb = (struct fsfilt_cb_data *)jcb;
442
443         fcb->cb_func(fcb->cb_obd, fcb->cb_last_rcvd, fcb->cb_data, error);
444
445         OBD_SLAB_FREE(fcb, fcb_cache, sizeof *fcb);
446         atomic_dec(&fcb_cache_count);
447 }
448
449 static int fsfilt_ext3_set_last_rcvd(struct obd_device *obd, __u64 last_rcvd,
450                                      void *handle, fsfilt_cb_t cb_func,
451                                      void *cb_data)
452 {
453         struct fsfilt_cb_data *fcb;
454
455         OBD_SLAB_ALLOC(fcb, fcb_cache, GFP_NOFS, sizeof *fcb);
456         if (fcb == NULL)
457                 RETURN(-ENOMEM);
458
459         atomic_inc(&fcb_cache_count);
460         fcb->cb_func = cb_func;
461         fcb->cb_obd = obd;
462         fcb->cb_last_rcvd = last_rcvd;
463         fcb->cb_data = cb_data;
464
465         CDEBUG(D_EXT2, "set callback for last_rcvd: "LPD64"\n", last_rcvd);
466         lock_kernel();
467         journal_callback_set(handle, fsfilt_ext3_cb_func,
468                              (struct journal_callback *)fcb);
469         unlock_kernel();
470
471         return 0;
472 }
473
474 static int fsfilt_ext3_journal_data(struct file *filp)
475 {
476 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
477         /* bug 1576: enable data journaling on 2.5 when appropriate */
478         struct inode *inode = filp->f_dentry->d_inode;
479         EXT3_I(inode)->i_flags |= EXT3_JOURNAL_DATA_FL;
480 #endif
481         return 0;
482 }
483
484 /*
485  * We need to hack the return value for the free inode counts because
486  * the current EA code requires one filesystem block per inode with EAs,
487  * so it is possible to run out of blocks before we run out of inodes.
488  *
489  * This can be removed when the ext3 EA code is fixed.
490  */
491 static int fsfilt_ext3_statfs(struct super_block *sb, struct obd_statfs *osfs)
492 {
493         struct kstatfs sfs;
494         int rc = vfs_statfs(sb, &sfs);
495
496         if (!rc && sfs.f_bfree < sfs.f_ffree) {
497                 sfs.f_files = (sfs.f_files - sfs.f_ffree) + sfs.f_bfree;
498                 sfs.f_ffree = sfs.f_bfree;
499         }
500
501         statfs_pack(osfs, &sfs);
502         return rc;
503 }
504
505 static int fsfilt_ext3_sync(struct super_block *sb)
506 {
507         return ext3_force_commit(sb);
508 }
509
510 extern int ext3_prep_san_write(struct inode *inode, long *blocks,
511                                int nblocks, loff_t newsize);
512 static int fsfilt_ext3_prep_san_write(struct inode *inode, long *blocks,
513                                       int nblocks, loff_t newsize)
514 {
515         return ext3_prep_san_write(inode, blocks, nblocks, newsize);
516 }
517
518 static int fsfilt_ext3_read_record(struct file * file, char *buf,
519                                    int size, loff_t *offs)
520 {
521         struct buffer_head *bh;
522         unsigned long block, boffs;
523         struct inode *inode = file->f_dentry->d_inode;
524         int err;
525
526         if (inode->i_size < *offs + size) {
527                 CERROR("file size %llu is too short for read %u@%llu\n",
528                        inode->i_size, size, *offs);
529                 return -EIO;
530         }
531
532         block = *offs >> inode->i_blkbits;
533         bh = ext3_bread(NULL, inode, block, 0, &err);
534         if (!bh) {
535                 CERROR("can't read block: %d\n", err);
536                 return err;
537         }
538
539         boffs = (unsigned)*offs % bh->b_size;
540         if (boffs + size > bh->b_size) {
541                 CERROR("request crosses block's border. offset %llu, size %u\n",
542                        *offs, size);
543                 brelse(bh);
544                 return -EIO;
545         }
546
547         memcpy(buf, bh->b_data + boffs, size);
548         brelse(bh);
549         *offs += size;
550         return size;
551 }
552
553 static int fsfilt_ext3_write_record(struct file * file, char *buf,
554                                     int size, loff_t *offs)
555 {
556         struct buffer_head *bh;
557         unsigned long block, boffs;
558         struct inode *inode = file->f_dentry->d_inode;
559         loff_t old_size = inode->i_size;
560         journal_t *journal;
561         handle_t *handle;
562         int err;
563
564         journal = EXT3_SB(inode->i_sb)->s_journal;
565         handle = journal_start(journal, EXT3_DATA_TRANS_BLOCKS + 2);
566         if (handle == NULL) {
567                 CERROR("can't start transaction\n");
568                 return -EIO;
569         }
570
571         block = *offs >> inode->i_blkbits;
572         if (*offs + size > inode->i_size) {
573                 down(&inode->i_sem);
574                 if (*offs + size > inode->i_size)
575                         inode->i_size = ((loff_t)block + 1) << inode->i_blkbits;
576                 up(&inode->i_sem);
577         }
578
579         bh = ext3_bread(handle, inode, block, 1, &err);
580         if (!bh) {
581                 CERROR("can't read/create block: %d\n", err);
582                 goto out;
583         }
584
585         /* This is a hack only needed because ext3_get_block_handle() updates
586          * i_disksize after marking the inode dirty in ext3_splice_branch().
587          * We will fix that when we get a chance, as ext3_mark_inode_dirty()
588          * is not without cost, nor is it even exported.
589          */
590         if (inode->i_size > old_size)
591                 mark_inode_dirty(inode);
592
593         boffs = (unsigned)*offs % bh->b_size;
594         if (boffs + size > bh->b_size) {
595                 CERROR("request crosses block's border. offset %llu, size %u\n",
596                        *offs, size);
597                 err = -EIO;
598                 goto out;
599         }
600
601         err = ext3_journal_get_write_access(handle, bh);
602         if (err) {
603                 CERROR("journal_get_write_access() returned error %d\n", err);
604                 goto out;
605         }
606         memcpy(bh->b_data + boffs, buf, size);
607         err = ext3_journal_dirty_metadata(handle, bh);
608         if (err) {
609                 CERROR("journal_dirty_metadata() returned error %d\n", err);
610                 goto out;
611         }
612         err = size;
613 out:
614         if (bh)
615                 brelse(bh);
616         journal_stop(handle);
617         if (err > 0)
618                 *offs += size;
619         return err;
620 }
621
622 static struct fsfilt_operations fsfilt_ext3_ops = {
623         fs_type:                "ext3",
624         fs_owner:               THIS_MODULE,
625         fs_start:               fsfilt_ext3_start,
626         fs_brw_start:           fsfilt_ext3_brw_start,
627         fs_commit:              fsfilt_ext3_commit,
628         fs_setattr:             fsfilt_ext3_setattr,
629         fs_set_md:              fsfilt_ext3_set_md,
630         fs_get_md:              fsfilt_ext3_get_md,
631         fs_readpage:            fsfilt_ext3_readpage,
632         fs_journal_data:        fsfilt_ext3_journal_data,
633         fs_set_last_rcvd:       fsfilt_ext3_set_last_rcvd,
634         fs_statfs:              fsfilt_ext3_statfs,
635         fs_sync:                fsfilt_ext3_sync,
636         fs_prep_san_write:      fsfilt_ext3_prep_san_write,
637         fs_write_record:        fsfilt_ext3_write_record,
638         fs_read_record:         fsfilt_ext3_read_record,
639 };
640
641 static int __init fsfilt_ext3_init(void)
642 {
643         int rc;
644
645         //rc = ext3_xattr_register();
646         fcb_cache = kmem_cache_create("fsfilt_ext3_fcb",
647                                       sizeof(struct fsfilt_cb_data), 0,
648                                       0, NULL, NULL);
649         if (!fcb_cache) {
650                 CERROR("error allocating fsfilt journal callback cache\n");
651                 GOTO(out, rc = -ENOMEM);
652         }
653
654         rc = fsfilt_register_ops(&fsfilt_ext3_ops);
655
656         if (rc)
657                 kmem_cache_destroy(fcb_cache);
658 out:
659         return rc;
660 }
661
662 static void __exit fsfilt_ext3_exit(void)
663 {
664         int rc;
665
666         fsfilt_unregister_ops(&fsfilt_ext3_ops);
667         rc = kmem_cache_destroy(fcb_cache);
668
669         if (rc || atomic_read(&fcb_cache_count)) {
670                 CERROR("can't free fsfilt callback cache: count %d, rc = %d\n",
671                        atomic_read(&fcb_cache_count), rc);
672         }
673
674         //rc = ext3_xattr_unregister();
675 }
676
677 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
678 MODULE_DESCRIPTION("Lustre ext3 Filesystem Helper v0.1");
679 MODULE_LICENSE("GPL");
680
681 module_init(fsfilt_ext3_init);
682 module_exit(fsfilt_ext3_exit);