Skip to content
Snippets Groups Projects
Commit a8899581 authored by alex's avatar alex
Browse files

b=7049

b=7085

 - port old fixes from b1_4 to HEAD (extents related)
 - unify extents & fsfilt codebase with fsfilt
parent 46433ea1
No related branches found
No related tags found
No related merge requests found
...@@ -9,9 +9,9 @@ ext3-ea-in-inode-2.6-fc3.patch ...@@ -9,9 +9,9 @@ ext3-ea-in-inode-2.6-fc3.patch
export-ext3-2.6.10-fc3.patch export-ext3-2.6.10-fc3.patch
ext3-include-fixes-2.6-suse.patch ext3-include-fixes-2.6-suse.patch
ext3-extents-2.6.10-fc3.patch ext3-extents-2.6.10-fc3.patch
ext3-extents-in-ea-2.6.10-fc3.patch #ext3-extents-in-ea-2.6.10-fc3.patch
ext3-extents-in-ea-ioctl-2.6.10-fc3.patch #ext3-extents-in-ea-ioctl-2.6.10-fc3.patch
ext3-extents-in-ea-exports-symbol-2.6.7.patch #ext3-extents-in-ea-exports-symbol-2.6.7.patch
ext3-mds-num-2.6.10-fc3.patch ext3-mds-num-2.6.10-fc3.patch
ext3-fid-2.6.7.patch ext3-fid-2.6.7.patch
ext3-raw-lookup-2.6.10.patch ext3-raw-lookup-2.6.10.patch
......
This diff is collapsed.
...@@ -44,7 +44,7 @@ Index: linux-2.6.10/fs/ext3/extents-in-ea.c ...@@ -44,7 +44,7 @@ Index: linux-2.6.10/fs/ext3/extents-in-ea.c
+#include <linux/quotaops.h> +#include <linux/quotaops.h>
+#include <linux/string.h> +#include <linux/string.h>
+#include <linux/ext3_extents.h> +#include <linux/ext3_extents.h>
+#include <linux/ext3_xattr.h> +#include <xattr.h>
+#include <linux/slab.h> +#include <linux/slab.h>
+#include <asm/uaccess.h> +#include <asm/uaccess.h>
+ +
...@@ -128,7 +128,7 @@ Index: linux-2.6.10/fs/ext3/extents-in-ea.c ...@@ -128,7 +128,7 @@ Index: linux-2.6.10/fs/ext3/extents-in-ea.c
+ err = ext3_extent_tree_init(handle, &tree); + err = ext3_extent_tree_init(handle, &tree);
+ ext3_release_tree_in_ea_desc(&tree); + ext3_release_tree_in_ea_desc(&tree);
+out: +out:
+ ext3_journal_stop(handle, inode); + ext3_journal_stop(handle);
+ kfree(root); + kfree(root);
+ return err; + return err;
+} +}
...@@ -151,24 +151,24 @@ Index: linux-2.6.10/fs/ext3/extents-in-ea.c ...@@ -151,24 +151,24 @@ Index: linux-2.6.10/fs/ext3/extents-in-ea.c
+ up(&EXT3_I(inode)->truncate_sem); + up(&EXT3_I(inode)->truncate_sem);
+ handle = ext3_journal_start(tree->inode, needed + 10); + handle = ext3_journal_start(tree->inode, needed + 10);
+ if (IS_ERR(handle)) { + if (IS_ERR(handle)) {
+ down_write(&EXT3_I(inode)->truncate_sem); + down(&EXT3_I(inode)->truncate_sem);
+ return PTR_ERR(handle); + return PTR_ERR(handle);
+ } + }
+ +
+ if (tgen != EXT_GENERATION(tree)) { + if (tgen != EXT_GENERATION(tree)) {
+ /* the tree has changed. so path can be invalid at moment */ + /* the tree has changed. so path can be invalid at moment */
+ ext3_journal_stop(handle, inode); + ext3_journal_stop(handle);
+ down_write(&EXT3_I(inode)->truncate_sem); + down(&EXT3_I(inode)->truncate_sem);
+ return EXT_REPEAT; + return EXT_REPEAT;
+ } + }
+ +
+ down_write(&EXT3_I(inode)->truncate_sem); + down(&EXT3_I(inode)->truncate_sem);
+ +
+ /* insert new extent */ + /* insert new extent */
+ newex->ee_start = 0; + newex->ee_start = 0;
+ err = ext3_ext_insert_extent(handle, tree, path, newex); + err = ext3_ext_insert_extent(handle, tree, path, newex);
+ if (!err) + if (!err)
+ ext3_journal_stop(handle, tree->inode); + ext3_journal_stop(handle);
+ +
+ return err; + return err;
+} +}
...@@ -182,11 +182,11 @@ Index: linux-2.6.10/fs/ext3/extents-in-ea.c ...@@ -182,11 +182,11 @@ Index: linux-2.6.10/fs/ext3/extents-in-ea.c
+ +
+ err = ext3_init_tree_in_ea_desc(&tree, inode, name_index, eaname); + err = ext3_init_tree_in_ea_desc(&tree, inode, name_index, eaname);
+ if (err == 0) { + if (err == 0) {
+ down_write(&EXT3_I(inode)->truncate_sem); + down(&EXT3_I(inode)->truncate_sem);
+ err = ext3_ext_walk_space(&tree, from, num, + err = ext3_ext_walk_space(&tree, from, num,
+ ext3_ext_in_ea_new_extent); + ext3_ext_in_ea_new_extent);
+ ext3_release_tree_in_ea_desc(&tree); + ext3_release_tree_in_ea_desc(&tree);
+ up_write(&EXT3_I(inode)->truncate_sem); + up(&EXT3_I(inode)->truncate_sem);
+ } + }
+ return err; + return err;
+} +}
...@@ -351,10 +351,11 @@ Index: linux-2.6.10/fs/ext3/Makefile ...@@ -351,10 +351,11 @@ Index: linux-2.6.10/fs/ext3/Makefile
=================================================================== ===================================================================
--- linux-2.6.10.orig/fs/ext3/Makefile 2005-04-05 12:27:00.597875304 +0800 --- linux-2.6.10.orig/fs/ext3/Makefile 2005-04-05 12:27:00.597875304 +0800
+++ linux-2.6.10/fs/ext3/Makefile 2005-04-05 12:28:26.989741744 +0800 +++ linux-2.6.10/fs/ext3/Makefile 2005-04-05 12:28:26.989741744 +0800
@@ -7,6 +7,6 @@ @@ -7,7 +7,7 @@
ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
ioctl.o namei.o super.o symlink.o hash.o resize.o iopen.o \ ioctl.o namei.o super.o symlink.o hash.o resize.o iopen.o \
extents.o extents.o
-ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o -ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
+ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o extents-in-ea.o +ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o extents-in-ea.o
ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
......
...@@ -1873,24 +1873,24 @@ Index: linux-2.6.10/fs/ext3/super.c ...@@ -1873,24 +1873,24 @@ Index: linux-2.6.10/fs/ext3/super.c
int i; int i;
+ ext3_mb_release(sb); + ext3_mb_release(sb);
ext3_ext_release(sb); ext3_ext_release(sb);
ext3_xattr_put_super(sb); ext3_xattr_put_super(sb);
journal_destroy(sbi->s_journal); journal_destroy(sbi->s_journal);
@@ -592,7 +593,7 @@ @@ -592,7 +593,7 @@
Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_pdirops, Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_pdirops,
Opt_iopen, Opt_noiopen, Opt_iopen_nopriv, Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
- Opt_extents, Opt_extdebug, - Opt_extents, Opt_extdebug,
+ Opt_extents, Opt_extdebug, Opt_mballoc, Opt_mbfactor, + Opt_extents, Opt_extdebug, Opt_mballoc, Opt_mbfactor,
Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
}; };
static match_table_t tokens = {
@@ -646,6 +647,8 @@ @@ -646,6 +647,8 @@
{Opt_iopen_nopriv, "iopen_nopriv"}, {Opt_iopen_nopriv, "iopen_nopriv"},
{Opt_extents, "extents"}, {Opt_extents, "extents"},
{Opt_extdebug, "extdebug"}, {Opt_extdebug, "extdebug"},
+ {Opt_mballoc, "mballoc"}, + {Opt_mballoc, "mballoc"},
+ {Opt_mballoc, "mbfactor=%u"}, + {Opt_mbfactor, "mbfactor=%u"},
{Opt_err, NULL}, {Opt_err, NULL},
{Opt_resize, "resize"}, {Opt_resize, "resize"},
}; };
...@@ -1915,9 +1915,9 @@ Index: linux-2.6.10/fs/ext3/super.c ...@@ -1915,9 +1915,9 @@ Index: linux-2.6.10/fs/ext3/super.c
percpu_counter_mod(&sbi->s_dirs_counter, percpu_counter_mod(&sbi->s_dirs_counter,
ext3_count_dirs(sb)); ext3_count_dirs(sb));
ext3_ext_init(sb); ext3_ext_init(sb);
+ ext3_mb_init(sb, needs_recovery); + ext3_mb_init(sb, needs_recovery);
return 0; return 0;
cantfind_ext3: cantfind_ext3:
...@@ -1925,13 +1925,14 @@ Index: linux-2.6.10/fs/ext3/Makefile ...@@ -1925,13 +1925,14 @@ Index: linux-2.6.10/fs/ext3/Makefile
=================================================================== ===================================================================
--- linux-2.6.10.orig/fs/ext3/Makefile 2005-02-25 17:27:00.228757768 +0200 --- linux-2.6.10.orig/fs/ext3/Makefile 2005-02-25 17:27:00.228757768 +0200
+++ linux-2.6.10/fs/ext3/Makefile 2005-02-25 17:28:41.863306968 +0200 +++ linux-2.6.10/fs/ext3/Makefile 2005-02-25 17:28:41.863306968 +0200
@@ -5,7 +5,7 @@ @@ -5,8 +5,8 @@
ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
ioctl.o namei.o super.o symlink.o hash.o resize.o iopen.o \ ioctl.o namei.o super.o symlink.o hash.o resize.o iopen.o \
- extents.o - extents.o
+ extents.o mballoc.o + extents.o mballoc.o
ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o extents-in-ea.o
ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
ext3-$(CONFIG_EXT3_FS_SECURITY) += xattr_security.o ext3-$(CONFIG_EXT3_FS_SECURITY) += xattr_security.o
Index: linux-2.6.10/fs/ext3/balloc.c Index: linux-2.6.10/fs/ext3/balloc.c
...@@ -2131,8 +2132,8 @@ Index: linux-2.6.10/include/linux/ext3_fs.h ...@@ -2131,8 +2132,8 @@ Index: linux-2.6.10/include/linux/ext3_fs.h
*/ */
@@ -365,6 +373,7 @@ @@ -365,6 +373,7 @@
#define EXT3_MOUNT_IOPEN_NOPRIV 0x80000 /* Make iopen world-readable */ #define EXT3_MOUNT_IOPEN_NOPRIV 0x80000 /* Make iopen world-readable */
#define EXT3_MOUNT_EXTENTS 0x100000 /* Extents support */ #define EXT3_MOUNT_EXTENTS 0x100000/* Extents support */
#define EXT3_MOUNT_EXTDEBUG 0x200000 /* Extents debug */ #define EXT3_MOUNT_EXTDEBUG 0x200000/* Extents debug */
+#define EXT3_MOUNT_MBALLOC 0x400000/* Buddy allocation support */ +#define EXT3_MOUNT_MBALLOC 0x400000/* Buddy allocation support */
/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */ /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
......
...@@ -31,4 +31,3 @@ export-show_task-2.6-vanilla.patch ...@@ -31,4 +31,3 @@ export-show_task-2.6-vanilla.patch
nid-2.6-fc3.patch nid-2.6-fc3.patch
highmem-split-2.6.10-fc3.patch highmem-split-2.6.10-fc3.patch
pag-basic-2.6.10-fc3.patch pag-basic-2.6.10-fc3.patch
...@@ -9,9 +9,9 @@ ext3-ea-in-inode-2.6-fc3.patch ...@@ -9,9 +9,9 @@ ext3-ea-in-inode-2.6-fc3.patch
export-ext3-2.6.10-fc3.patch export-ext3-2.6.10-fc3.patch
ext3-include-fixes-2.6-suse.patch ext3-include-fixes-2.6-suse.patch
ext3-extents-2.6.10-fc3.patch ext3-extents-2.6.10-fc3.patch
ext3-extents-in-ea-2.6.10-fc3.patch #ext3-extents-in-ea-2.6.10-fc3.patch
ext3-extents-in-ea-ioctl-2.6.10-fc3.patch #ext3-extents-in-ea-ioctl-2.6.10-fc3.patch
ext3-extents-in-ea-exports-symbol-2.6.7.patch #ext3-extents-in-ea-exports-symbol-2.6.7.patch
ext3-mds-num-2.6.10-fc3.patch ext3-mds-num-2.6.10-fc3.patch
ext3-fid-2.6.7.patch ext3-fid-2.6.7.patch
ext3-raw-lookup-2.6.10.patch ext3-raw-lookup-2.6.10.patch
......
...@@ -369,14 +369,17 @@ static int fsfilt_ext3_commit_async(struct inode *inode, void *h, ...@@ -369,14 +369,17 @@ static int fsfilt_ext3_commit_async(struct inode *inode, void *h,
static int fsfilt_ext3_commit_wait(struct inode *inode, void *h) static int fsfilt_ext3_commit_wait(struct inode *inode, void *h)
{ {
journal_t *journal = EXT3_JOURNAL(inode);
tid_t tid = (tid_t)(long)h; tid_t tid = (tid_t)(long)h;
CDEBUG(D_INODE, "commit wait: %lu\n", (unsigned long) tid); CDEBUG(D_INODE, "commit wait: %lu\n", (unsigned long) tid);
if (is_journal_aborted(EXT3_JOURNAL(inode))) if (unlikely(is_journal_aborted(journal)))
return -EIO; return -EIO;
log_wait_commit(EXT3_JOURNAL(inode), tid); log_wait_commit(EXT3_JOURNAL(inode), tid);
if (unlikely(is_journal_aborted(journal)))
return -EIO;
return 0; return 0;
} }
...@@ -724,6 +727,14 @@ static int fsfilt_ext3_sync(struct super_block *sb) ...@@ -724,6 +727,14 @@ static int fsfilt_ext3_sync(struct super_block *sb)
return ext3_force_commit(sb); return ext3_force_commit(sb);
} }
#if defined(EXT3_MULTIBLOCK_ALLOCATOR) && (!defined(EXT3_EXT_CACHE_NO) || defined(EXT_CACHE_MARK))
#warning "kernel code has old extents/mballoc patch, disabling"
#undef EXT3_MULTIBLOCK_ALLOCATOR
#endif
#ifndef EXT3_EXTENTS_FL
#define EXT3_EXTENTS_FL 0x00080000 /* Inode uses extents */
#endif
#ifdef EXT3_MULTIBLOCK_ALLOCATOR #ifdef EXT3_MULTIBLOCK_ALLOCATOR
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#define ext3_up_truncate_sem(inode) up_write(&EXT3_I(inode)->truncate_sem); #define ext3_up_truncate_sem(inode) up_write(&EXT3_I(inode)->truncate_sem);
...@@ -752,18 +763,19 @@ struct bpointers { ...@@ -752,18 +763,19 @@ struct bpointers {
int init_num; int init_num;
int create; int create;
}; };
static int ext3_ext_find_goal(struct inode *inode, struct ext3_ext_path *path, static int ext3_ext_find_goal(struct inode *inode, struct ext3_ext_path *path,
unsigned long block, int *aflags) unsigned long block, int *aflags)
{ {
struct ext3_inode_info *ei = EXT3_I(inode); struct ext3_inode_info *ei = EXT3_I(inode);
unsigned long bg_start; unsigned long bg_start;
unsigned long colour; unsigned long colour;
int depth; int depth;
if (path) { if (path) {
struct ext3_extent *ex; struct ext3_extent *ex;
depth = path->p_depth; depth = path->p_depth;
/* try to predict block placement */ /* try to predict block placement */
if ((ex = path[depth].p_ext)) { if ((ex = path[depth].p_ext)) {
#if 0 #if 0
...@@ -772,57 +784,56 @@ static int ext3_ext_find_goal(struct inode *inode, struct ext3_ext_path *path, ...@@ -772,57 +784,56 @@ static int ext3_ext_find_goal(struct inode *inode, struct ext3_ext_path *path,
* request will fit into. This can fragment data * request will fit into. This can fragment data
* block allocation and prevents our lovely 1M I/Os * block allocation and prevents our lovely 1M I/Os
* from reaching the disk intact. */ * from reaching the disk intact. */
if (ex->ee_block + ex->ee_len == block) if (ex->ee_block + ex->ee_len == block)
*aflags |= 1; *aflags |= 1;
#endif #endif
return ex->ee_start + (block - ex->ee_block); return ex->ee_start + (block - ex->ee_block);
} }
/* it looks index is empty /* it looks index is empty
* try to find starting from index itself */ * try to find starting from index itself */
if (path[depth].p_bh) if (path[depth].p_bh)
return path[depth].p_bh->b_blocknr; return path[depth].p_bh->b_blocknr;
} }
/* OK. use inode's group */ /* OK. use inode's group */
bg_start = (ei->i_block_group * EXT3_BLOCKS_PER_GROUP(inode->i_sb)) + bg_start = (ei->i_block_group * EXT3_BLOCKS_PER_GROUP(inode->i_sb)) +
le32_to_cpu(EXT3_SB(inode->i_sb)->s_es->s_first_data_block); le32_to_cpu(EXT3_SB(inode->i_sb)->s_es->s_first_data_block);
colour = (current->pid % 16) * colour = (current->pid % 16) *
(EXT3_BLOCKS_PER_GROUP(inode->i_sb) / 16); (EXT3_BLOCKS_PER_GROUP(inode->i_sb) / 16);
return bg_start + colour + block; return bg_start + colour + block;
} }
static int ext3_ext_new_extent_cb(struct ext3_extents_tree *tree, static int ext3_ext_new_extent_cb(struct ext3_extents_tree *tree,
struct ext3_ext_path *path, struct ext3_ext_path *path,
struct ext3_extent *newex, int exist) struct ext3_ext_cache *cex)
{ {
struct inode *inode = tree->inode; struct inode *inode = tree->inode;
struct bpointers *bp = tree->private; struct bpointers *bp = tree->private;
struct ext3_extent nex;
int count, err, goal; int count, err, goal;
unsigned long pblock; unsigned long pblock;
unsigned long tgen;
loff_t new_i_size; loff_t new_i_size;
handle_t *handle; handle_t *handle;
int i, aflags = 0; int i, aflags = 0;
i = EXT_DEPTH(tree); i = EXT_DEPTH(tree);
EXT_ASSERT(i == path->p_depth); EXT_ASSERT(i == path->p_depth);
EXT_ASSERT(path[i].p_hdr); EXT_ASSERT(path[i].p_hdr);
if (exist) { if (cex->ec_type == EXT3_EXT_CACHE_EXTENT) {
err = EXT_CONTINUE; err = EXT_CONTINUE;
goto map; goto map;
} }
if (bp->create == 0) { if (bp->create == 0) {
i = 0; i = 0;
if (newex->ee_block < bp->start) if (cex->ec_block < bp->start)
i = bp->start - newex->ee_block; i = bp->start - cex->ec_block;
if (i >= newex->ee_len) if (i >= cex->ec_len)
CERROR("nothing to do?! i = %d, e_num = %u\n", CERROR("nothing to do?! i = %d, e_num = %u\n",
i, newex->ee_len); i, cex->ec_len);
for (; i < newex->ee_len && bp->num; i++) { for (; i < cex->ec_len && bp->num; i++) {
*(bp->created) = 0; *(bp->created) = 0;
bp->created++; bp->created++;
*(bp->blocks) = 0; *(bp->blocks) = 0;
...@@ -830,78 +841,92 @@ static int ext3_ext_new_extent_cb(struct ext3_extents_tree *tree, ...@@ -830,78 +841,92 @@ static int ext3_ext_new_extent_cb(struct ext3_extents_tree *tree,
bp->num--; bp->num--;
bp->start++; bp->start++;
} }
return EXT_CONTINUE; return EXT_CONTINUE;
} }
tgen = EXT_GENERATION(tree);
count = ext3_ext_calc_credits_for_insert(tree, path); count = ext3_ext_calc_credits_for_insert(tree, path);
ext3_up_truncate_sem(inode);
lock_24kernel(); lock_24kernel();
handle = journal_start(EXT3_JOURNAL(inode), count + EXT3_ALLOC_NEEDED + 1); handle = journal_start(EXT3_JOURNAL(inode), count+EXT3_ALLOC_NEEDED+1);
unlock_24kernel(); unlock_24kernel();
if (IS_ERR(handle)) { if (IS_ERR(handle))
ext3_down_truncate_sem(inode);
return PTR_ERR(handle); return PTR_ERR(handle);
}
count = cex->ec_len;
if (tgen != EXT_GENERATION(tree)) { goal = ext3_ext_find_goal(inode, path, cex->ec_block, &aflags);
/* the tree has changed. so path can be invalid at moment */
lock_24kernel();
journal_stop(handle);
unlock_24kernel();
ext3_down_truncate_sem(inode);
return EXT_REPEAT;
}
ext3_down_truncate_sem(inode);
count = newex->ee_len;
goal = ext3_ext_find_goal(inode, path, newex->ee_block, &aflags);
aflags |= 2; /* block have been already reserved */ aflags |= 2; /* block have been already reserved */
lock_24kernel();
pblock = ext3_mb_new_blocks(handle, inode, goal, &count, aflags, &err); pblock = ext3_mb_new_blocks(handle, inode, goal, &count, aflags, &err);
unlock_24kernel();
if (!pblock) if (!pblock)
goto out; goto out;
EXT_ASSERT(count <= newex->ee_len); EXT_ASSERT(count <= cex->ec_len);
/* insert new extent */ /* insert new extent */
newex->ee_start = pblock; nex.ee_block = cex->ec_block;
newex->ee_len = count; nex.ee_start = pblock;
err = ext3_ext_insert_extent(handle, tree, path, newex); nex.ee_len = count;
err = ext3_ext_insert_extent(handle, tree, path, &nex);
if (err) if (err)
goto out; goto out;
/*
* Putting len of the actual extent we just inserted,
* we are asking ext3_ext_walk_space() to continue
* scaning after that block
*/
cex->ec_len = nex.ee_len;
cex->ec_start = nex.ee_start;
BUG_ON(nex.ee_len == 0);
BUG_ON(nex.ee_block != cex->ec_block);
/* correct on-disk inode size */ /* correct on-disk inode size */
if (newex->ee_len > 0) { if (nex.ee_len > 0) {
new_i_size = (loff_t) newex->ee_block + newex->ee_len; new_i_size = (loff_t) nex.ee_block + nex.ee_len;
new_i_size = new_i_size << inode->i_blkbits; new_i_size = new_i_size << inode->i_blkbits;
if (new_i_size > EXT3_I(inode)->i_disksize) { if (new_i_size > EXT3_I(inode)->i_disksize) {
EXT3_I(inode)->i_disksize = new_i_size; EXT3_I(inode)->i_disksize = new_i_size;
err = ext3_mark_inode_dirty(handle, inode); err = ext3_mark_inode_dirty(handle, inode);
} }
} }
out: out:
lock_24kernel(); lock_24kernel();
journal_stop(handle); journal_stop(handle);
unlock_24kernel(); unlock_24kernel();
map: map:
if (err >= 0) { if (err >= 0) {
struct block_device *bdev = inode->i_sb->s_bdev;
/* map blocks */ /* map blocks */
if (bp->num == 0) { if (bp->num == 0) {
CERROR("hmm. why do we find this extent?\n"); CERROR("hmm. why do we find this extent?\n");
CERROR("initial space: %lu:%u\n", CERROR("initial space: %lu:%u\n",
bp->start, bp->init_num); bp->start, bp->init_num);
CERROR("current extent: %u/%u/%u %d\n", CERROR("current extent: %u/%u/%u %d\n",
newex->ee_block, newex->ee_len, cex->ec_block, cex->ec_len,
newex->ee_start, exist); cex->ec_start, cex->ec_type);
} }
i = 0; i = 0;
if (newex->ee_block < bp->start) if (cex->ec_block < bp->start)
i = bp->start - newex->ee_block; i = bp->start - cex->ec_block;
if (i >= newex->ee_len) if (i >= cex->ec_len)
CERROR("nothing to do?! i = %d, e_num = %u\n", CERROR("nothing to do?! i = %d, e_num = %u\n",
i, newex->ee_len); i, cex->ec_len);
for (; i < newex->ee_len && bp->num; i++) { for (; i < cex->ec_len && bp->num; i++) {
*(bp->created) = (exist == 0 ? 1 : 0); *(bp->blocks) = cex->ec_start + i;
if (cex->ec_type == EXT3_EXT_CACHE_EXTENT) {
*(bp->created) = 0;
} else {
*(bp->created) = 1;
/* unmap any possible underlying metadata from
* the block device mapping. bug 6998.
* This only compiles on 2.6, but there are
* no users of mballoc on 2.4. */
unmap_underlying_metadata(bdev, *(bp->blocks));
}
bp->created++; bp->created++;
*(bp->blocks) = newex->ee_start + i;
bp->blocks++; bp->blocks++;
bp->num--; bp->num--;
bp->start++; bp->start++;
...@@ -909,18 +934,18 @@ map: ...@@ -909,18 +934,18 @@ map:
} }
return err; return err;
} }
int fsfilt_map_nblocks(struct inode *inode, unsigned long block, int fsfilt_map_nblocks(struct inode *inode, unsigned long block,
unsigned long num, unsigned long *blocks, unsigned long num, unsigned long *blocks,
int *created, int create) int *created, int create)
{ {
struct ext3_extents_tree tree; struct ext3_extents_tree tree;
struct bpointers bp; struct bpointers bp;
int err, i; int err;
CDEBUG(D_OTHER, "blocks %lu-%lu requested for inode %u\n", CDEBUG(D_OTHER, "blocks %lu-%lu requested for inode %u\n",
block, block + num, (unsigned) inode->i_ino); block, block + num, (unsigned) inode->i_ino);
ext3_init_tree_desc(&tree, inode); ext3_init_tree_desc(&tree, inode);
tree.private = &bp; tree.private = &bp;
bp.blocks = blocks; bp.blocks = blocks;
...@@ -928,21 +953,10 @@ int fsfilt_map_nblocks(struct inode *inode, unsigned long block, ...@@ -928,21 +953,10 @@ int fsfilt_map_nblocks(struct inode *inode, unsigned long block,
bp.start = block; bp.start = block;
bp.init_num = bp.num = num; bp.init_num = bp.num = num;
bp.create = create; bp.create = create;
ext3_down_truncate_sem(inode);
err = ext3_ext_walk_space(&tree, block, num, ext3_ext_new_extent_cb); err = ext3_ext_walk_space(&tree, block, num, ext3_ext_new_extent_cb);
ext3_ext_invalidate_cache(&tree); ext3_ext_invalidate_cache(&tree);
ext3_up_truncate_sem(inode);
/* unmap underlying pages/buffers from blockdevice mapping */
if (create) {
struct block_device *bdev = inode->i_sb->s_bdev;
for (i = 0; i < num; i++) {
if (created[i] == 0)
continue;
unmap_underlying_metadata(bdev, blocks[i]);
}
}
return err; return err;
} }
...@@ -1108,7 +1122,7 @@ static int fsfilt_ext3_write_record(struct file *file, void *buf, int bufsize, ...@@ -1108,7 +1122,7 @@ static int fsfilt_ext3_write_record(struct file *file, void *buf, int bufsize,
loff_t new_size = inode->i_size; loff_t new_size = inode->i_size;
journal_t *journal; journal_t *journal;
handle_t *handle; handle_t *handle;
int err = 0, block_count = 0, blocksize, size, boffs; int err, block_count = 0, blocksize, size, boffs;
/* Determine how many transaction credits are needed */ /* Determine how many transaction credits are needed */
blocksize = 1 << inode->i_blkbits; blocksize = 1 << inode->i_blkbits;
...@@ -1338,6 +1352,7 @@ static int fsfilt_ext3_get_op_len(int op, struct fsfilt_objinfo *fso, int logs) ...@@ -1338,6 +1352,7 @@ static int fsfilt_ext3_get_op_len(int op, struct fsfilt_objinfo *fso, int logs)
} }
#if 0
#define EXTENTS_EA "write_extents" #define EXTENTS_EA "write_extents"
#define EXTENTS_EA_SIZE 64 #define EXTENTS_EA_SIZE 64
...@@ -1398,6 +1413,7 @@ static int fsfilt_ext3_get_write_extents_num(struct inode *inode, int *size) ...@@ -1398,6 +1413,7 @@ static int fsfilt_ext3_get_write_extents_num(struct inode *inode, int *size)
EXTENTS_EA, size); EXTENTS_EA, size);
return rc; return rc;
} }
#endif
static struct fsfilt_operations fsfilt_ext3_ops = { static struct fsfilt_operations fsfilt_ext3_ops = {
.fs_type = "ext3", .fs_type = "ext3",
...@@ -1427,11 +1443,13 @@ static struct fsfilt_operations fsfilt_ext3_ops = { ...@@ -1427,11 +1443,13 @@ static struct fsfilt_operations fsfilt_ext3_ops = {
.fs_get_op_len = fsfilt_ext3_get_op_len, .fs_get_op_len = fsfilt_ext3_get_op_len,
.fs_add_dir_entry = fsfilt_ext3_add_dir_entry, .fs_add_dir_entry = fsfilt_ext3_add_dir_entry,
.fs_del_dir_entry = fsfilt_ext3_del_dir_entry, .fs_del_dir_entry = fsfilt_ext3_del_dir_entry,
#if 0
.fs_init_extents_ea = fsfilt_ext3_init_extents_ea, .fs_init_extents_ea = fsfilt_ext3_init_extents_ea,
.fs_insert_extents_ea = fsfilt_ext3_insert_extents_ea, .fs_insert_extents_ea = fsfilt_ext3_insert_extents_ea,
.fs_remove_extents_ea = fsfilt_ext3_remove_extents_ea, .fs_remove_extents_ea = fsfilt_ext3_remove_extents_ea,
.fs_get_inode_write_extents = fsfilt_ext3_get_inode_write_extents, .fs_get_inode_write_extents = fsfilt_ext3_get_inode_write_extents,
.fs_get_write_extents_num = fsfilt_ext3_get_write_extents_num, .fs_get_write_extents_num = fsfilt_ext3_get_write_extents_num,
#endif
}; };
static int __init fsfilt_ext3_init(void) static int __init fsfilt_ext3_init(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment