Whamcloud - gitweb
filefrag: Lustre changes to filefrag FIEMAP handling
[tools/e2fsprogs.git] / lib / ext2fs / fiemap.h
1 /*
2  * FS_IOC_FIEMAP ioctl infrastructure.
3  *
4  * Some portions copyright (C) 2007 Cluster File Systems, Inc
5  *
6  * Authors: Mark Fasheh <mfasheh@suse.com>
7  *          Kalpak Shah <kalpak.shah@sun.com>
8  *          Andreas Dilger <adilger@sun.com>
9  */
10
11 #ifndef _LINUX_FIEMAP_H
12 #define _LINUX_FIEMAP_H
13
14 struct fiemap_extent {
15         __u64 fe_logical;  /* logical offset in bytes for the start of
16                             * the extent from the beginning of the file */
17         __u64 fe_physical; /* physical offset in bytes for the start
18                             * of the extent from the beginning of the disk */
19         __u64 fe_length;   /* length in bytes for this extent */
20         __u64 fe_reserved64[2];
21         __u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
22         __u32 fe_device;   /* device number (fs-specific if FIEMAP_EXTENT_NET)
23                             * low 16bits are used */
24         __u32 fe_reserved[2];
25 };
26
27 struct fiemap {
28         __u64 fm_start;         /* logical offset (inclusive) at
29                                  * which to start mapping (in) */
30         __u64 fm_length;        /* logical length of mapping which
31                                  * userspace wants (in) */
32         __u32 fm_flags;         /* FIEMAP_FLAG_* flags for request (in/out) */
33         __u32 fm_mapped_extents;/* number of extents that were mapped (out) */
34         __u32 fm_extent_count;  /* size of fm_extents array (in) */
35         __u32 fm_reserved;
36 #if __GNUC_PREREQ (4, 8)
37 #pragma GCC diagnostic push
38 #pragma GCC diagnostic ignored "-Wpedantic"
39 #endif
40         struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
41 #if __GNUC_PREREQ (4, 8)
42 #pragma GCC diagnostic pop
43 #endif
44 };
45
46 #if defined(__linux__) && !defined(FS_IOC_FIEMAP)
47 #define FS_IOC_FIEMAP   _IOWR('f', 11, struct fiemap)
48 #endif
49
50 #if defined(__linux__) && !defined(FS_IOC_GETSTATE)
51 #define EXT4_IOC_GETSTATE               _IOW('f', 41, __u32)
52 #endif
53
54 #if defined(__linux__) && !defined(EXT4_IOC_GET_ES_CACHE)
55 #define EXT4_IOC_GET_ES_CACHE           _IOWR('f', 42, struct fiemap)
56 #endif
57
58 #if defined(__linux__) && !defined(EXT4_STATE_FLAG_EXT_PRECACHED)
59 #define EXT4_STATE_FLAG_EXT_PRECACHED   0x00000001
60 #endif
61
62 #define FIEMAP_MAX_OFFSET       (~0ULL)
63
64 #define FIEMAP_FLAG_SYNC        0x00000001 /* sync file data before map */
65 #define FIEMAP_FLAG_XATTR       0x00000002 /* map extended attribute tree */
66 #define FIEMAP_FLAG_CACHE       0x00000004 /* request caching of the extents */
67 #define FIEMAP_FLAG_DEVICE_ORDER 0x40000000 /* return device ordered mapping */
68
69 #define FIEMAP_FLAGS_COMPAT     (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
70
71 #define FIEMAP_EXTENT_LAST              0x00000001 /* Last extent in file. */
72 #define FIEMAP_EXTENT_UNKNOWN           0x00000002 /* Data location unknown. */
73 #define FIEMAP_EXTENT_DELALLOC          0x00000004 /* Location still pending.
74                                                     * Sets EXTENT_UNKNOWN. */
75 #define FIEMAP_EXTENT_ENCODED           0x00000008 /* Data can not be read
76                                                     * while fs is unmounted */
77 #define FIEMAP_EXTENT_DATA_ENCRYPTED    0x00000080 /* Data is encrypted by fs.
78                                                     * Sets EXTENT_NO_BYPASS. */
79 #define FIEMAP_EXTENT_NOT_ALIGNED       0x00000100 /* Extent offsets may not be
80                                                     * block aligned. */
81 #define FIEMAP_EXTENT_DATA_INLINE       0x00000200 /* Data mixed with metadata.
82                                                     * Sets EXTENT_NOT_ALIGNED.*/
83 #define FIEMAP_EXTENT_DATA_TAIL         0x00000400 /* Multiple files in block.
84                                                     * Sets EXTENT_NOT_ALIGNED.*/
85 #define FIEMAP_EXTENT_UNWRITTEN         0x00000800 /* Space allocated, but
86                                                     * no data (i.e. zero). */
87 #define FIEMAP_EXTENT_MERGED            0x00001000 /* File does not natively
88                                                     * support extents. Result
89                                                     * merged for efficiency. */
90 #define FIEMAP_EXTENT_SHARED            0x00002000 /* Space shared with other
91                                                     * files. */
92
93 #define EXT4_FIEMAP_EXTENT_HOLE         0x08000000 /* Entry in extent status
94                                                       cache for a hole*/
95 /* Network filesystem flags - use a high bit, don't conflict with upstream */
96 #define FIEMAP_EXTENT_NET               0x80000000 /* Data stored remotely. */
97
98 #endif /* _LINUX_FIEMAP_H */