diff options
Diffstat (limited to 'fs/incfs/data_mgmt.h')
-rw-r--r-- | fs/incfs/data_mgmt.h | 93 |
1 files changed, 18 insertions, 75 deletions
diff --git a/fs/incfs/data_mgmt.h b/fs/incfs/data_mgmt.h index 76b16999f854..a98858afb138 100644 --- a/fs/incfs/data_mgmt.h +++ b/fs/incfs/data_mgmt.h | |||
@@ -10,12 +10,9 @@ | |||
10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
11 | #include <linux/mutex.h> | 11 | #include <linux/mutex.h> |
12 | #include <linux/spinlock.h> | 12 | #include <linux/spinlock.h> |
13 | #include <linux/rcupdate.h> | ||
14 | #include <linux/completion.h> | 13 | #include <linux/completion.h> |
15 | #include <linux/wait.h> | 14 | #include <linux/wait.h> |
16 | #include <linux/zstd.h> | ||
17 | #include <crypto/hash.h> | 15 | #include <crypto/hash.h> |
18 | #include <linux/rwsem.h> | ||
19 | 16 | ||
20 | #include <uapi/linux/incrementalfs.h> | 17 | #include <uapi/linux/incrementalfs.h> |
21 | 18 | ||
@@ -35,14 +32,13 @@ struct full_record { | |||
35 | u32 block_index : 30; | 32 | u32 block_index : 30; |
36 | incfs_uuid_t file_id; | 33 | incfs_uuid_t file_id; |
37 | u64 absolute_ts_us; | 34 | u64 absolute_ts_us; |
38 | uid_t uid; | ||
39 | } __packed; /* 28 bytes */ | 35 | } __packed; /* 28 bytes */ |
40 | 36 | ||
41 | struct same_file_record { | 37 | struct same_file_record { |
42 | enum LOG_RECORD_TYPE type : 2; /* SAME_FILE */ | 38 | enum LOG_RECORD_TYPE type : 2; /* SAME_FILE */ |
43 | u32 block_index : 30; | 39 | u32 block_index : 30; |
44 | u32 relative_ts_us; /* max 2^32 us ~= 1 hour (1:11:30) */ | 40 | u32 relative_ts_us; /* max 2^32 us ~= 1 hour (1:11:30) */ |
45 | } __packed; /* 8 bytes */ | 41 | } __packed; /* 12 bytes */ |
46 | 42 | ||
47 | struct same_file_next_block { | 43 | struct same_file_next_block { |
48 | enum LOG_RECORD_TYPE type : 2; /* SAME_FILE_NEXT_BLOCK */ | 44 | enum LOG_RECORD_TYPE type : 2; /* SAME_FILE_NEXT_BLOCK */ |
@@ -103,7 +99,8 @@ struct mount_options { | |||
103 | unsigned int readahead_pages; | 99 | unsigned int readahead_pages; |
104 | unsigned int read_log_pages; | 100 | unsigned int read_log_pages; |
105 | unsigned int read_log_wakeup_count; | 101 | unsigned int read_log_wakeup_count; |
106 | bool report_uid; | 102 | bool no_backing_file_cache; |
103 | bool no_backing_file_readahead; | ||
107 | }; | 104 | }; |
108 | 105 | ||
109 | struct mount_info { | 106 | struct mount_info { |
@@ -112,8 +109,9 @@ struct mount_info { | |||
112 | struct path mi_backing_dir_path; | 109 | struct path mi_backing_dir_path; |
113 | 110 | ||
114 | struct dentry *mi_index_dir; | 111 | struct dentry *mi_index_dir; |
115 | 112 | /* For stacking mounts, if true, this indicates if the index dir needs | |
116 | struct dentry *mi_incomplete_dir; | 113 | * to be freed for this SB otherwise it was created by lower level SB */ |
114 | bool mi_index_free; | ||
117 | 115 | ||
118 | const struct cred *mi_owner; | 116 | const struct cred *mi_owner; |
119 | 117 | ||
@@ -128,13 +126,13 @@ struct mount_info { | |||
128 | wait_queue_head_t mi_pending_reads_notif_wq; | 126 | wait_queue_head_t mi_pending_reads_notif_wq; |
129 | 127 | ||
130 | /* | 128 | /* |
131 | * Protects - RCU safe: | 129 | * Protects: |
132 | * - reads_list_head | 130 | * - reads_list_head |
133 | * - mi_pending_reads_count | 131 | * - mi_pending_reads_count |
134 | * - mi_last_pending_read_number | 132 | * - mi_last_pending_read_number |
135 | * - data_file_segment.reads_list_head | 133 | * - data_file_segment.reads_list_head |
136 | */ | 134 | */ |
137 | spinlock_t pending_read_lock; | 135 | struct mutex mi_pending_reads_mutex; |
138 | 136 | ||
139 | /* List of active pending_read objects */ | 137 | /* List of active pending_read objects */ |
140 | struct list_head mi_reads_list_head; | 138 | struct list_head mi_reads_list_head; |
@@ -156,23 +154,6 @@ struct mount_info { | |||
156 | 154 | ||
157 | void *pending_read_xattr; | 155 | void *pending_read_xattr; |
158 | size_t pending_read_xattr_size; | 156 | size_t pending_read_xattr_size; |
159 | |||
160 | /* A queue of waiters who want to be notified about blocks_written */ | ||
161 | wait_queue_head_t mi_blocks_written_notif_wq; | ||
162 | |||
163 | /* Number of blocks written since mount */ | ||
164 | atomic_t mi_blocks_written; | ||
165 | |||
166 | /* Per UID read timeouts */ | ||
167 | spinlock_t mi_per_uid_read_timeouts_lock; | ||
168 | struct incfs_per_uid_read_timeouts *mi_per_uid_read_timeouts; | ||
169 | int mi_per_uid_read_timeouts_size; | ||
170 | |||
171 | /* zstd workspace */ | ||
172 | struct mutex mi_zstd_workspace_mutex; | ||
173 | void *mi_zstd_workspace; | ||
174 | ZSTD_DStream *mi_zstd_stream; | ||
175 | struct delayed_work mi_zstd_cleanup_work; | ||
176 | }; | 157 | }; |
177 | 158 | ||
178 | struct data_file_block { | 159 | struct data_file_block { |
@@ -194,20 +175,17 @@ struct pending_read { | |||
194 | 175 | ||
195 | int serial_number; | 176 | int serial_number; |
196 | 177 | ||
197 | uid_t uid; | ||
198 | |||
199 | struct list_head mi_reads_list; | 178 | struct list_head mi_reads_list; |
200 | 179 | ||
201 | struct list_head segment_reads_list; | 180 | struct list_head segment_reads_list; |
202 | |||
203 | struct rcu_head rcu; | ||
204 | }; | 181 | }; |
205 | 182 | ||
206 | struct data_file_segment { | 183 | struct data_file_segment { |
207 | wait_queue_head_t new_data_arrival_wq; | 184 | wait_queue_head_t new_data_arrival_wq; |
208 | 185 | ||
209 | /* Protects reads and writes from the blockmap */ | 186 | /* Protects reads and writes from the blockmap */ |
210 | struct rw_semaphore rwsem; | 187 | /* Good candidate for read/write mutex */ |
188 | struct mutex blockmap_mutex; | ||
211 | 189 | ||
212 | /* List of active pending_read objects belonging to this segment */ | 190 | /* List of active pending_read objects belonging to this segment */ |
213 | /* Protected by mount_info.pending_reads_mutex */ | 191 | /* Protected by mount_info.pending_reads_mutex */ |
@@ -257,23 +235,7 @@ struct data_file { | |||
257 | /* Total number of blocks, data + hash */ | 235 | /* Total number of blocks, data + hash */ |
258 | int df_total_block_count; | 236 | int df_total_block_count; |
259 | 237 | ||
260 | /* For mapped files, the offset into the actual file */ | 238 | struct file_attr n_attr; |
261 | loff_t df_mapped_offset; | ||
262 | |||
263 | /* Number of data blocks written to file */ | ||
264 | atomic_t df_data_blocks_written; | ||
265 | |||
266 | /* Number of data blocks in the status block */ | ||
267 | u32 df_initial_data_blocks_written; | ||
268 | |||
269 | /* Number of hash blocks written to file */ | ||
270 | atomic_t df_hash_blocks_written; | ||
271 | |||
272 | /* Number of hash blocks in the status block */ | ||
273 | u32 df_initial_hash_blocks_written; | ||
274 | |||
275 | /* Offset to status metadata header */ | ||
276 | loff_t df_status_offset; | ||
277 | 239 | ||
278 | struct mtree *df_hash_tree; | 240 | struct mtree *df_hash_tree; |
279 | 241 | ||
@@ -300,23 +262,6 @@ struct dentry_info { | |||
300 | struct path backing_path; | 262 | struct path backing_path; |
301 | }; | 263 | }; |
302 | 264 | ||
303 | enum FILL_PERMISSION { | ||
304 | CANT_FILL = 0, | ||
305 | CAN_FILL = 1, | ||
306 | }; | ||
307 | |||
308 | struct incfs_file_data { | ||
309 | /* Does this file handle have INCFS_IOC_FILL_BLOCKS permission */ | ||
310 | enum FILL_PERMISSION fd_fill_permission; | ||
311 | |||
312 | /* If INCFS_IOC_GET_FILLED_BLOCKS has been called, where are we */ | ||
313 | int fd_get_block_pos; | ||
314 | |||
315 | /* And how many filled blocks are there up to that point */ | ||
316 | int fd_filled_data_blocks; | ||
317 | int fd_filled_hash_blocks; | ||
318 | }; | ||
319 | |||
320 | struct mount_info *incfs_alloc_mount_info(struct super_block *sb, | 265 | struct mount_info *incfs_alloc_mount_info(struct super_block *sb, |
321 | struct mount_options *options, | 266 | struct mount_options *options, |
322 | struct path *backing_dir_path); | 267 | struct path *backing_dir_path); |
@@ -326,21 +271,19 @@ int incfs_realloc_mount_info(struct mount_info *mi, | |||
326 | 271 | ||
327 | void incfs_free_mount_info(struct mount_info *mi); | 272 | void incfs_free_mount_info(struct mount_info *mi); |
328 | 273 | ||
329 | char *file_id_to_str(incfs_uuid_t id); | ||
330 | struct dentry *incfs_lookup_dentry(struct dentry *parent, const char *name); | ||
331 | struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf); | 274 | struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf); |
332 | void incfs_free_data_file(struct data_file *df); | 275 | void incfs_free_data_file(struct data_file *df); |
333 | 276 | ||
277 | int incfs_scan_metadata_chain(struct data_file *df); | ||
278 | |||
334 | struct dir_file *incfs_open_dir_file(struct mount_info *mi, struct file *bf); | 279 | struct dir_file *incfs_open_dir_file(struct mount_info *mi, struct file *bf); |
335 | void incfs_free_dir_file(struct dir_file *dir); | 280 | void incfs_free_dir_file(struct dir_file *dir); |
336 | 281 | ||
337 | ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, | 282 | ssize_t incfs_read_data_file_block(struct mem_range dst, struct file *f, |
338 | int index, u32 min_time_us, | 283 | int index, int timeout_ms, |
339 | u32 min_pending_time_us, u32 max_pending_time_us, | 284 | struct mem_range tmp); |
340 | struct mem_range tmp); | ||
341 | 285 | ||
342 | int incfs_get_filled_blocks(struct data_file *df, | 286 | int incfs_get_filled_blocks(struct data_file *df, |
343 | struct incfs_file_data *fd, | ||
344 | struct incfs_get_filled_blocks_args *arg); | 287 | struct incfs_get_filled_blocks_args *arg); |
345 | 288 | ||
346 | int incfs_read_file_signature(struct data_file *df, struct mem_range dst); | 289 | int incfs_read_file_signature(struct data_file *df, struct mem_range dst); |
@@ -360,13 +303,11 @@ bool incfs_fresh_pending_reads_exist(struct mount_info *mi, int last_number); | |||
360 | */ | 303 | */ |
361 | int incfs_collect_pending_reads(struct mount_info *mi, int sn_lowerbound, | 304 | int incfs_collect_pending_reads(struct mount_info *mi, int sn_lowerbound, |
362 | struct incfs_pending_read_info *reads, | 305 | struct incfs_pending_read_info *reads, |
363 | struct incfs_pending_read_info2 *reads2, | 306 | int reads_size); |
364 | int reads_size, int *new_max_sn); | ||
365 | 307 | ||
366 | int incfs_collect_logged_reads(struct mount_info *mi, | 308 | int incfs_collect_logged_reads(struct mount_info *mi, |
367 | struct read_log_state *start_state, | 309 | struct read_log_state *start_state, |
368 | struct incfs_pending_read_info *reads, | 310 | struct incfs_pending_read_info *reads, |
369 | struct incfs_pending_read_info2 *reads2, | ||
370 | int reads_size); | 311 | int reads_size); |
371 | struct read_log_state incfs_get_log_state(struct mount_info *mi); | 312 | struct read_log_state incfs_get_log_state(struct mount_info *mi); |
372 | int incfs_get_uncollected_logs_count(struct mount_info *mi, | 313 | int incfs_get_uncollected_logs_count(struct mount_info *mi, |
@@ -451,4 +392,6 @@ static inline int get_blocks_count_for_size(u64 size) | |||
451 | return 1 + (size - 1) / INCFS_DATA_FILE_BLOCK_SIZE; | 392 | return 1 + (size - 1) / INCFS_DATA_FILE_BLOCK_SIZE; |
452 | } | 393 | } |
453 | 394 | ||
395 | bool incfs_equal_ranges(struct mem_range lhs, struct mem_range rhs); | ||
396 | |||
454 | #endif /* _INCFS_DATA_MGMT_H */ | 397 | #endif /* _INCFS_DATA_MGMT_H */ |