23#if defined(_MSC_VER) && defined(__REACTOS__)
25#pragma warning(disable: 4018)
26#pragma warning(disable: 4242)
27#pragma warning(disable: 4244)
34#define EXT4_EXT_MAY_ZEROOUT 0x1
36#define EXT4_EXT_MARK_UNWRIT1 0x2
37#define EXT4_EXT_MARK_UNWRIT2 0x4
39#define EXT4_EXT_DATA_VALID1 0x8
40#define EXT4_EXT_DATA_VALID2 0x10
42#define CONFIG_EXTENT_TEST
43#ifdef CONFIG_EXTENT_TEST
45#define ext4_mark_inode_dirty(icb, handle, n) ext3_mark_inode_dirty(icb, n)
56 unsigned long *
count,
int *errp)
91#define EXT4_ERROR_INODE(inode, str, ...) do { \
92 DbgPrint("inode[%p]: " str "\n", inode, ##__VA_ARGS__); \
95#define EXT4_ERROR_INODE(inode, str, ...) do { \
96 DbgPrint("inode[%p]: "##str "\n", inode, __VA_ARGS__); \
100#define EXT4_ERROR_INODE
103#define ext4_std_error(s, err)
112#define EXT_MAX_BLOCKS 0xffffffff
121#ifdef AGGRESSIVE_TEST
134#ifdef AGGRESSIVE_TEST
148#ifdef AGGRESSIVE_TEST
162#ifdef AGGRESSIVE_TEST
210 if (!buffer_uptodate(bh)) {
214 if (buffer_verified(bh))
220 set_buffer_verified(bh);
228#define read_extent_tree_block(inode, pblk, depth, flags) \
229 __read_extent_tree_block("", __LINE__, (inode), (pblk), \
232#define ext4_ext_check(inode, eh, depth, pblk) \
233 __ext4_ext_check("", __LINE__, (inode), (eh), (depth), (pblk))
330 if (
block > ext_block)
331 return ext_pblk + (
block - ext_block);
333 return ext_pblk - (ext_block -
block);
428 ext_debug(
"Warning: extent checksum damaged? tail->et_checksum = "
429 "%lu, ext4_ext_block_csum = %lu\n",
458 if (
block < (
m->ei_block))
462 ext_debug(
"%p(%u):%p(%u):%p(%u) ",
l, (
l->ei_block),
471#ifdef CHECK_BINSEARCH
537 (
path->p_ext->ee_block),
542#ifdef CHECK_BINSEARCH
550 <= (
ex[-1].ee_block));
571 }
else if (
path->p_ext) {
628 ext_debug(
"move %d:%llu:[%d]%d in new leaf %llu\n",
639#define ext4_ext_show_path(inode, path)
640#define ext4_ext_show_leaf(inode, path)
641#define ext4_ext_show_move(inode, path, newblock, level)
651 short int depth,
i, ppos = 0;
683 path[ppos].p_depth =
i;
698 "ppos %d > depth %d", ppos,
depth);
702 path[ppos].p_bh = bh;
703 path[ppos].p_hdr = eh;
706 path[ppos].p_depth =
i;
748 "logical %d == ei_block %d!",
756 "eh_entries %d >= eh_max %d!",
764 ext_debug(
"insert new index %d after: %llu\n", logical,
ptr);
765 ix = curp->
p_idx + 1;
768 ext_debug(
"insert new index %d before: %llu\n", logical,
ptr);
776 "move %d indices from 0x%p to 0x%p\n",
777 logical,
len, ix, ix + 1);
838 " next leaf starts at %d\n",
843 " next leaf starts at %d\n",
870 ablocks[
a] = newblock;
874 newblock = ablocks[--
a];
916 set_buffer_uptodate(bh);
944 ext_debug(
"create %d intermediate indices\n",
k);
950 newblock = ablocks[--
a];
970 ext_debug(
"int.index at %d (block %llu): %u -> %llu\n",
977 "EXT_MAX_INDEX != EXT_LAST_INDEX ee_block %d!",
993 set_buffer_uptodate(bh);
1084 set_buffer_uptodate(bh);
1100 ext_debug(
"new root: num %d(%d), lblock %d, ptr %llu\n",
1119 unsigned int mb_flags,
1120 unsigned int gb_flags,
1217 "EXT_FIRST_EXTENT != ex *logical %d ee_block %d!",
1221 while (--
depth >= 0) {
1225 "ix (%d) != EXT_FIRST_INDEX (%d) (depth %d)!",
1238 "logical %d < ee_block %d + ee_len %d!",
1285 if (*logical < (
ex->ee_block)) {
1288 "first_extent(path[%d].p_hdr) != ex",
1292 while (--
depth >= 0) {
1296 "ix != EXT_FIRST_INDEX *logical %d!",
1307 "logical %d < ee_block %d + ee_len %d!",
1320 while (--
depth >= 0) {
1335 while (++depth < path->p_depth) {
1354 *logical = (
ex->ee_block);
1379 while (
depth >= 0) {
1416 while (
depth >= 0) {
1447 "ex %p == NULL or eh %p == NULL",
ex, eh);
1494 unsigned short ext1_ee_len, ext2_ee_len;
1522#ifdef AGGRESSIVE_TEST
1523 if (ext1_ee_len >= 4)
1545 int merge_done = 0, unwritten;
1587 if ((
path[0].p_depth != 1) ||
1608 path[1].p_maxdepth =
path[0].p_maxdepth;
1610 path[0].p_depth = 0;
1663 int mb_flags = 0, unwritten;
1703 ext_debug(
"append [%d]%d block to %u:[%d]%d"
1728 ext_debug(
"prepend %u[%d]%d block to %u:[%d]%d"
1779 ext_debug(
"next leaf has no free space(%d,%d)\n",
1805 ext_debug(
"first extent in the leaf: %u:%llu:[%d]%d\n",
1815 ext_debug(
"insert %u:%llu:[%d]%d before: "
1826 ext_debug(
"insert %u:%llu:[%d]%d after: "
1837 "move %d extents from 0x%p to 0x%p\n",
1842 len, nearex, nearex + 1);
1897 unsigned long from,
unsigned long to)
1944 int err = 0, correct_index = 0;
1948 unsigned long ex_ee_block;
1949 unsigned short ex_ee_len;
1965 ex_ee_block + ex_ee_len >
start) {
1969 b = (
unsigned long long)ex_ee_block + ex_ee_len - 1 <
1973 if (
a != ex_ee_block &&
b != ex_ee_block + ex_ee_len - 1) {
1977 }
else if (
a != ex_ee_block) {
1979 block = ex_ee_block;
1981 }
else if (
b != ex_ee_block + ex_ee_len - 1) {
1989 block = ex_ee_block;
1992 BUG_ON(
b != ex_ee_block + ex_ee_len - 1);
2116 memcpy(&orig_ex,
ex,
sizeof(orig_ex));
2127 goto fix_extent_len;
2164 goto fix_extent_len;
2170 goto fix_extent_len;
2174 goto fix_extent_len;
2240 while (
i >= 0 &&
err == 0) {
2275 path[
i+1].p_bh = bh;
2283 if (
path[
i].p_hdr->eh_entries == 0 &&
i > 0) {
2297 if (
path->p_hdr->eh_entries == 0) {
2386 unsigned long max_blocks,
struct buffer_head *bh_result,
2392 unsigned long allocated = 0;
2395 clear_buffer_new(bh_result);
2427 newblock = iblock -
ee_block + ee_start;
2442 newblock = iblock -
ee_block + ee_start;
2460 allocated =
next - iblock;
2463 if (allocated > max_blocks)
2464 allocated = max_blocks;
2500 set_buffer_new(bh_result);
2503 if (allocated > max_blocks)
2504 allocated = max_blocks;
2507 set_buffer_mapped(bh_result);
2517 return err ?
err : allocated;
2531#if defined(_MSC_VER) && defined(__REACTOS__)
_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