fs/ext3/inode.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- fs/ext3/super.c | 5 ++- fs/ext3/xattr.c | 5 +++ fs/ext3/xattr.h | 2 - 4 files changed, 92 insertions(+), 4 deletions(-) --- linux-2.5.63-nointent/fs/ext3/xattr.c~ext3-2.5.63 Fri Mar 21 18:47:19 2003 +++ linux-2.5.63-nointent-root/fs/ext3/xattr.c Fri Mar 21 18:47:19 2003 @@ -1181,3 +1181,8 @@ exit_ext3_xattr(void) ext3_xattr_unregister(EXT3_XATTR_INDEX_USER, &ext3_xattr_user_handler); } + +EXPORT_SYMBOL(ext3_xattr_get); +EXPORT_SYMBOL(ext3_xattr_set); +EXPORT_SYMBOL(ext3_xattr_set_handle); + --- linux-2.5.63-nointent/fs/ext3/inode.c~ext3-2.5.63 Fri Mar 21 18:47:19 2003 +++ linux-2.5.63-nointent-root/fs/ext3/inode.c Fri Mar 21 18:47:19 2003 @@ -1019,7 +1019,7 @@ struct buffer_head *ext3_bread(handle_t *err = -EIO; return NULL; } - +EXPORT_SYMBOL(ext3_bread); static int walk_page_buffers( handle_t *handle, struct buffer_head *head, unsigned from, @@ -2870,3 +2870,85 @@ int ext3_change_inode_journal_flag(struc * here, in ext3_aops_journal_start() to ensure that the forthcoming "see if we * need to extend" test in ext3_prepare_write() succeeds. */ + +/* for each block: 1 ind + 1 dind + 1 tind + * for each block: 3 bitmap blocks + * for each block: 3 group descriptor blocks + * i inode block + * 1 superblock + * 2 * EXT3_SINGLEDATA_TRANS_BLOCKS for the quote files + * ((1+1+1) * 3 * nblocks) + 1 + 1 + 2 * EXT3_SINGLEDATA_TRANS_BLOCKS + * + * XXX assuming: + * (1) fs logic block size == page size + * (2) ext3 in writeback mode + */ +static inline int ext3_san_write_trans_blocks(int nblocks) +{ + int ret; + + ret = (1 + 1 + 1) * 3 * nblocks + 1 + 1; + +#ifdef CONFIG_QUOTA + ret += 2 * EXT3_SINGLEDATA_TRANS_BLOCKS; +#endif + + return ret; +} + +/* Alloc blocks for an inode, while don't create any buffer/page + * for data I/O; set the inode size if file is extended. + * + * @inode: target inode + * @blocks: array of logic block number + * @nblocks: how many blocks need be alloced + * @newsize: new filesize we should set + * + * return: 0 success, otherwise failed + * (*blocks) contains physical block number alloced + * + * XXX this assume the fs block size == page size + */ +int ext3_prep_san_write(struct inode *inode, long *blocks, + int nblocks, loff_t newsize) +{ + handle_t *handle; + struct buffer_head bh_tmp; + int needed_blocks; + int i, ret = 0, ret2; + + needed_blocks = ext3_san_write_trans_blocks(nblocks); + + lock_kernel(); + handle = ext3_journal_start(inode, needed_blocks); + if (IS_ERR(handle)) { + unlock_kernel(); + return PTR_ERR(handle); + } + unlock_kernel(); + + /* alloc blocks one by one */ + for (i = 0; i < nblocks; i++) { + ret = ext3_get_block_handle(handle, inode, blocks[i], + &bh_tmp, 1, 1); + if (ret) + break; + + blocks[i] = bh_tmp.b_blocknr; + } + + /* set inode size if needed */ + if (!ret && (newsize > inode->i_size)) { + inode->i_size = newsize; + ext3_mark_inode_dirty(handle, inode); + } + + lock_kernel(); + ret2 = ext3_journal_stop(handle, inode); + unlock_kernel(); + + if (!ret) + ret = ret2; + return ret; +} +EXPORT_SYMBOL(ext3_prep_san_write); --- linux-2.5.63-nointent/fs/ext3/super.c~ext3-2.5.63 Fri Mar 21 18:47:19 2003 +++ linux-2.5.63-nointent-root/fs/ext3/super.c Fri Mar 21 18:47:19 2003 @@ -1492,10 +1492,10 @@ static journal_t *ext3_get_dev_journal(s printk(KERN_ERR "EXT3-fs: I/O error on journal device\n"); goto out_journal; } - if (ntohl(journal->j_superblock->s_nr_users) != 1) { + if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) { printk(KERN_ERR "EXT3-fs: External journal has more than one " "user (unsupported) - %d\n", - ntohl(journal->j_superblock->s_nr_users)); + be32_to_cpu(journal->j_superblock->s_nr_users)); goto out_journal; } EXT3_SB(sb)->journal_bdev = bdev; @@ -1703,6 +1703,7 @@ int ext3_force_commit(struct super_block unlock_kernel(); return ret; } +EXPORT_SYMBOL(ext3_force_commit); /* * Ext3 always journals updates to the superblock itself, so we don't --- linux-2.5.63-nointent/fs/ext3/xattr.h~ext3-2.5.63 Fri Mar 21 18:47:19 2003 +++ linux-2.5.63-nointent-root/fs/ext3/xattr.h Fri Mar 21 18:47:19 2003 @@ -5,7 +5,7 @@ (C) 2001 Andreas Gruenbacher, */ - +#include #include #include _