-
Notifications
You must be signed in to change notification settings - Fork 83
/
dedupe.h
74 lines (61 loc) · 1.91 KB
/
dedupe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* dedupe.h
*
* Copyright (C) 2016 SUSE. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
*/
#ifndef __DEDUPE_H__
#define __DEDUPE_H__
#include "list.h"
#include "ioctl.h"
#define MAX_DEDUPES_PER_IOCTL 120
struct dedupe_ctxt {
/*
* Starting len/file off saved for the callers convenience -
* the ones below can change during dedupe operations.
*/
uint64_t orig_len;
uint64_t orig_file_off;
uint64_t len;
struct filerec *ioctl_file;
uint64_t ioctl_file_off;
/* Next two are used for sanity checking */
unsigned int max_queable;
unsigned int num_queued;
unsigned int same_size;
/*
* request tracking.
* queued: request is awaiting dedupe
* in_progress: currently undergoing dedupe operations
* completed: results of dedupe for this request are available
*/
struct list_head queued;
struct list_head in_progress;
struct list_head completed;
struct file_dedupe_range *same;
};
struct dedupe_ctxt *new_dedupe_ctxt(unsigned int max_extents, uint64_t loff,
uint64_t elen, struct filerec *ioctl_file);
void free_dedupe_ctxt(struct dedupe_ctxt *ctxt);
/*
* add_extent_to_dedupe returns:
* < 0: error
* == 0: no more extents after this one
* > 0: ok, can accept more extents
*/
int add_extent_to_dedupe(struct dedupe_ctxt *ctxt, uint64_t loff,
struct filerec *file);
int dedupe_extents(struct dedupe_ctxt *ctxt);
int pop_one_dedupe_result(struct dedupe_ctxt *ctxt, int *status,
uint64_t *off, uint64_t *bytes_deduped,
struct filerec **file);
#endif /* __DEDUPE_H__ */