Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext3-map_inode_page-2.6-suse.patch
1  fs/ext3/inode.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2  fs/ext3/super.c |    3 +++
3  2 files changed, 55 insertions(+)
4
5 Index: linux-2.6.0/fs/ext3/inode.c
6 ===================================================================
7 --- linux-2.6.0.orig/fs/ext3/inode.c    2003-12-31 00:33:49.000000000 +0300
8 +++ linux-2.6.0/fs/ext3/inode.c 2003-12-31 01:14:17.000000000 +0300
9 @@ -3136,3 +3136,62 @@
10                 ret = ret2;
11         return ret;
12  }
13 +
14 +int ext3_map_inode_page(struct inode *inode, struct page *page,
15 +                        unsigned long *blocks, int *created, int create)
16 +{
17 +        unsigned int blocksize, blocks_per_page;
18 +        unsigned long iblock;
19 +        struct buffer_head dummy;
20 +        void *handle;
21 +        int i, rc = 0, failed = 0, needed_blocks;
22 +
23 +        blocksize = inode->i_sb->s_blocksize;
24 +        blocks_per_page = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
25 +        iblock = page->index * blocks_per_page;
26 +
27 +        for (i = 0; i < blocks_per_page; i++, iblock++) {
28 +                blocks[i] = ext3_bmap(inode->i_mapping, iblock);
29 +                if (blocks[i] == 0) {
30 +                        failed++;
31 +                       if (created)
32 +                               created[i] = -1;
33 +               } else if (created) {
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);
42 +        handle = ext3_journal_start(inode, needed_blocks);
43 +        if (IS_ERR(handle))
44 +                return PTR_ERR(handle);
45 +
46 +        iblock = page->index * blocks_per_page;
47 +        for (i = 0; i < blocks_per_page; i++, iblock++) {
48 +                if (blocks[i] != 0)
49 +                        continue;
50 +
51 +                rc = ext3_get_block_handle(handle, inode, iblock, &dummy, 1, 1);
52 +                if (rc) {
53 +                        printk(KERN_INFO "ext3_map_inode_page: error reading "
54 +                               "block %ld\n", iblock);
55 +                        goto out;
56 +                }
57 +               /* Unmap any metadata buffers from the block mapping, to avoid
58 +                * data corruption due to direct-write from Lustre being
59 +                * clobbered by a later flush of the blockdev metadata buffer.*/
60 +                if (buffer_new(&dummy))
61 +                        unmap_underlying_metadata(dummy.b_bdev,
62 +                                                      dummy.b_blocknr);
63 +                blocks[i] = dummy.b_blocknr;
64 +               if (created)
65 +                       created[i] = 1;
66 +        }
67 +
68 + out:
69 +       ext3_journal_stop(handle);
70 +        return rc;
71 +}
72 Index: linux-2.6.0/fs/ext3/super.c
73 ===================================================================
74 --- linux-2.6.0.orig/fs/ext3/super.c    2003-12-31 00:33:49.000000000 +0300
75 +++ linux-2.6.0/fs/ext3/super.c 2003-12-31 01:10:40.000000000 +0300
76 @@ -2051,6 +2051,10 @@
77                          int nblocks, loff_t newsize);
78  EXPORT_SYMBOL(ext3_prep_san_write);
79  
80 +int ext3_map_inode_page(struct inode *inode, struct page *page,
81 +                        unsigned long *blocks, int *created, int create);
82 +EXPORT_SYMBOL(ext3_map_inode_page);
83 +
84  MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
85  MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
86  MODULE_LICENSE("GPL");