blob: 9deba46c88cc1aac0a0306c02946496aa36d0f3d [file] [log] [blame]
Theodore Ts'o69365c62009-08-22 13:27:40 -04001/*
2 * bmap64.h --- 64-bit bitmap structure
3 *
4 * Copyright (C) 2007, 2008 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
10 */
11
Lukas Czerner9288e3b2011-12-16 17:31:07 -050012struct ext2_bmap_statistics {
13 int type;
14 struct timeval created;
15
16#ifdef BMAP_STATS_OPS
17 unsigned long copy_count;
18 unsigned long resize_count;
19 unsigned long mark_count;
20 unsigned long unmark_count;
21 unsigned long test_count;
22 unsigned long mark_ext_count;
23 unsigned long unmark_ext_count;
24 unsigned long test_ext_count;
25 unsigned long set_range_count;
26 unsigned long get_range_count;
27 unsigned long clear_count;
28
29 blk64_t last_marked;
30 blk64_t last_tested;
31 blk64_t mark_back;
32 blk64_t test_back;
33
34 unsigned long mark_seq;
35 unsigned long test_seq;
36#endif /* BMAP_STATS_OPS */
37};
38
39
Theodore Ts'o69365c62009-08-22 13:27:40 -040040struct ext2fs_struct_generic_bitmap {
41 errcode_t magic;
42 ext2_filsys fs;
43 struct ext2_bitmap_ops *bitmap_ops;
44 int flags;
45 __u64 start, end;
46 __u64 real_end;
Theodore Ts'o94968e72011-06-10 17:55:09 -040047 int cluster_bits;
Theodore Ts'o69365c62009-08-22 13:27:40 -040048 char *description;
49 void *private;
50 errcode_t base_error_code;
Lukas Czerner9288e3b2011-12-16 17:31:07 -050051#ifdef BMAP_STATS
52 struct ext2_bmap_statistics stats;
53#endif
Theodore Ts'o69365c62009-08-22 13:27:40 -040054};
55
56#define EXT2FS_IS_32_BITMAP(bmap) \
57 (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
58 ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
59 ((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
60
61#define EXT2FS_IS_64_BITMAP(bmap) \
62 (((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
63 ((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
64 ((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
65
66struct ext2_bitmap_ops {
67 int type;
68 /* Generic bmap operators */
69 errcode_t (*new_bmap)(ext2_filsys fs, ext2fs_generic_bitmap bmap);
70 void (*free_bmap)(ext2fs_generic_bitmap bitmap);
71 errcode_t (*copy_bmap)(ext2fs_generic_bitmap src,
72 ext2fs_generic_bitmap dest);
73 errcode_t (*resize_bmap)(ext2fs_generic_bitmap bitmap,
74 __u64 new_end,
75 __u64 new_real_end);
76 /* bit set/test operators */
77 int (*mark_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
78 int (*unmark_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
79 int (*test_bmap)(ext2fs_generic_bitmap bitmap, __u64 arg);
80 void (*mark_bmap_extent)(ext2fs_generic_bitmap bitmap, __u64 arg,
81 unsigned int num);
82 void (*unmark_bmap_extent)(ext2fs_generic_bitmap bitmap, __u64 arg,
83 unsigned int num);
84 int (*test_clear_bmap_extent)(ext2fs_generic_bitmap bitmap,
85 __u64 arg, unsigned int num);
86 errcode_t (*set_bmap_range)(ext2fs_generic_bitmap bitmap,
87 __u64 start, size_t num, void *in);
88 errcode_t (*get_bmap_range)(ext2fs_generic_bitmap bitmap,
89 __u64 start, size_t num, void *out);
90 void (*clear_bmap)(ext2fs_generic_bitmap bitmap);
Lukas Czerner9288e3b2011-12-16 17:31:07 -050091 void (*print_stats)(ext2fs_generic_bitmap);
Sami Liedesc1a1e7f2012-03-10 22:36:12 +020092
93 /* Find the first zero bit between start and end, inclusive.
94 * May be NULL, in which case a generic function is used. */
95 errcode_t (*find_first_zero)(ext2fs_generic_bitmap bitmap,
96 __u64 start, __u64 end, __u64 *out);
Theodore Ts'odff0b6a2014-01-12 15:57:31 -050097 /* Find the first set bit between start and end, inclusive.
98 * May be NULL, in which case a generic function is used. */
99 errcode_t (*find_first_set)(ext2fs_generic_bitmap bitmap,
100 __u64 start, __u64 end, __u64 *out);
Theodore Ts'o69365c62009-08-22 13:27:40 -0400101};
102
103extern struct ext2_bitmap_ops ext2fs_blkmap64_bitarray;
Lukas Czernerc1359d92011-12-18 00:29:33 -0500104extern struct ext2_bitmap_ops ext2fs_blkmap64_rbtree;