21#pragma warning(disable: 4018)
22#pragma warning(disable: 4242)
23#pragma warning(disable: 4244)
30#define EXT4_EXT_MAY_ZEROOUT 0x1
32#define EXT4_EXT_MARK_UNWRIT1 0x2
33#define EXT4_EXT_MARK_UNWRIT2 0x4
35#define EXT4_EXT_DATA_VALID1 0x8
36#define EXT4_EXT_DATA_VALID2 0x10
38#define CONFIG_EXTENT_TEST
39#ifdef CONFIG_EXTENT_TEST
41#define ext4_mark_inode_dirty(icb, handle, n) ext3_mark_inode_dirty(icb, n)
52 unsigned long *
count,
int *errp)
86#define EXT4_ERROR_INODE(inode, str, ...) do { \
87 DbgPrint("inode[%p]: " str "\n", inode, ##__VA_ARGS__); \
90#define EXT4_ERROR_INODE
93#define ext4_std_error(s, err)
102#define EXT_MAX_BLOCKS 0xffffffff
111#ifdef AGGRESSIVE_TEST
124#ifdef AGGRESSIVE_TEST
138#ifdef AGGRESSIVE_TEST
152#ifdef AGGRESSIVE_TEST
200 if (!buffer_uptodate(bh)) {
204 if (buffer_verified(bh))
210 set_buffer_verified(bh);
218#define read_extent_tree_block(inode, pblk, depth, flags) \
219 __read_extent_tree_block("", __LINE__, (inode), (pblk), \
222#define ext4_ext_check(inode, eh, depth, pblk) \
223 __ext4_ext_check("", __LINE__, (inode), (eh), (depth), (pblk))
320 if (
block > ext_block)
321 return ext_pblk + (
block - ext_block);
323 return ext_pblk - (ext_block -
block);
417 ext_debug(
"Warning: extent checksum damaged? tail->et_checksum = "
418 "%lu, ext4_ext_block_csum = %lu\n",
447 if (
block < (
m->ei_block))
451 ext_debug(
"%p(%u):%p(%u):%p(%u) ",
l, (
l->ei_block),
460#ifdef CHECK_BINSEARCH
526 (
path->p_ext->ee_block),
531#ifdef CHECK_BINSEARCH
539 <= (
ex[-1].ee_block));
560 }
else if (
path->p_ext) {
617 ext_debug(
"move %d:%llu:[%d]%d in new leaf %llu\n",
628#define ext4_ext_show_path(inode, path)
629#define ext4_ext_show_leaf(inode, path)
630#define ext4_ext_show_move(inode, path, newblock, level)
640 short int depth,
i, ppos = 0;
672 path[ppos].p_depth =
i;
687 "ppos %d > depth %d", ppos,
depth);
691 path[ppos].p_bh = bh;
692 path[ppos].p_hdr = eh;
695 path[ppos].p_depth =
i;
737 "logical %d == ei_block %d!",
745 "eh_entries %d >= eh_max %d!",
753 ext_debug(
"insert new index %d after: %llu\n", logical,
ptr);
754 ix = curp->
p_idx + 1;
757 ext_debug(
"insert new index %d before: %llu\n", logical,
ptr);
765 "move %d indices from 0x%p to 0x%p\n",
766 logical,
len, ix, ix + 1);
827 " next leaf starts at %d\n",
832 " next leaf starts at %d\n",
859 ablocks[
a] = newblock;
863 newblock = ablocks[--
a];
905 set_buffer_uptodate(bh);
933 ext_debug(
"create %d intermediate indices\n",
k);
939 newblock = ablocks[--
a];
959 ext_debug(
"int.index at %d (block %llu): %u -> %llu\n",
966 "EXT_MAX_INDEX != EXT_LAST_INDEX ee_block %d!",
982 set_buffer_uptodate(bh);
1073 set_buffer_uptodate(bh);
1089 ext_debug(
"new root: num %d(%d), lblock %d, ptr %llu\n",
1108 unsigned int mb_flags,
1109 unsigned int gb_flags,
1206 "EXT_FIRST_EXTENT != ex *logical %d ee_block %d!",
1210 while (--
depth >= 0) {
1214 "ix (%d) != EXT_FIRST_INDEX (%d) (depth %d)!",
1227 "logical %d < ee_block %d + ee_len %d!",
1274 if (*logical < (
ex->ee_block)) {
1277 "first_extent(path[%d].p_hdr) != ex",
1281 while (--
depth >= 0) {
1285 "ix != EXT_FIRST_INDEX *logical %d!",
1296 "logical %d < ee_block %d + ee_len %d!",
1309 while (--
depth >= 0) {
1324 while (++depth < path->p_depth) {
1343 *logical = (
ex->ee_block);
1368 while (
depth >= 0) {
1405 while (
depth >= 0) {
1436 "ex %p == NULL or eh %p == NULL",
ex, eh);
1483 unsigned short ext1_ee_len, ext2_ee_len;
1511#ifdef AGGRESSIVE_TEST
1512 if (ext1_ee_len >= 4)
1534 int merge_done = 0, unwritten;
1576 if ((
path[0].p_depth != 1) ||
1597 path[1].p_maxdepth =
path[0].p_maxdepth;
1599 path[0].p_depth = 0;
1652 int mb_flags = 0, unwritten;
1692 ext_debug(
"append [%d]%d block to %u:[%d]%d"
1717 ext_debug(
"prepend %u[%d]%d block to %u:[%d]%d"
1768 ext_debug(
"next leaf has no free space(%d,%d)\n",
1794 ext_debug(
"first extent in the leaf: %u:%llu:[%d]%d\n",
1804 ext_debug(
"insert %u:%llu:[%d]%d before: "
1815 ext_debug(
"insert %u:%llu:[%d]%d after: "
1826 "move %d extents from 0x%p to 0x%p\n",
1831 len, nearex, nearex + 1);
1886 unsigned long from,
unsigned long to)
1933 int err = 0, correct_index = 0;
1937 unsigned long ex_ee_block;
1938 unsigned short ex_ee_len;
1954 ex_ee_block + ex_ee_len >
start) {
1958 b = (
unsigned long long)ex_ee_block + ex_ee_len - 1 <
1962 if (
a != ex_ee_block &&
b != ex_ee_block + ex_ee_len - 1) {
1966 }
else if (
a != ex_ee_block) {
1968 block = ex_ee_block;
1970 }
else if (
b != ex_ee_block + ex_ee_len - 1) {
1978 block = ex_ee_block;
1981 BUG_ON(
b != ex_ee_block + ex_ee_len - 1);
2105 memcpy(&orig_ex,
ex,
sizeof(orig_ex));
2116 goto fix_extent_len;
2153 goto fix_extent_len;
2159 goto fix_extent_len;
2163 goto fix_extent_len;
2229 while (
i >= 0 &&
err == 0) {
2264 path[
i+1].p_bh = bh;
2272 if (
path[
i].p_hdr->eh_entries == 0 &&
i > 0) {
2286 if (
path->p_hdr->eh_entries == 0) {
2375 unsigned long max_blocks,
struct buffer_head *bh_result,
2381 unsigned long allocated = 0;
2384 clear_buffer_new(bh_result);
2416 newblock = iblock -
ee_block + ee_start;
2431 newblock = iblock -
ee_block + ee_start;
2449 allocated =
next - iblock;
2452 if (allocated > max_blocks)
2453 allocated = max_blocks;
2489 set_buffer_new(bh_result);
2492 if (allocated > max_blocks)
2493 allocated = max_blocks;
2496 set_buffer_mapped(bh_result);
2506 return err ?
err : allocated;
_STLP_MOVE_TO_STD_NAMESPACE _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2, _OutputIter __result)
struct outqueuenode * tail
static LPSTR * split(LPSTR s, LPINT args)
#define NT_SUCCESS(StatCode)
static void cleanup(void)
#define check(expected, result)
NTSTATUS Ext2NewBlock(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG GroupHint, IN ULONG BlockHint, OUT PULONG Block, IN OUT PULONG Number)
NTSTATUS Ext2FreeBlock(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN ULONG Block, IN ULONG Number)
int Ext2LinuxError(NTSTATUS Status)
unsigned long long ext4_fsblk_t
#define EXT4_MB_USE_RESERVED
#define EXT4_FREE_BLOCKS_FORGET
#define EXT4_FREE_BLOCKS_METADATA
#define EXT4_GET_BLOCKS_PRE_IO
#define EXT4_GET_BLOCKS_METADATA_NOFAIL
#define EXT4_MB_DELALLOC_RESERVED
#define EXT4_GET_BLOCKS_DELALLOC_RESERVE
static void ext4_ext_mark_unwritten(struct ext4_extent *ext)
#define EXT_MAX_INDEX(__hdr__)
#define EXT_HAS_FREE_INDEX(__path__)
static void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
static struct ext4_extent_header * ext_inode_hdr(struct inode *inode)
static int ext4_ext_is_unwritten(struct ext4_extent *ext)
static void ext4_ext_mark_initialized(struct ext4_extent *ext)
#define EXT_UNWRITTEN_MAX_LEN
static struct ext4_extent_header * ext_block_hdr(struct buffer_head *bh)
static struct ext4_extent_tail * find_ext4_extent_tail(struct ext4_extent_header *eh)
#define EXT_LAST_INDEX(__hdr__)
#define EXT_FIRST_EXTENT(__hdr__)
static ext4_fsblk_t ext4_idx_pblock(struct ext4_extent_idx *ix)
#define ext4_ext_dirty(icb, handle, inode, path)
static unsigned short ext_depth(struct inode *inode)
static ext4_fsblk_t ext4_ext_pblock(struct ext4_extent *ex)
#define EXT_FIRST_INDEX(__hdr__)
#define EXT_LAST_EXTENT(__hdr__)
static void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
#define EXT_MAX_EXTENT(__hdr__)
static uint16_t ext4_ext_get_actual_len(struct ext4_extent *ext)
static void ext4_ext_try_to_merge(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *path, struct ext4_extent *ex)
int ext4_ext_tree_init(void *icb, handle_t *handle, struct inode *inode)
#define ext4_ext_check(inode, eh, depth, pblk)
static int ext4_ext_grow_indepth(void *icb, handle_t *handle, struct inode *inode, unsigned int flags)
static int get_default_free_blocks_flags(struct inode *inode)
static int ext4_ext_split(void *icb, handle_t *handle, struct inode *inode, unsigned int flags, struct ext4_ext_path *path, struct ext4_extent *newext, int at)
static struct buffer_head * __read_extent_tree_block(const char *function, unsigned int line, struct inode *inode, ext4_fsblk_t pblk, int depth, int flags)
static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode, struct ext4_ext_path *path, ext4_lblk_t block)
#define ext4_ext_show_path(inode, path)
static int ext4_ext_search_right(struct inode *inode, struct ext4_ext_path *path, ext4_lblk_t *logical, ext4_fsblk_t *phys, struct ext4_extent **ret_ex)
static int ext4_ext_get_access(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *path)
int __ext4_ext_dirty(const char *where, unsigned int line, void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *path)
void ext4_ext_drop_refs(struct ext4_ext_path *path)
static uint32_t ext4_ext_block_csum(struct inode *inode, struct ext4_extent_header *eh)
int ext4_ext_rm_idx(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *path)
static ext4_fsblk_t ext4_inode_to_goal_block(struct inode *inode)
static int __ext4_ext_check(const char *function, unsigned int line, struct inode *inode, struct ext4_extent_header *eh, int depth, ext4_fsblk_t pblk)
static int ext4_force_split_extent_at(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path **ppath, ext4_lblk_t lblk, int nofail)
static void ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, ext4_lblk_t block)
static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex)
static int ext4_ext_convert_to_initialized(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path **ppath, ext4_lblk_t split, unsigned long blocks, int flags)
static int ext4_ext_search_left(struct inode *inode, struct ext4_ext_path *path, ext4_lblk_t *logical, ext4_fsblk_t *phys)
int ext4_ext_insert_extent(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path **ppath, struct ext4_extent *newext, int gb_flags)
static ext4_lblk_t ext4_ext_next_leaf_block(struct ext4_ext_path *path)
#define EXT4_EXT_MAY_ZEROOUT
static int ext4_remove_blocks(void *icb, handle_t *handle, struct inode *inode, struct ext4_extent *ex, unsigned long from, unsigned long to)
static int ext4_ext_insert_index(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *curp, int logical, ext4_fsblk_t ptr)
#define EXT4_EXT_MARK_UNWRIT1
static ext4_fsblk_t ext4_ext_new_meta_block(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *path, struct ext4_extent *ex, int *err, unsigned int flags)
static void ext4_ext_binsearch_idx(struct inode *inode, struct ext4_ext_path *path, ext4_lblk_t block)
#define EXT4_EXT_DATA_VALID2
static int ext4_ext_more_to_rm(struct ext4_ext_path *path)
int ext4_ext_truncate(void *icb, struct inode *inode, unsigned long start)
void ext4_ext_init(struct super_block *sb)
#define ext4_std_error(s, err)
static int ext4_ext_space_block(struct inode *inode, int check)
static void ext4_ext_try_to_merge_up(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *path)
#define ext4_mark_inode_dirty(icb, handle, n)
static int ext4_ext_correct_indexes(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *path)
static void ext_debug(char *str,...)
static int ext4_ext_space_root(struct inode *inode, int check)
static int ext4_ext_create_new_leaf(void *icb, handle_t *handle, struct inode *inode, unsigned int mb_flags, unsigned int gb_flags, struct ext4_ext_path **ppath, struct ext4_extent *newext)
static void ext4_extent_block_csum_set(struct inode *inode, struct ext4_extent_header *eh)
static int ext4_ext_max_entries(struct inode *inode, int depth)
static int ext4_split_extent_at(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path **ppath, ext4_lblk_t split, int split_flag, int flags)
static void ext4_free_blocks(void *icb, handle_t *handle, struct inode *inode, void *fake, ext4_fsblk_t block, int count, int flags)
struct ext4_ext_path * ext4_find_extent(struct inode *inode, ext4_lblk_t block, struct ext4_ext_path **orig_path, int flags)
static ext4_fsblk_t ext4_new_meta_blocks(void *icb, handle_t *handle, struct inode *inode, ext4_fsblk_t goal, unsigned int flags, unsigned long *count, int *errp)
static int ext4_ext_space_block_idx(struct inode *inode, int check)
int ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1, struct ext4_extent *ex2)
ext4_lblk_t ext4_ext_next_allocated_block(struct ext4_ext_path *path)
int ext4_ext_check_inode(struct inode *inode)
#define ext4_ext_show_leaf(inode, path)
static int ext4_ext_try_to_merge_right(struct inode *inode, struct ext4_ext_path *path, struct ext4_extent *ex)
#define EXT4_EXT_MARK_UNWRIT2
int ext4_ext_remove_space(void *icb, struct inode *inode, unsigned long start)
static int ext4_ext_space_root_idx(struct inode *inode, int check)
#define read_extent_tree_block(inode, pblk, depth, flags)
#define EXT4_EXT_DATA_VALID1
static int ext4_ext_rm_leaf(void *icb, handle_t *handle, struct inode *inode, struct ext4_ext_path *path, unsigned long start)
#define ext4_ext_show_move(inode, path, newblock, level)
int ext4_ext_get_blocks(void *icb, handle_t *handle, struct inode *inode, ext4_fsblk_t iblock, unsigned long max_blocks, struct buffer_head *bh_result, int create, int flags)
int __ext4_handle_dirty_metadata(const char *where, unsigned int line, void *icb, handle_t *handle, struct inode *inode, struct buffer_head *bh)
#define ext4_handle_dirty_metadata(handle, icb, inode, bh)
#define ext4_journal_get_write_access(handle, icb, bh)
static int ext4_journal_extend(void *icb, handle_t *handle, int nblocks)
#define ext4_journal_get_create_access(handle, icb, bh)
#define ext4_journal_stop(icb, handle)
GLint GLint GLsizei GLsizei GLsizei GLint border
GLint GLint GLsizei GLsizei GLsizei depth
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble r
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
struct buffer_head * extents_bread(struct super_block *sb, sector_t block)
#define kmalloc(size, gfp)
static long IS_ERR(const void *ptr)
static void * ERR_PTR(long error)
static long PTR_ERR(const void *ptr)
void extents_brelse(struct buffer_head *bh)
void * kzalloc(int size, int flags)
static void le16_add_cpu(__le16 *var, u16 val)
struct buffer_head * extents_bwrite(struct super_block *sb, sector_t block)
static const struct access_res create[16]
static unsigned __int64 next
struct block_device * b_bdev
struct ext4_extent_header * p_hdr
struct buffer_head * p_bh
struct ext4_extent_idx * p_idx
struct ext4_extent * p_ext
struct super_block * i_sb
static const WCHAR * error_msg[8]
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
static unsigned int block