1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/lib/fsfilt_smfs.c
5 * Lustre filesystem abstraction routines
7 * Copyright (C) 2004 Cluster File Systems, Inc.
8 * Author: Wang Di <wangdi@clusterfs.com>
10 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
26 #define DEBUG_SUBSYSTEM S_FILTER
29 #include <linux/jbd.h>
30 #include <linux/slab.h>
31 #include <linux/pagemap.h>
32 #include <linux/quotaops.h>
33 #include <linux/version.h>
34 #include <linux/kp30.h>
35 #include <linux/lustre_fsfilt.h>
36 #include <linux/lustre_smfs.h>
37 #include <linux/obd.h>
38 #include <linux/obd_class.h>
39 #include <linux/module.h>
40 #include <linux/init.h>
42 #include <linux/lustre_snap.h>
43 #include <linux/lustre_smfs.h>
44 static void *fsfilt_smfs_start(struct inode *inode, int op,
45 void *desc_private, int logs)
48 struct inode *cache_inode = I2CI(inode);
49 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
51 if (cache_fsfilt == NULL)
54 SMFS_TRANS_OP(inode, op);
56 if (!cache_fsfilt->fs_start)
57 return ERR_PTR(-ENOSYS);
59 handle = cache_fsfilt->fs_start(cache_inode, op, desc_private, logs);
63 static void *fsfilt_smfs_brw_start(int objcount, struct fsfilt_objinfo *fso,
64 int niocount, struct niobuf_local *nb,
65 void *desc_private, int logs)
67 struct fsfilt_operations *cache_fsfilt;
68 struct dentry *cache_dentry = NULL;
69 struct inode *cache_inode = NULL;
70 struct fsfilt_objinfo cache_fso;
74 cache_fsfilt = I2FOPS(fso->fso_dentry->d_inode);
75 if (cache_fsfilt == NULL)
78 cache_inode = I2CI(fso->fso_dentry->d_inode);
79 cache_dentry = pre_smfs_dentry(NULL, cache_inode, fso->fso_dentry);
82 GOTO(exit, rc = ERR_PTR(-ENOMEM));
84 cache_fso.fso_dentry = cache_dentry;
85 cache_fso.fso_bufcnt = fso->fso_bufcnt;
87 if (!cache_fsfilt->fs_brw_start)
88 return ERR_PTR(-ENOSYS);
90 rc = cache_fsfilt->fs_brw_start(objcount, &cache_fso, niocount, nb,
93 post_smfs_dentry(cache_dentry);
97 /* FIXME-WANGDI: here we can easily have inode == NULL due to
98 mds_open() behavior. It passes NULL inode to mds_finish_transno()
99 sometimes. Probably we should have spare way to get cache fsfilt
101 static int fsfilt_smfs_commit(struct super_block *sb, struct inode *inode,
102 void *h, int force_sync)
104 struct fsfilt_operations *cache_fsfilt = S2SMI(sb)->sm_cache_fsfilt;
105 struct super_block *csb = S2CSB(sb);
106 struct inode *cache_inode = NULL;
110 cache_inode = I2CI(inode);
112 if (cache_fsfilt == NULL)
115 if (!cache_fsfilt->fs_commit)
118 rc = cache_fsfilt->fs_commit(csb, cache_inode, h, force_sync);
123 static int fsfilt_smfs_commit_async(struct inode *inode, void *h,
126 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
127 struct inode *cache_inode = NULL;
130 cache_inode = I2CI(inode);
131 if (cache_fsfilt == NULL)
134 if (!cache_fsfilt->fs_commit_async)
137 rc = cache_fsfilt->fs_commit_async(cache_inode, h, wait_handle);
142 static int fsfilt_smfs_commit_wait(struct inode *inode, void *h)
144 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
145 struct inode *cache_inode = NULL;
148 cache_inode = I2CI(inode);
149 if (cache_fsfilt == NULL)
152 if (!cache_fsfilt->fs_commit_wait)
155 rc = cache_fsfilt->fs_commit_wait(cache_inode, h);
160 static int fsfilt_smfs_setattr(struct dentry *dentry, void *handle,
161 struct iattr *iattr, int do_trunc)
163 struct fsfilt_operations *cache_fsfilt = I2FOPS(dentry->d_inode);
164 struct dentry *cache_dentry = NULL;
165 struct inode *cache_inode = NULL;
171 cache_inode = I2CI(dentry->d_inode);
173 cache_dentry = pre_smfs_dentry(NULL, cache_inode, dentry);
175 GOTO(exit, rc = -ENOMEM);
177 pre_smfs_inode(dentry->d_inode, cache_inode);
179 if (!cache_fsfilt->fs_setattr)
182 rc = cache_fsfilt->fs_setattr(cache_dentry, handle, iattr, do_trunc);
184 post_smfs_inode(dentry->d_inode, cache_inode);
187 struct super_block *sb = dentry->d_inode->i_sb;
189 if (SMFS_DO_REC(S2SMI(sb)) &&
190 SMFS_DO_INODE_REC(dentry->d_inode)) {
191 rc = smfs_rec_setattr(dentry->d_inode, dentry, iattr);
195 post_smfs_dentry(cache_dentry);
199 static int fsfilt_smfs_iocontrol(struct inode *inode, struct file *file,
200 unsigned int cmd, unsigned long arg)
202 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
203 struct inode *cache_inode = NULL;
204 struct smfs_file_info *sfi = NULL;
211 cache_inode = I2CI(inode);
219 if (sfi->magic != SMFS_FILE_MAGIC)
225 if (!cache_fsfilt->fs_iocontrol)
229 rc = cache_fsfilt->fs_iocontrol(cache_inode, sfi->c_file, cmd,
232 rc = cache_fsfilt->fs_iocontrol(cache_inode, NULL, cmd, arg);
235 /* FIXME-UMKA: Should this be in duplicate_inode()? */
236 if (rc == 0 && cmd == EXT3_IOC_SETFLAGS)
237 inode->i_flags = cache_inode->i_flags;
239 post_smfs_inode(inode, cache_inode);
244 static int fsfilt_smfs_set_md(struct inode *inode, void *handle,
245 void *lmm, int lmm_size)
247 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
248 struct inode *cache_inode = NULL;
254 cache_inode = I2CI(inode);
259 pre_smfs_inode(inode, cache_inode);
261 if (!cache_fsfilt->fs_set_md)
264 down(&cache_inode->i_sem);
265 rc = cache_fsfilt->fs_set_md(cache_inode, handle, lmm, lmm_size);
266 up(&cache_inode->i_sem);
268 post_smfs_inode(inode, cache_inode);
270 smfs_rec_md(inode, lmm, lmm_size);
275 /* Must be called with i_sem held */
276 static int fsfilt_smfs_get_md(struct inode *inode, void *lmm, int lmm_size)
278 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
279 struct inode *cache_inode = NULL;
285 cache_inode = I2CI(inode);
290 pre_smfs_inode(inode, cache_inode);
292 if (!cache_fsfilt->fs_get_md)
295 down(&cache_inode->i_sem);
296 rc = cache_fsfilt->fs_get_md(cache_inode, lmm, lmm_size);
297 up(&cache_inode->i_sem);
299 post_smfs_inode(inode, cache_inode);
304 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
305 static int fsfilt_smfs_send_bio(struct inode *inode, struct bio *bio)
307 static int fsfilt_smfs_send_bio(struct inode *inode, struct kiobuf *bio)
310 struct inode *cache_inode;
311 struct fsfilt_operations *cache_fsfilt;
313 cache_fsfilt = I2FOPS(inode);
317 cache_inode = I2CI(inode);
321 if (!cache_fsfilt->fs_send_bio)
324 return cache_fsfilt->fs_send_bio(cache_inode, bio);
328 fsfilt_smfs_getpage(struct inode *inode, long int index)
330 struct fsfilt_operations *cache_fsfilt;
331 struct inode *cache_inode;
333 cache_fsfilt = I2FOPS(inode);
335 RETURN(ERR_PTR(-EINVAL));
337 cache_inode = I2CI(inode);
339 RETURN(ERR_PTR(-EINVAL));
341 if (!cache_fsfilt->fs_getpage)
342 RETURN(ERR_PTR(-ENOSYS));
344 if (SMFS_DO_COW(S2SMI(inode->i_sb))) {
345 struct address_space_operations *aops =
346 cache_inode->i_mapping->a_ops;
347 if (aops->bmap(cache_inode->i_mapping, index)) {
348 struct inode *ind_inode = NULL;
349 struct inode *cache_ind = NULL;
350 struct page *page = NULL;
352 ind_inode = smfs_cow_get_ind(inode, index);
354 RETURN(ERR_PTR(-EIO));
356 cache_ind = I2CI(ind_inode);
357 /*FIXME cow inode should be bottom fs inode */
358 page = cache_fsfilt->fs_getpage(cache_ind, index);
364 return cache_fsfilt->fs_getpage(cache_inode, index);
367 static ssize_t fsfilt_smfs_readpage(struct file *file, char *buf,
368 size_t count, loff_t *off)
370 struct fsfilt_operations *cache_fsfilt;
371 struct smfs_file_info *sfi;
372 struct inode *cache_inode;
379 cache_fsfilt = I2FOPS(file->f_dentry->d_inode);
383 cache_inode = I2CI(file->f_dentry->d_inode);
388 if (sfi->magic != SMFS_FILE_MAGIC)
391 if (off != &(file->f_pos))
392 cache_ppos = &tmp_ppos;
394 cache_ppos = &sfi->c_file->f_pos;
397 pre_smfs_inode(file->f_dentry->d_inode, cache_inode);
400 if (smfs_dotsnap_inode(file->f_dentry->d_inode)) {
401 struct fsfilt_operations *snapops =
402 I2SNAPOPS(file->f_dentry->d_inode);
404 LASSERT(S_ISDIR(file->f_dentry->d_inode->i_mode));
406 rc = snapops->fs_read_dotsnap_dir_page(sfi->c_file, buf, count,
409 if (cache_fsfilt->fs_readpage)
410 rc = cache_fsfilt->fs_readpage(sfi->c_file, buf, count,
414 if (cache_fsfilt->fs_readpage)
415 rc = cache_fsfilt->fs_readpage(sfi->c_file, buf, count,
420 post_smfs_inode(file->f_dentry->d_inode, cache_inode);
421 duplicate_file(file, sfi->c_file);
427 static int fsfilt_smfs_add_journal_cb(struct obd_device *obd,
428 struct super_block *sb, __u64 last_rcvd,
429 void *handle, fsfilt_cb_t cb_func,
432 struct fsfilt_operations *cache_fsfilt = S2SMI(sb)->sm_cache_fsfilt;
433 struct super_block *csb = S2CSB(sb);
438 if (cache_fsfilt->fs_add_journal_cb)
439 rc = cache_fsfilt->fs_add_journal_cb(obd, csb, last_rcvd,
440 handle, cb_func, cb_data);
444 static int fsfilt_smfs_statfs(struct super_block *sb, struct obd_statfs *osfs)
446 struct fsfilt_operations *cache_fsfilt = S2SMI(sb)->sm_cache_fsfilt;
447 struct super_block *csb = S2CSB(sb);
453 if (!cache_fsfilt->fs_statfs)
456 rc = cache_fsfilt->fs_statfs(csb, osfs);
457 duplicate_sb(csb, sb);
462 static int fsfilt_smfs_sync(struct super_block *sb)
464 struct fsfilt_operations *cache_fsfilt = S2SMI(sb)->sm_cache_fsfilt;
465 struct super_block *csb = S2CSB(sb);
471 if (!cache_fsfilt->fs_sync)
474 rc = cache_fsfilt->fs_sync(csb);
479 int fsfilt_smfs_map_inode_pages(struct inode *inode, struct page **page,
480 int pages, unsigned long *blocks, int *created,
481 int create, struct semaphore *sem)
483 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
484 struct inode *cache_inode = NULL;
490 cache_inode = I2CI(inode);
495 if (!cache_fsfilt->fs_map_inode_pages)
498 down(&cache_inode->i_sem);
499 rc = cache_fsfilt->fs_map_inode_pages(cache_inode, page, pages, blocks,
500 created, create, sem);
501 up(&cache_inode->i_sem);
506 static int fsfilt_smfs_prep_san_write(struct inode *inode, long *blocks,
507 int nblocks, loff_t newsize)
509 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
510 struct inode *cache_inode = NULL;
516 cache_inode = I2CI(inode);
521 if (!cache_fsfilt->fs_prep_san_write)
524 down(&cache_inode->i_sem);
525 rc = cache_fsfilt->fs_prep_san_write(cache_inode, blocks, nblocks,
527 up(&cache_inode->i_sem);
532 static int fsfilt_smfs_read_record(struct file * file, void *buf,
533 int size, loff_t *offs)
535 struct fsfilt_operations *cache_fsfilt;
536 struct inode *cache_inode;
537 struct smfs_file_info *sfi;
543 cache_fsfilt = I2FOPS(file->f_dentry->d_inode);
547 cache_inode = I2CI(file->f_dentry->d_inode);
553 if (sfi->magic != SMFS_FILE_MAGIC) BUG();
555 if (offs != &(file->f_pos))
556 cache_ppos = &tmp_ppos;
558 cache_ppos = &sfi->c_file->f_pos;
561 pre_smfs_inode(file->f_dentry->d_inode, cache_inode);
563 if (!cache_fsfilt->fs_read_record)
566 rc = cache_fsfilt->fs_read_record(sfi->c_file, buf, size, cache_ppos);
569 post_smfs_inode(file->f_dentry->d_inode, cache_inode);
570 duplicate_file(file, sfi->c_file);
575 static int fsfilt_smfs_write_record(struct file *file, void *buf, int bufsize,
576 loff_t *offs, int force_sync)
578 struct fsfilt_operations *cache_fsfilt;
579 struct inode *cache_inode;
580 struct smfs_file_info *sfi;
587 cache_fsfilt = I2FOPS(file->f_dentry->d_inode);
591 cache_inode = I2CI(file->f_dentry->d_inode);
597 if (sfi->magic != SMFS_FILE_MAGIC)
600 if (offs != &(file->f_pos))
601 cache_ppos = &tmp_ppos;
603 cache_ppos = &sfi->c_file->f_pos;
606 pre_smfs_inode(file->f_dentry->d_inode, cache_inode);
608 if (!cache_fsfilt->fs_write_record)
611 rc = cache_fsfilt->fs_write_record(sfi->c_file, buf,
612 bufsize, cache_ppos, force_sync);
614 post_smfs_inode(file->f_dentry->d_inode, cache_inode);
615 duplicate_file(file, sfi->c_file);
620 static int fsfilt_smfs_post_setup(struct obd_device *obd, struct vfsmount *mnt,
621 struct dentry *root_dentry)
623 struct super_block *sb = NULL;
628 S2SMI(sb)->smsi_exp = obd->obd_self_export;
629 smfs_post_setup(sb, mnt);
630 if (SMFS_DO_REC(S2SMI(sb)))
631 rc = smfs_start_rec(sb, mnt);
635 obd->obd_llog_ctxt[LLOG_REINT_ORIG_CTXT] =
636 S2SMI(sb)->smsi_rec_log;
640 CERROR("can not do post setup in obd %p rc=%d", obd, rc);
645 static int fsfilt_smfs_post_cleanup(struct obd_device *obd,
646 struct vfsmount *mnt)
648 struct super_block *sb = NULL;
654 if (SMFS_DO_REC(S2SMI(sb)))
655 rc = smfs_stop_rec(sb);
656 smfs_post_cleanup(sb);
661 static int fsfilt_smfs_set_fs_flags(struct inode *inode, int flags)
666 if (SMFS_DO_REC(S2SMI(inode->i_sb)) && (flags & SM_DO_REC))
667 SMFS_SET_INODE_REC(inode);
668 if (SMFS_DO_COW(S2SMI(inode->i_sb)) && (flags & SM_DO_COW))
669 SMFS_SET_INODE_COW(inode);
673 static int fsfilt_smfs_clear_fs_flags(struct inode *inode, int flags)
678 if (SMFS_DO_REC(S2SMI(inode->i_sb)) && (flags & SM_DO_REC))
679 SMFS_CLEAN_INODE_REC(inode);
680 if (SMFS_DO_COW(S2SMI(inode->i_sb)) && (flags & SM_DO_COW))
681 SMFS_CLEAN_INODE_COW(inode);
685 static int fsfilt_smfs_get_fs_flags(struct dentry *de)
687 struct inode *inode = de->d_inode;
693 if (SMFS_DO_REC(S2SMI(inode->i_sb)) && SMFS_DO_INODE_REC(inode))
695 if (SMFS_DO_COW(S2SMI(inode->i_sb)) && SMFS_DO_INODE_COW(inode))
700 static int fsfilt_smfs_set_ost_flags(struct super_block *sb)
703 SET_REC_PACK_TYPE_INDEX(S2SMI(sb)->smsi_flags, PACK_OST);
707 static int fsfilt_smfs_set_mds_flags(struct super_block *sb)
710 SET_REC_PACK_TYPE_INDEX(S2SMI(sb)->smsi_flags, PACK_MDS);
714 static int fsfilt_smfs_get_reint_log_ctxt(struct super_block *sb,
715 struct llog_ctxt **ctxt)
717 struct smfs_super_info *smfs_info = S2SMI(sb);
720 *ctxt = smfs_info->smsi_rec_log;
724 static int fsfilt_smfs_setup(struct obd_device *obd, struct super_block *sb)
726 struct smfs_super_info *smfs_info = S2SMI(sb);
727 struct fsfilt_operations *cache_fsfilt;
728 struct super_block *csb;
731 /* It should be initialized olready by smfs_read_super(). */
732 if (!(cache_fsfilt = smfs_info->sm_cache_fsfilt))
733 cache_fsfilt = fsfilt_get_ops(smfs_info->smsi_cache_ftype);
739 if (cache_fsfilt->fs_setup)
740 rc = cache_fsfilt->fs_setup(obd, csb);
742 duplicate_sb(sb, csb);
747 static int fsfilt_smfs_set_xattr(struct inode *inode, void *handle, char *name,
748 void *buffer, int buffer_size)
750 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
751 struct inode *cache_inode = NULL;
757 cache_inode = I2CI(inode);
761 pre_smfs_inode(inode, cache_inode);
763 if (cache_fsfilt->fs_set_xattr)
764 rc = cache_fsfilt->fs_set_xattr(cache_inode, handle, name,
765 buffer, buffer_size);
766 post_smfs_inode(inode, cache_inode);
771 static int fsfilt_smfs_get_xattr(struct inode *inode, char *name,
772 void *buffer, int buffer_size)
774 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
775 struct inode *cache_inode = NULL;
781 cache_inode = I2CI(inode);
785 pre_smfs_inode(inode, cache_inode);
787 if (cache_fsfilt->fs_get_xattr)
788 rc = cache_fsfilt->fs_get_xattr(cache_inode, name,
789 buffer, buffer_size);
790 post_smfs_inode(inode, cache_inode);
795 static int fsfilt_smfs_insert_extents_ea(struct inode *inode,
796 unsigned long from, unsigned long num)
798 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
799 struct inode *cache_inode = NULL;
805 cache_inode = I2CI(inode);
809 pre_smfs_inode(inode, cache_inode);
811 if (cache_fsfilt->fs_insert_extents_ea)
812 rc = cache_fsfilt->fs_insert_extents_ea(cache_inode, from, num);
814 post_smfs_inode(inode, cache_inode);
818 static int fsfilt_smfs_remove_extents_ea(struct inode *inode,
819 unsigned long from, unsigned long num)
821 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
822 struct inode *cache_inode = NULL;
828 cache_inode = I2CI(inode);
832 pre_smfs_inode(inode, cache_inode);
834 if (cache_fsfilt->fs_remove_extents_ea)
835 rc = cache_fsfilt->fs_remove_extents_ea(cache_inode, from, num);
837 post_smfs_inode(inode, cache_inode);
841 static int fsfilt_smfs_init_extents_ea(struct inode *inode)
843 struct fsfilt_operations *cache_fsfilt = I2FOPS(inode);
844 struct inode *cache_inode = NULL;
850 cache_inode = I2CI(inode);
854 pre_smfs_inode(inode, cache_inode);
856 if (cache_fsfilt->fs_init_extents_ea)
857 rc = cache_fsfilt->fs_init_extents_ea(cache_inode);
859 post_smfs_inode(inode, cache_inode);
863 static int fsfilt_smfs_free_extents(struct super_block *sb, ino_t ino,
864 char *pbuf, int size)
866 OBD_FREE(pbuf, size * (sizeof(struct ldlm_extent)));
870 static int fsfilt_smfs_write_extents(struct dentry *dentry,
871 unsigned long from, unsigned long num)
875 if (SMFS_DO_REC(S2SMI(dentry->d_inode->i_sb)))
876 rc = smfs_write_extents(dentry->d_inode, dentry, from, num);
881 static int fsfilt_smfs_precreate_rec(struct dentry *dentry, int *count,
886 if (SMFS_DO_REC(S2SMI(dentry->d_inode->i_sb)))
887 rc = smfs_rec_precreate(dentry, count, oa);
892 static int fsfilt_smfs_get_ino_write_extents(struct super_block *sb, ino_t ino,
893 char **pbuf, int *size)
895 struct fs_extent *fs_extents;
896 struct ldlm_extent *extents = NULL;
898 struct inode *cache_inode;
899 struct fsfilt_operations *cache_fsfilt = NULL;
900 struct lvfs_run_ctxt saved;
901 int rc = 0, fs_ex_size, ex_num, flags;
902 char *buf = NULL, *ex_buf = NULL;
904 push_ctxt(&saved, S2SMI(sb)->smsi_ctxt, NULL);
906 inode = iget(sb, ino);
908 if (!inode || is_bad_inode(inode)) {
909 CWARN("Can not get inode %lu ino\n", ino);
912 cache_inode = I2CI(inode);
913 cache_fsfilt = I2FOPS(inode);
915 rc = cache_fsfilt->fs_get_xattr(cache_inode, REINT_EXTENTS_FLAGS,
916 &flags, sizeof(int));
917 if (!(flags & SMFS_OVER_WRITE) && !(flags & SMFS_DIRTY_WRITE)) {
919 } else if (flags & SMFS_OVER_WRITE) {
921 OBD_ALLOC(ex_buf, sizeof(struct ldlm_extent));
923 GOTO(out, rc=-ENOMEM);
924 extents = (struct ldlm_extent*)(ex_buf);
926 extents->end = 0xffffffff;
930 rc = cache_fsfilt->fs_get_write_extents_num(cache_inode, &fs_ex_size);
933 OBD_ALLOC(buf, fs_ex_size);
935 GOTO(out, rc=-ENOMEM);
937 rc = cache_fsfilt->fs_get_inode_write_extents(cache_inode, &buf,
942 ex_num = fs_ex_size / sizeof(struct fs_extent);
944 OBD_ALLOC(ex_buf, ex_num* sizeof(struct ldlm_extent));
946 GOTO(out, rc=-ENOMEM);
948 fs_extents = (struct fs_extent*)(buf);
949 extents = (struct ldlm_extent*)(ex_buf);
951 int blk_size = I2CI(inode)->i_blksize;
953 extents->start = fs_extents->e_block * blk_size;
954 extents->end = extents->start + fs_extents->e_num * blk_size;
963 OBD_FREE(buf, fs_ex_size);
965 OBD_FREE(ex_buf, (*size) * (sizeof(struct ldlm_extent)));
966 pop_ctxt(&saved, S2SMI(sb)->smsi_ctxt, NULL);
970 static int fsfilt_smfs_set_snap_item(struct super_block *sb, char *name)
976 #warning "still not implement for add snap item -wangdi"
980 static int fsfilt_smfs_do_write_cow(struct dentry *de, void *extents,
985 struct write_extents *w_ext = (struct write_extents *)extents;
988 for (i = 0; i < num_extents; i++) {
989 size_t count = w_ext->w_count;
990 loff_t off = w_ext->w_pos;
991 rc = smfs_cow_write_pre(de->d_inode, de, &count, &off);
999 static struct fsfilt_operations fsfilt_smfs_ops = {
1001 .fs_owner = THIS_MODULE,
1002 .fs_start = fsfilt_smfs_start,
1003 .fs_brw_start = fsfilt_smfs_brw_start,
1004 .fs_commit = fsfilt_smfs_commit,
1005 .fs_commit_async = fsfilt_smfs_commit_async,
1006 .fs_commit_wait = fsfilt_smfs_commit_wait,
1007 .fs_setattr = fsfilt_smfs_setattr,
1008 .fs_iocontrol = fsfilt_smfs_iocontrol,
1009 .fs_set_md = fsfilt_smfs_set_md,
1010 .fs_get_md = fsfilt_smfs_get_md,
1011 .fs_readpage = fsfilt_smfs_readpage,
1012 .fs_getpage = fsfilt_smfs_getpage,
1013 .fs_add_journal_cb = fsfilt_smfs_add_journal_cb,
1014 .fs_statfs = fsfilt_smfs_statfs,
1015 .fs_sync = fsfilt_smfs_sync,
1016 .fs_map_inode_pages = fsfilt_smfs_map_inode_pages,
1017 .fs_prep_san_write = fsfilt_smfs_prep_san_write,
1018 .fs_write_record = fsfilt_smfs_write_record,
1019 .fs_read_record = fsfilt_smfs_read_record,
1020 .fs_setup = fsfilt_smfs_setup,
1021 .fs_post_setup = fsfilt_smfs_post_setup,
1022 .fs_post_cleanup = fsfilt_smfs_post_cleanup,
1023 .fs_set_fs_flags = fsfilt_smfs_set_fs_flags,
1024 .fs_clear_fs_flags = fsfilt_smfs_clear_fs_flags,
1025 .fs_get_fs_flags = fsfilt_smfs_get_fs_flags,
1026 .fs_set_ost_flags = fsfilt_smfs_set_ost_flags,
1027 .fs_set_mds_flags = fsfilt_smfs_set_mds_flags,
1028 .fs_precreate_rec = fsfilt_smfs_precreate_rec,
1029 .fs_get_reint_log_ctxt = fsfilt_smfs_get_reint_log_ctxt,
1030 .fs_send_bio = fsfilt_smfs_send_bio,
1031 .fs_set_xattr = fsfilt_smfs_set_xattr,
1032 .fs_get_xattr = fsfilt_smfs_get_xattr,
1033 .fs_init_extents_ea = fsfilt_smfs_init_extents_ea,
1034 .fs_insert_extents_ea = fsfilt_smfs_insert_extents_ea,
1035 .fs_remove_extents_ea = fsfilt_smfs_remove_extents_ea,
1036 .fs_get_ino_write_extents = fsfilt_smfs_get_ino_write_extents,
1037 .fs_free_write_extents = fsfilt_smfs_free_extents,
1038 .fs_write_extents = fsfilt_smfs_write_extents,
1039 .fs_set_snap_item = fsfilt_smfs_set_snap_item,
1040 .fs_do_write_cow = fsfilt_smfs_do_write_cow,
1041 /* FIXME-UMKA: probably fsfilt_smfs_get_op_len() should be
1045 static int __init fsfilt_smfs_init(void)
1049 rc = fsfilt_register_ops(&fsfilt_smfs_ops);
1053 static void __exit fsfilt_smfs_exit(void)
1055 fsfilt_unregister_ops(&fsfilt_smfs_ops);
1058 module_init(fsfilt_smfs_init);
1059 module_exit(fsfilt_smfs_exit);
1061 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1062 MODULE_DESCRIPTION("Lustre SMFS Filesystem Helper v0.1");
1063 MODULE_LICENSE("GPL");