Whamcloud - gitweb
merge b_devel into HEAD, which will become 0.7.3
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-map_inode_page.patch
1
2
3
4  fs/ext3/ext3-exports.c |    3 ++
5  fs/ext3/inode.c        |   55 +++++++++++++++++++++++++++++++++++++++++++++++++
6  2 files changed, 58 insertions(+)
7
8 --- linux-2.4.20-l18/fs/ext3/inode.c~ext3-map_inode_page        Tue Jul  8 20:07:23 2003
9 +++ linux-2.4.20-l18-phil/fs/ext3/inode.c       Wed Jul  9 03:56:41 2003
10 @@ -2867,3 +2867,58 @@ int ext3_prep_san_write(struct inode *in
11                 ret = ret2;
12         return ret;
13  }
14 +
15 +int ext3_map_inode_page(struct inode *inode, struct page *page,
16 +                        unsigned long *blocks, int *created, int create)
17 +{
18 +        unsigned int blocksize, blocks_per_page;
19 +        unsigned long iblock;
20 +        struct buffer_head dummy;
21 +        void *handle;
22 +        int i, rc = 0, failed = 0, needed_blocks;
23 +
24 +        blocksize = inode->i_sb->s_blocksize;
25 +        blocks_per_page = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
26 +        iblock = page->index >> (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
27 +
28 +        for (i = 0; i < blocks_per_page; i++, iblock++) {
29 +                blocks[i] = ext3_bmap(inode->i_mapping, iblock);
30 +                if (blocks[i] == 0) {
31 +                        failed++;
32 +                        created[i] = -1;
33 +                } else {
34 +                        created[i] = 0;
35 +                }
36 +        }
37 +
38 +        if (failed == 0 || create == 0)
39 +                return 0;
40 +
41 +        needed_blocks = ext3_writepage_trans_blocks(inode) * failed;
42 +        lock_kernel();
43 +        handle = ext3_journal_start(inode, needed_blocks);
44 +        unlock_kernel();
45 +        if (IS_ERR(handle))
46 +                return PTR_ERR(handle);
47 +
48 +        iblock = page->index >> (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
49 +        for (i = 0; i < blocks_per_page; i++, iblock++) {
50 +                if (blocks[i] != 0)
51 +                        continue;
52 +
53 +                rc = ext3_get_block_handle(handle, inode, iblock, &dummy, 1);
54 +                if (rc) {
55 +                        printk(KERN_INFO "ext3_map_inode_page: error reading "
56 +                               "block %ld\n", iblock);
57 +                        goto out;
58 +                }
59 +                blocks[i] = dummy.b_blocknr;
60 +                created[i] = 1;
61 +        }
62 +
63 + out:
64 +       lock_kernel();
65 +       ext3_journal_stop(handle, inode);
66 +       unlock_kernel();
67 +        return rc;
68 +}
69 --- linux-2.4.20-l18/fs/ext3/ext3-exports.c~ext3-map_inode_page Tue Jul  8 20:07:10 2003
70 +++ linux-2.4.20-l18-phil/fs/ext3/ext3-exports.c        Tue Jul  8 20:09:02 2003
71 @@ -9,6 +9,8 @@
72  
73  int ext3_prep_san_write(struct inode *inode, long *blocks,
74                         int nblocks, loff_t newsize);
75 +int ext3_map_inode_page(struct inode *inode, struct page *page,
76 +                        unsigned long *block, int *created, int create);
77  
78  EXPORT_SYMBOL(ext3_force_commit);
79  EXPORT_SYMBOL(ext3_bread);
80 @@ -18,3 +20,4 @@ EXPORT_SYMBOL(ext3_xattr_get);
81  EXPORT_SYMBOL(ext3_xattr_list);
82  EXPORT_SYMBOL(ext3_xattr_set);
83  EXPORT_SYMBOL(ext3_prep_san_write);
84 +EXPORT_SYMBOL(ext3_map_inode_page);