| Tao Ma | 8dec98e | 2009-08-18 11:19:58 +0800 | [diff] [blame] | 1 | /* -*- mode: c; c-basic-offset: 8; -*- | 
 | 2 |  * vim: noexpandtab sw=8 ts=8 sts=0: | 
 | 3 |  * | 
 | 4 |  * refcounttree.h | 
 | 5 |  * | 
 | 6 |  * Copyright (C) 2009 Oracle.  All rights reserved. | 
 | 7 |  * | 
 | 8 |  * This program is free software; you can redistribute it and/or | 
 | 9 |  * modify it under the terms of the GNU General Public | 
 | 10 |  * License version 2 as published by the Free Software Foundation. | 
 | 11 |  * | 
 | 12 |  * This program is distributed in the hope that it will be useful, | 
 | 13 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 | 14 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
 | 15 |  * General Public License for more details. | 
 | 16 |  */ | 
 | 17 | #ifndef OCFS2_REFCOUNTTREE_H | 
 | 18 | #define OCFS2_REFCOUNTTREE_H | 
 | 19 |  | 
 | 20 | struct ocfs2_refcount_tree { | 
 | 21 | 	struct rb_node rf_node; | 
 | 22 | 	u64 rf_blkno; | 
 | 23 | 	u32 rf_generation; | 
 | 24 | 	struct rw_semaphore rf_sem; | 
 | 25 | 	struct ocfs2_lock_res rf_lockres; | 
 | 26 | 	struct kref rf_getcnt; | 
 | 27 | 	int rf_removed; | 
 | 28 |  | 
 | 29 | 	/* the following 4 fields are used by caching_info. */ | 
 | 30 | 	struct ocfs2_caching_info rf_ci; | 
 | 31 | 	spinlock_t rf_lock; | 
 | 32 | 	struct mutex rf_io_mutex; | 
 | 33 | 	struct super_block *rf_sb; | 
 | 34 | }; | 
 | 35 |  | 
| Tao Ma | 374a263 | 2009-08-24 11:13:37 +0800 | [diff] [blame] | 36 | void ocfs2_purge_refcount_trees(struct ocfs2_super *osb); | 
 | 37 | int ocfs2_lock_refcount_tree(struct ocfs2_super *osb, u64 ref_blkno, int rw, | 
 | 38 | 			     struct ocfs2_refcount_tree **tree, | 
 | 39 | 			     struct buffer_head **ref_bh); | 
 | 40 | void ocfs2_unlock_refcount_tree(struct ocfs2_super *osb, | 
 | 41 | 				struct ocfs2_refcount_tree *tree, | 
 | 42 | 				int rw); | 
| Tao Ma | 1823cb0 | 2009-08-18 11:24:49 +0800 | [diff] [blame] | 43 |  | 
 | 44 | int ocfs2_decrease_refcount(struct inode *inode, | 
 | 45 | 			    handle_t *handle, u32 cpos, u32 len, | 
 | 46 | 			    struct ocfs2_alloc_context *meta_ac, | 
| Tao Ma | 6ae23c5 | 2009-08-18 11:30:55 +0800 | [diff] [blame] | 47 | 			    struct ocfs2_cached_dealloc_ctxt *dealloc, | 
 | 48 | 			    int delete); | 
