1 fs/ext3/inode.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 2 files changed, 85 insertions(+)
5 --- linux-2.5.73/fs/ext3/inode.c~ext3-san-jdike-2.5.73 2003-06-22 12:32:58.000000000 -0600
6 +++ linux-2.5.73-braam/fs/ext3/inode.c 2003-06-30 12:19:21.000000000 -0600
7 @@ -2945,3 +2945,84 @@ int ext3_change_inode_journal_flag(struc
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);
92 --- linux-2.5.73/fs/ext3/super.c~ext3-san-jdike-2.5.73 2003-06-22 12:33:16.000000000 -0600
93 +++ linux-2.5.73-braam/fs/ext3/super.c 2003-06-30 12:16:36.000000000 -0600
94 @@ -2080,6 +2080,10 @@ static void __exit exit_ext3_fs(void)
98 +int ext3_prep_san_write(struct inode *inode, long *blocks,
99 + int nblocks, loff_t newsize);
100 +EXPORT_SYMBOL(ext3_prep_san_write);
102 MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
103 MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
104 MODULE_LICENSE("GPL");