X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fsmfs%2Fsmfs_internal.h;h=5b73d03ca5dac36c13f734279da8c36c96fd8323;hp=7da1b7e74fe0431f44ba2de12303f8470dde92bb;hb=ac606470fe01743b1af98b29c07cadbd792c9614;hpb=32b4812a6afd1e71a3576835d445622d38cdafd1 diff --git a/lustre/smfs/smfs_internal.h b/lustre/smfs/smfs_internal.h index 7da1b7e..5b73d03 100644 --- a/lustre/smfs/smfs_internal.h +++ b/lustre/smfs/smfs_internal.h @@ -59,16 +59,6 @@ struct smfs_control_device { #define MYPATHLEN(buffer, path) ((buffer) + PAGE_SIZE - (path)) -#define SMFS_KML_POST(dir, dentry, data1, data2, op, name, rc, label) \ -do { \ - if (smfs_do_rec(dir) && !rc) { \ - CDEBUG(D_INODE, "Do %s kml post for dir %lu \n", \ - name, dir->i_ino); \ - rc = smfs_post_kml_rec(dir, dentry, data1, data2, op); \ - if (rc) \ - GOTO(label, rc); \ - } \ -} while(0) #define PACK_KML_REC_INIT(buffer, op_code) \ do{ \ @@ -77,6 +67,7 @@ do{ \ buffer += sizeof(opcode); \ } while (0) + extern int init_smfs_proc_sys(void); /*options.c*/ extern int get_opt(struct option **option, char **pos); @@ -126,12 +117,22 @@ static inline struct journal_operations *journal_ops(struct smfs_super_info *smb { return &smb->sm_ops->sm_journal_ops; } -/*super.c*/ -extern int init_smfs(void); -extern int cleanup_smfs(void); -extern void smfs_put_super(struct super_block *sb); -extern struct super_block *smfs_get_sb_by_path(char *path, int len); -extern struct vfsmount* get_vfsmount(struct super_block *sb); + +struct smfs_hook_ops *smfs_alloc_hook_ops(char *name, + smfs_hook_func pre_hook, + smfs_hook_func post_hook); + +void smfs_free_hook_ops(struct smfs_hook_ops *hops); +int smfs_register_hook_ops(struct smfs_super_info *smb, + struct smfs_hook_ops *smh_ops); + +struct smfs_hook_ops *smfs_unregister_hook_ops(struct smfs_super_info *smb, + char *name); +/*smfs_lib.c*/ +void smfs_put_super(struct super_block *sb); +int smfs_fill_super(struct super_block *sb, void *data, int silent); + +void smfs_cleanup_hooks(struct smfs_super_info *smb); /*sysctl.c*/ extern int sm_debug_level; extern int sm_inodes; @@ -156,16 +157,22 @@ extern int smfs_removexattr(struct dentry *dentry, const char *name); extern int smfs_open(struct inode * inode, struct file * filp); extern int smfs_release(struct inode * inode, struct file * filp); /*inode.c*/ +struct inode *smfs_get_inode(struct super_block *sb, ino_t hash, + struct inode *dir, int index); + extern struct super_operations smfs_super_ops; + +struct smfs_iget_args { + struct inode *s_inode; + int s_index; + int s_ino; +}; /*symlink.c*/ extern struct inode_operations smfs_sym_iops; extern struct file_operations smfs_sym_fops; /*journal.c */ -extern void *smfs_trans_start(struct inode *inode, int op, void *desc_private); -extern void smfs_trans_commit(struct inode *inode, void *handle, - int force_sync); -extern int smfs_post_kml_rec(struct inode *dir, struct dentry *dst_dentry, - void *data1, void *data2, int op); +void *smfs_trans_start(struct inode *inode, int op, void *desc_private); +void smfs_trans_commit(struct inode *inode, void *handle, int force_sync); extern int smfs_post_rec_write(struct inode *dir, struct dentry *dentry, void *data1, void *data2); @@ -174,22 +181,19 @@ extern int smfs_post_rec_setattr(struct inode *dir, struct dentry *dentry, extern int smfs_post_rec_create(struct inode *dir, struct dentry *dentry, void *data1, void *data2); /*kml.c*/ -extern int smfs_kml_init(struct super_block *sb); -extern int smfs_do_rec(struct inode *inode); -extern int smfs_rec_cleanup(struct super_block *sb); -extern int smfs_rec_init(struct super_block *sb); +int smfs_do_rec(struct inode *inode); +int smfs_rec_cleanup(struct smfs_super_info *sb); +int smfs_rec_init(struct super_block *sb); + extern int smfs_rec_unpack(struct smfs_proc_args *args, char *record, char **pbuf, int *opcode); extern int smfs_process_rec(struct super_block *sb, int count, char *dir, int flags); -extern void smfs_rec_pack(struct update_record *rec, - struct inode *dst, void* data, int op); -extern smfs_pack_rec_func smfs_get_rec_pack_type(struct super_block *sb); - -extern int ost_rec_pack_init(struct super_block *sb); +/*mds_kml.c*/ +int mds_rec_pack_init(struct smfs_super_info *smb); /*ost_kml.c*/ -extern int mds_rec_pack_init(struct super_block *sb); +int ost_rec_pack_init(struct smfs_super_info *smb); /*smfs_llog.c*/ extern int smfs_llog_setup(struct super_block *sb, struct vfsmount *mnt); @@ -199,6 +203,7 @@ extern int smfs_llog_add_rec(struct smfs_super_info * sinfo, void *data, /*ioctl.c*/ extern int init_smfs_psdev(void); extern void smfs_cleanup_psdev(void); +/*smfs_cow.c */ /* cache_space.c */ extern int do_cache_manage; @@ -222,10 +227,10 @@ extern int cache_space_post(int op, void *handle, struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry); -extern int cache_space_hook_setup(struct super_block *); -extern int cache_space_hook_cleanup(void); -extern int cache_space_hook_init(struct super_block *); -extern int cache_space_hook_exit(struct super_block *); +int cache_space_hook_setup(struct super_block *); +int cache_space_hook_cleanup(void); +int cache_space_hook_init(struct super_block *sb); +int cache_space_hook_exit(struct smfs_super_info *smfs_info); #define XATTR_SMFS_HOARD_MARK "hoard" #define XATTR_SMFS_CACHE_LOGCOOKIE "cache" @@ -273,42 +278,65 @@ static inline int get_active_entry(struct inode *dir, __u64 *active_entry) rc = 0; RETURN(rc); } +#define HOOK_CREATE 1 +#define HOOK_LOOKUP 2 +#define HOOK_LINK 3 +#define HOOK_UNLINK 4 +#define HOOK_SYMLINK 5 +#define HOOK_MKDIR 6 +#define HOOK_RMDIR 7 +#define HOOK_MKNOD 8 +#define HOOK_RENAME 9 +#define HOOK_SETATTR 10 +#define HOOK_WRITE 11 +#define HOOK_READDIR 12 +#define HOOK_MAX 12 -#define CACHE_HOOK_CREATE 1 -#define CACHE_HOOK_LOOKUP 2 -#define CACHE_HOOK_LINK 3 -#define CACHE_HOOK_UNLINK 4 -#define CACHE_HOOK_SYMLINK 5 -#define CACHE_HOOK_MKDIR 6 -#define CACHE_HOOK_RMDIR 7 -#define CACHE_HOOK_MKNOD 8 -#define CACHE_HOOK_RENAME 9 - -#define CACHE_HOOK_MAX 9 - -#define SMFS_CACHE_HOOK_PRE(op, handle, dir) \ -{ \ - if (smfs_cache_hook(dir)) { \ - LASSERT(handle != NULL); \ - CDEBUG(D_INODE, "cache hook pre: op %d, dir %lu\n", \ - op, dir->i_ino); \ - cache_space_pre(dir, op); \ - } \ -} +#define PRE_HOOK 0 +#define POST_HOOK 1 + +#define SMFS_HOOK(inode, dentry, data1, data2, op, handle, flag, rc, label) \ +do { \ + LASSERT(inode->i_sb); \ + if (!rc) { \ + struct smfs_super_info *smb = S2SMI(inode->i_sb); \ + struct list_head *hlist = &smb->smsi_hook_list; \ + struct list_head *p; \ + \ + list_for_each(p, hlist) { \ + struct smfs_hook_ops *hops; \ + \ + hops = list_entry(p, typeof(*hops), smh_list); \ + if (flag == PRE_HOOK && hops->smh_pre_op) \ + rc = hops->smh_pre_op(inode, dentry, data1, \ + data2, op, handle); \ + else if (flag == POST_HOOK && hops->smh_post_op) \ + rc = hops->smh_post_op(inode, dentry, data1, \ + data2, op, handle); \ + if (rc) \ + break; \ + } \ + } \ + if (rc) \ + GOTO(label, rc); \ +} while(0) \ + +#define SMFS_GET_INODE(sb, cache_inode, dir, inode, rc, label) \ +do { \ + LASSERT(cache_inode); \ + inode = smfs_get_inode(sb, cache_inode->i_ino, dir, 0); \ + iput(cache_inode); \ + if (!inode) \ + GOTO(label, rc = -ENOENT); \ +} while(0) -#define SMFS_CACHE_HOOK_POST(op, handle, old_dir, old_dentry, \ - new_dir, new_dentry, rc, label) \ -{ \ - if (!rc && smfs_cache_hook(old_dir)) { \ - LASSERT(handle != NULL); \ - CDEBUG(D_INODE, "cache hook post: op %d, dir %lu\n", \ - op, old_dir->i_ino); \ - rc = cache_space_post(op, handle, old_dir, old_dentry, \ - new_dir, new_dentry); \ - if (rc) \ - GOTO(label, rc); \ - } \ -} +#if CONFIG_SNAPFS +int smfs_cow_init(struct super_block *sb); +int smfs_cow_cleanup(struct smfs_super_info *smb); +int smfs_snap_test_inode(struct inode *inode, void *args); +#else +#define SMFS_PRE_COW(dir, dentry, new_dir, new_dentry, op, name, rc, label) +#endif #endif /*__KERNEL*/ #endif /* __LINUX_SMFS_H */