| Tao Ma | bcbbb24 | 2009-08-18 11:29:12 +0800 | [diff] [blame] | 49 | int ocfs2_prepare_refcount_change_for_del(struct inode *inode, | 
| Tristan Ye | 78f9467 | 2010-05-11 17:54:42 +0800 | [diff] [blame] | 50 | 					  u64 refcount_loc, | 
| Tao Ma | bcbbb24 | 2009-08-18 11:29:12 +0800 | [diff] [blame] | 51 | 					  u64 phys_blkno, | 
 | 52 | 					  u32 clusters, | 
 | 53 | 					  int *credits, | 
| Tristan Ye | 78f9467 | 2010-05-11 17:54:42 +0800 | [diff] [blame] | 54 | 					  int *ref_blocks); | 
| Tao Ma | 6f70fa5 | 2009-08-25 08:05:12 +0800 | [diff] [blame] | 55 | int ocfs2_refcount_cow(struct inode *inode, struct buffer_head *di_bh, | 
| Tao Ma | 37f8a2b | 2009-08-26 09:47:28 +0800 | [diff] [blame] | 56 | 		       u32 cpos, u32 write_len, u32 max_cpos); | 
| Tao Ma | 492a8a3 | 2009-08-18 11:43:17 +0800 | [diff] [blame] | 57 |  | 
 | 58 | typedef int (ocfs2_post_refcount_func)(struct inode *inode, | 
 | 59 | 				       handle_t *handle, | 
 | 60 | 				       void *para); | 
 | 61 | /* | 
 | 62 |  * Some refcount caller need to do more work after we modify the data b-tree | 
 | 63 |  * during refcount operation(including CoW and add refcount flag), and make the | 
 | 64 |  * transaction complete. So it must give us this structure so that we can do it | 
 | 65 |  * within our transaction. | 
 | 66 |  * | 
 | 67 |  */ | 
 | 68 | struct ocfs2_post_refcount { | 
 | 69 | 	int credits;			/* credits it need for journal. */ | 
 | 70 | 	ocfs2_post_refcount_func *func;	/* real function. */ | 
 | 71 | 	void *para; | 
 | 72 | }; | 
 | 73 |  | 
 | 74 | int ocfs2_refcounted_xattr_delete_need(struct inode *inode, | 
 | 75 | 				       struct ocfs2_caching_info *ref_ci, | 
 | 76 | 				       struct buffer_head *ref_root_bh, | 
 | 77 | 				       struct ocfs2_xattr_value_root *xv, | 
 | 78 | 				       int *meta_add, int *credits); | 
 | 79 | int ocfs2_refcount_cow_xattr(struct inode *inode, | 
 | 80 | 			     struct ocfs2_dinode *di, | 
 | 81 | 			     struct ocfs2_xattr_value_buf *vb, | 
 | 82 | 			     struct ocfs2_refcount_tree *ref_tree, | 
 | 83 | 			     struct buffer_head *ref_root_bh, | 
 | 84 | 			     u32 cpos, u32 write_len, | 
 | 85 | 			     struct ocfs2_post_refcount *post); | 
| Tao Ma | 0129241 | 2009-09-21 13:04:19 +0800 | [diff] [blame] | 86 | int ocfs2_add_refcount_flag(struct inode *inode, | 
 | 87 | 			    struct ocfs2_extent_tree *data_et, | 
 | 88 | 			    struct ocfs2_caching_info *ref_ci, | 
 | 89 | 			    struct buffer_head *ref_root_bh, | 
 | 90 | 			    u32 cpos, u32 p_cluster, u32 num_clusters, | 
 | 91 | 			    struct ocfs2_cached_dealloc_ctxt *dealloc, | 
 | 92 | 			    struct ocfs2_post_refcount *post); | 
| Tao Ma | 8b2c0db | 2009-08-18 11:43:49 +0800 | [diff] [blame] | 93 | int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh); | 
 | 94 | int ocfs2_try_remove_refcount_tree(struct inode *inode, | 
 | 95 | 				   struct buffer_head *di_bh); | 
| Tao Ma | 2999d12 | 2009-08-18 11:43:55 +0800 | [diff] [blame] | 96 | int ocfs2_increase_refcount(handle_t *handle, | 
 | 97 | 			    struct ocfs2_caching_info *ci, | 
 | 98 | 			    struct buffer_head *ref_root_bh, | 
 | 99 | 			    u64 cpos, u32 len, | 
 | 100 | 			    struct ocfs2_alloc_context *meta_ac, | 
 | 101 | 			    struct ocfs2_cached_dealloc_ctxt *dealloc); | 
| Tao Ma | bd50873 | 2009-09-21 11:25:14 +0800 | [diff] [blame] | 102 | int ocfs2_reflink_ioctl(struct inode *inode, | 
 | 103 | 			const char __user *oldname, | 
 | 104 | 			const char __user *newname, | 
 | 105 | 			bool preserve); | 
| Tao Ma | 8dec98e | 2009-08-18 11:19:58 +0800 | [diff] [blame] | 106 | #endif /* OCFS2_REFCOUNTTREE_H */ |