1 fs/ext3/ext3-exports.c | 9 ++++-
2 fs/ext3/inode.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++
3 2 files changed, 89 insertions(+), 1 deletion(-)
5 --- linux/fs/ext3/inode.c~ext3-san-2.4.20-hp Tue Apr 29 11:01:52 2003
6 +++ linux-mmonroe/fs/ext3/inode.c Tue Apr 29 11:01:53 2003
7 @@ -2734,3 +2734,84 @@ int ext3_change_inode_journal_flag(struc
8 * here, in ext3_aops_journal_start() to ensure that the forthcoming "see if we
9 * need to extend" test in ext3_prepare_write() succeeds.
12 +/* for each block: 1 ind + 1 dind + 1 tind
13 + * for each block: 3 bitmap blocks
14 + * for each block: 3 group descriptor blocks
17 + * 2 * EXT3_SINGLEDATA_TRANS_BLOCKS for the quote files
18 + * ((1+1+1) * 3 * nblocks) + 1 + 1 + 2 * EXT3_SINGLEDATA_TRANS_BLOCKS
21 + * (1) fs logic block size == page size
22 + * (2) ext3 in writeback mode
24 +static inline int ext3_san_write_trans_blocks(int nblocks)
28 + ret = (1 + 1 + 1) * 3 * nblocks + 1 + 1;
31 + ret += 2 * EXT3_SINGLEDATA_TRANS_BLOCKS;
37 +/* Alloc blocks for an inode, while don't create any buffer/page
38 + * for data I/O; set the inode size if file is extended.
40 + * @inode: target inode
41 + * @blocks: array of logic block number
42 + * @nblocks: how many blocks need be alloced
43 + * @newsize: new filesize we should set
45 + * return: 0 success, otherwise failed
46 + * (*blocks) contains physical block number alloced
48 + * XXX this assume the fs block size == page size
50 +int ext3_prep_san_write(struct inode *inode, long *blocks,
51 + int nblocks, loff_t newsize)
54 + struct buffer_head bh_tmp;
56 + int i, ret = 0, ret2;
58 + needed_blocks = ext3_san_write_trans_blocks(nblocks);
61 + handle = ext3_journal_start(inode, needed_blocks);
62 + if (IS_ERR(handle)) {
64 + return PTR_ERR(handle);
68 + /* alloc blocks one by one */
69 + for (i = 0; i < nblocks; i++) {
70 + ret = ext3_get_block_handle(handle, inode, blocks[i],
75 + blocks[i] = bh_tmp.b_blocknr;
78 + /* set inode size if needed */
79 + if (!ret && (newsize > inode->i_size)) {
80 + inode->i_size = newsize;
81 + ext3_mark_inode_dirty(handle, inode);
85 + ret2 = ext3_journal_stop(handle, inode);
92 --- linux/fs/ext3/ext3-exports.c~ext3-san-2.4.20-hp Tue Apr 29 11:01:51 2003
93 +++ linux-mmonroe/fs/ext3/ext3-exports.c Tue Apr 29 11:07:19 2003
95 #include <linux/config.h>
96 #include <linux/module.h>
97 -#include <linux/ext3_fs.h>
98 +#include <linux/fs.h>
99 +#include <linux/locks.h>
100 +#include <linux/slab.h>
101 #include <linux/ext3_jbd.h>
102 +#include <linux/ext3_fs.h>
103 #include <linux/ext3_xattr.h>
105 +int ext3_prep_san_write(struct inode *inode, long *blocks,
106 + int nblocks, loff_t newsize);
108 EXPORT_SYMBOL(ext3_force_commit);
109 EXPORT_SYMBOL(ext3_bread);
110 EXPORT_SYMBOL(ext3_xattr_register);
111 @@ -11,3 +17,4 @@ EXPORT_SYMBOL(ext3_xattr_unregister);
112 EXPORT_SYMBOL(ext3_xattr_get);
113 EXPORT_SYMBOL(ext3_xattr_list);
114 EXPORT_SYMBOL(ext3_xattr_set);
115 +EXPORT_SYMBOL(ext3_prep_san_write);