Loading...
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
20struct ocfs2_refcount_tree {
21 struct rb_node rf_node;
22 u64 rf_blkno;
23 u32 rf_generation;
24 struct kref rf_getcnt;
25 struct rw_semaphore rf_sem;
26 struct ocfs2_lock_res rf_lockres;
27 int rf_removed;
28
29 /* the following 4 fields are used by caching_info. */
30 spinlock_t rf_lock;
31 struct ocfs2_caching_info rf_ci;
32 struct mutex rf_io_mutex;
33 struct super_block *rf_sb;
34};
35
36void ocfs2_purge_refcount_trees(struct ocfs2_super *osb);
37int 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);
40void ocfs2_unlock_refcount_tree(struct ocfs2_super *osb,
41 struct ocfs2_refcount_tree *tree,
42 int rw);
43
44int ocfs2_decrease_refcount(struct inode *inode,
45 handle_t *handle, u32 cpos, u32 len,
46 struct ocfs2_alloc_context *meta_ac,
47 struct ocfs2_cached_dealloc_ctxt *dealloc,
48 int delete);
49int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
50 u64 refcount_loc,
51 u64 phys_blkno,
52 u32 clusters,
53 int *credits,
54 int *ref_blocks);
55int ocfs2_refcount_cow(struct inode *inode,
56 struct buffer_head *di_bh,
57 u32 cpos, u32 write_len, u32 max_cpos);
58
59typedef int (ocfs2_post_refcount_func)(struct inode *inode,
60 handle_t *handle,
61 void *para);
62/*
63 * Some refcount caller need to do more work after we modify the data b-tree
64 * during refcount operation(including CoW and add refcount flag), and make the
65 * transaction complete. So it must give us this structure so that we can do it
66 * within our transaction.
67 *
68 */
69struct ocfs2_post_refcount {
70 int credits; /* credits it need for journal. */
71 ocfs2_post_refcount_func *func; /* real function. */
72 void *para;
73};
74
75int ocfs2_refcounted_xattr_delete_need(struct inode *inode,
76 struct ocfs2_caching_info *ref_ci,
77 struct buffer_head *ref_root_bh,
78 struct ocfs2_xattr_value_root *xv,
79 int *meta_add, int *credits);
80int ocfs2_refcount_cow_xattr(struct inode *inode,
81 struct ocfs2_dinode *di,
82 struct ocfs2_xattr_value_buf *vb,
83 struct ocfs2_refcount_tree *ref_tree,
84 struct buffer_head *ref_root_bh,
85 u32 cpos, u32 write_len,
86 struct ocfs2_post_refcount *post);
87int ocfs2_duplicate_clusters_by_page(handle_t *handle,
88 struct inode *inode,
89 u32 cpos, u32 old_cluster,
90 u32 new_cluster, u32 new_len);
91int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
92 struct inode *inode,
93 u32 cpos, u32 old_cluster,
94 u32 new_cluster, u32 new_len);
95int ocfs2_cow_sync_writeback(struct super_block *sb,
96 struct inode *inode,
97 u32 cpos, u32 num_clusters);
98int ocfs2_add_refcount_flag(struct inode *inode,
99 struct ocfs2_extent_tree *data_et,
100 struct ocfs2_caching_info *ref_ci,
101 struct buffer_head *ref_root_bh,
102 u32 cpos, u32 p_cluster, u32 num_clusters,
103 struct ocfs2_cached_dealloc_ctxt *dealloc,
104 struct ocfs2_post_refcount *post);
105int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh);
106int ocfs2_try_remove_refcount_tree(struct inode *inode,
107 struct buffer_head *di_bh);
108int ocfs2_increase_refcount(handle_t *handle,
109 struct ocfs2_caching_info *ci,
110 struct buffer_head *ref_root_bh,
111 u64 cpos, u32 len,
112 struct ocfs2_alloc_context *meta_ac,
113 struct ocfs2_cached_dealloc_ctxt *dealloc);
114int ocfs2_reflink_ioctl(struct inode *inode,
115 const char __user *oldname,
116 const char __user *newname,
117 bool preserve);
118int ocfs2_reflink_remap_range(struct file *file_in,
119 loff_t pos_in,
120 struct file *file_out,
121 loff_t pos_out,
122 u64 len,
123 bool is_dedupe);
124
125#endif /* OCFS2_REFCOUNTTREE_H */
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * refcounttree.h
4 *
5 * Copyright (C) 2009 Oracle. All rights reserved.
6 */
7#ifndef OCFS2_REFCOUNTTREE_H
8#define OCFS2_REFCOUNTTREE_H
9
10struct ocfs2_refcount_tree {
11 struct rb_node rf_node;
12 u64 rf_blkno;
13 u32 rf_generation;
14 struct kref rf_getcnt;
15 struct rw_semaphore rf_sem;
16 struct ocfs2_lock_res rf_lockres;
17 int rf_removed;
18
19 /* the following 4 fields are used by caching_info. */
20 spinlock_t rf_lock;
21 struct ocfs2_caching_info rf_ci;
22 struct mutex rf_io_mutex;
23 struct super_block *rf_sb;
24};
25
26void ocfs2_purge_refcount_trees(struct ocfs2_super *osb);
27int ocfs2_lock_refcount_tree(struct ocfs2_super *osb, u64 ref_blkno, int rw,
28 struct ocfs2_refcount_tree **tree,
29 struct buffer_head **ref_bh);
30void ocfs2_unlock_refcount_tree(struct ocfs2_super *osb,
31 struct ocfs2_refcount_tree *tree,
32 int rw);
33
34int ocfs2_decrease_refcount(struct inode *inode,
35 handle_t *handle, u32 cpos, u32 len,
36 struct ocfs2_alloc_context *meta_ac,
37 struct ocfs2_cached_dealloc_ctxt *dealloc,
38 int delete);
39int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
40 u64 refcount_loc,
41 u64 phys_blkno,
42 u32 clusters,
43 int *credits,
44 int *ref_blocks);
45int ocfs2_refcount_cow(struct inode *inode,
46 struct buffer_head *di_bh,
47 u32 cpos, u32 write_len, u32 max_cpos);
48
49typedef int (ocfs2_post_refcount_func)(struct inode *inode,
50 handle_t *handle,
51 void *para);
52/*
53 * Some refcount caller need to do more work after we modify the data b-tree
54 * during refcount operation(including CoW and add refcount flag), and make the
55 * transaction complete. So it must give us this structure so that we can do it
56 * within our transaction.
57 *
58 */
59struct ocfs2_post_refcount {
60 int credits; /* credits it need for journal. */
61 ocfs2_post_refcount_func *func; /* real function. */
62 void *para;
63};
64
65int ocfs2_refcounted_xattr_delete_need(struct inode *inode,
66 struct ocfs2_caching_info *ref_ci,
67 struct buffer_head *ref_root_bh,
68 struct ocfs2_xattr_value_root *xv,
69 int *meta_add, int *credits);
70int ocfs2_refcount_cow_xattr(struct inode *inode,
71 struct ocfs2_dinode *di,
72 struct ocfs2_xattr_value_buf *vb,
73 struct ocfs2_refcount_tree *ref_tree,
74 struct buffer_head *ref_root_bh,
75 u32 cpos, u32 write_len,
76 struct ocfs2_post_refcount *post);
77int ocfs2_duplicate_clusters_by_page(handle_t *handle,
78 struct inode *inode,
79 u32 cpos, u32 old_cluster,
80 u32 new_cluster, u32 new_len);
81int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
82 struct inode *inode,
83 u32 cpos, u32 old_cluster,
84 u32 new_cluster, u32 new_len);
85int ocfs2_cow_sync_writeback(struct super_block *sb,
86 struct inode *inode,
87 u32 cpos, u32 num_clusters);
88int ocfs2_add_refcount_flag(struct inode *inode,
89 struct ocfs2_extent_tree *data_et,
90 struct ocfs2_caching_info *ref_ci,
91 struct buffer_head *ref_root_bh,
92 u32 cpos, u32 p_cluster, u32 num_clusters,
93 struct ocfs2_cached_dealloc_ctxt *dealloc,
94 struct ocfs2_post_refcount *post);
95int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh);
96int ocfs2_try_remove_refcount_tree(struct inode *inode,
97 struct buffer_head *di_bh);
98int ocfs2_increase_refcount(handle_t *handle,
99 struct ocfs2_caching_info *ci,
100 struct buffer_head *ref_root_bh,
101 u64 cpos, u32 len,
102 struct ocfs2_alloc_context *meta_ac,
103 struct ocfs2_cached_dealloc_ctxt *dealloc);
104int ocfs2_reflink_ioctl(struct inode *inode,
105 const char __user *oldname,
106 const char __user *newname,
107 bool preserve);
108loff_t ocfs2_reflink_remap_blocks(struct inode *s_inode,
109 struct buffer_head *s_bh,
110 loff_t pos_in,
111 struct inode *t_inode,
112 struct buffer_head *t_bh,
113 loff_t pos_out,
114 loff_t len);
115int ocfs2_reflink_inodes_lock(struct inode *s_inode,
116 struct buffer_head **bh1,
117 struct inode *t_inode,
118 struct buffer_head **bh2);
119void ocfs2_reflink_inodes_unlock(struct inode *s_inode,
120 struct buffer_head *s_bh,
121 struct inode *t_inode,
122 struct buffer_head *t_bh);
123int ocfs2_reflink_update_dest(struct inode *dest,
124 struct buffer_head *d_bh,
125 loff_t newlen);
126
127#endif /* OCFS2_REFCOUNTTREE_H */