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