Whamcloud - gitweb
- highmem-split-2.6.10-fc3.patch in order to make 3GB memory on mountain's
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-san-jdike-2.6-suse.patch
1  fs/ext3/inode.c |   81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  fs/ext3/super.c |    4 ++
3  2 files changed, 85 insertions(+)
4
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
8  
9         return err;
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, 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);
86 +       unlock_kernel();
87 +
88 +       if (!ret)
89 +               ret = ret2;
90 +       return ret;
91 +}
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)
95         exit_ext3_xattr();
96  }
97  
98 +int ext3_prep_san_write(struct inode *inode, long *blocks,
99 +                        int nblocks, loff_t newsize);
100 +EXPORT_SYMBOL(ext3_prep_san_write);
101 +
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");
105
106 _