Whamcloud - gitweb
Modified ChangeLog entry.
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-san-2.4.20.patch
1  fs/ext3/ext3-exports.c |    9 ++++-
2  fs/ext3/inode.c        |   81 +++++++++++++++++++++++++++++++++++++++++++++++++
3  2 files changed, 89 insertions(+), 1 deletion(-)
4
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.  
10   */
11 +
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
15 + * i inode block
16 + * 1 superblock
17 + * 2 * EXT3_SINGLEDATA_TRANS_BLOCKS for the quote files
18 + * ((1+1+1) * 3 * nblocks) + 1 + 1 + 2 * EXT3_SINGLEDATA_TRANS_BLOCKS
19 + *
20 + * XXX assuming:
21 + * (1) fs logic block size == page size
22 + * (2) ext3 in writeback mode
23 + */
24 +static inline int ext3_san_write_trans_blocks(int nblocks)
25 +{
26 +       int ret;
27 +       
28 +       ret = (1 + 1 + 1) * 3 * nblocks + 1 + 1;
29 +
30 +#ifdef CONFIG_QUOTA
31 +       ret += 2 * EXT3_SINGLEDATA_TRANS_BLOCKS;
32 +#endif
33 +
34 +       return ret;
35 +}
36 +
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.
39 + *
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
44 + *
45 + * return:    0 success, otherwise failed
46 + *            (*blocks) contains physical block number alloced
47 + *
48 + * XXX this assume the fs block size == page size
49 + */
50 +int ext3_prep_san_write(struct inode *inode, long *blocks,
51 +                       int nblocks, loff_t newsize)
52 +{
53 +       handle_t *handle;
54 +       struct buffer_head bh_tmp;
55 +       int needed_blocks;
56 +       int i, ret = 0, ret2;
57 +
58 +       needed_blocks = ext3_san_write_trans_blocks(nblocks);
59 +
60 +       lock_kernel();
61 +       handle = ext3_journal_start(inode, needed_blocks);
62 +       if (IS_ERR(handle)) {
63 +               unlock_kernel();
64 +               return PTR_ERR(handle);
65 +       }
66 +       unlock_kernel();
67 +
68 +       /* alloc blocks one by one */
69 +       for (i = 0; i < nblocks; i++) {
70 +               ret = ext3_get_block_handle(handle, inode, blocks[i],
71 +                                               &bh_tmp, 1);
72 +               if (ret)
73 +                       break;
74 +
75 +               blocks[i] = bh_tmp.b_blocknr;
76 +       }
77 +
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);
82 +       }
83 +
84 +       lock_kernel();
85 +       ret2 = ext3_journal_stop(handle, inode);
86 +       unlock_kernel();
87 +
88 +       if (!ret)
89 +               ret = ret2;
90 +       return ret;
91 +}
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
94 @@ -1,9 +1,15 @@
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>
104  
105 +int ext3_prep_san_write(struct inode *inode, long *blocks,
106 +                       int nblocks, loff_t newsize);
107 +
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);
116
117 _