Whamcloud - gitweb
- landing of b_fid after merge with b_hd_cleanup_merge.
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-map_inode_page-2.4.24.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 Index: lum/fs/ext3/inode.c
9 ===================================================================
10 --- lum.orig/fs/ext3/inode.c    Sat Nov 22 16:38:51 2003
11 +++ lum/fs/ext3/inode.c Fri Nov 28 00:37:18 2003
12 @@ -2979,3 +2979,75 @@
13                 ret = ret2;
14         return ret;
15  }
16 +
17 +/* copied from fs/buffer.c */
18 +static void unmap_underlying_metadata(struct buffer_head * bh)
19 +{
20 +       struct buffer_head *old_bh;
21 +
22 +       old_bh = get_hash_table(bh->b_dev, bh->b_blocknr, bh->b_size);
23 +       if (old_bh) {
24 +               mark_buffer_clean(old_bh);
25 +               wait_on_buffer(old_bh);
26 +               clear_bit(BH_Req, &old_bh->b_state);
27 +               __brelse(old_bh);
28 +       }
29 +}
30 +
31 +int ext3_map_inode_page(struct inode *inode, struct page *page,
32 +                        unsigned long *blocks, int *created, int create)
33 +{
34 +        unsigned int blocksize, blocks_per_page;
35 +        unsigned long iblock;
36 +        void *handle;
37 +        int i, rc = 0, failed = 0, needed_blocks;
38 +
39 +        blocksize = inode->i_sb->s_blocksize;
40 +        blocks_per_page = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
41 +        iblock = page->index * blocks_per_page;
42 +
43 +        for (i = 0; i < blocks_per_page; i++, iblock++) {
44 +                blocks[i] = ext3_bmap(inode->i_mapping, iblock);
45 +                if (blocks[i] == 0) {
46 +                        failed++;
47 +                        created[i] = -1;
48 +                } else {
49 +                        created[i] = 0;
50 +                }
51 +        }
52 +
53 +        if (failed == 0 || create == 0)
54 +                return 0;
55 +
56 +        needed_blocks = ext3_writepage_trans_blocks(inode);
57 +        lock_kernel();
58 +        handle = ext3_journal_start(inode, needed_blocks);
59 +        unlock_kernel();
60 +        if (IS_ERR(handle))
61 +                return PTR_ERR(handle);
62 +
63 +        iblock = page->index * blocks_per_page;
64 +        for (i = 0; i < blocks_per_page; i++, iblock++) {
65 +                struct buffer_head bh;
66 +
67 +                if (blocks[i] != 0)
68 +                        continue;
69 +
70 +                rc = ext3_get_block_handle(handle, inode, iblock, &bh, 1);
71 +                if (rc) {
72 +                        printk(KERN_INFO "ext3_map_inode_page: error %d "
73 +                               "allocating block %ld\n", rc, iblock);
74 +                        goto out;
75 +                }
76 +                if (buffer_new(&bh))
77 +                        unmap_underlying_metadata(&bh);
78 +                blocks[i] = bh.b_blocknr;
79 +                created[i] = 1;
80 +        }
81 +
82 + out:
83 +       lock_kernel();
84 +       ext3_journal_stop(handle, inode);
85 +       unlock_kernel();
86 +        return rc;
87 +}
88 Index: lum/fs/ext3/ext3-exports.c
89 ===================================================================
90 --- lum.orig/fs/ext3/ext3-exports.c     Sat Nov 22 16:38:51 2003
91 +++ lum/fs/ext3/ext3-exports.c  Sat Nov 22 16:38:51 2003
92 @@ -9,6 +9,8 @@
93  
94  int ext3_prep_san_write(struct inode *inode, long *blocks,
95                         int nblocks, loff_t newsize);
96 +int ext3_map_inode_page(struct inode *inode, struct page *page,
97 +                        unsigned long *block, int *created, int create);
98  
99  EXPORT_SYMBOL(ext3_force_commit);
100  EXPORT_SYMBOL(ext3_bread);
101 @@ -18,3 +20,4 @@
102  EXPORT_SYMBOL(ext3_xattr_list);
103  EXPORT_SYMBOL(ext3_xattr_set);
104  EXPORT_SYMBOL(ext3_prep_san_write);
105 +EXPORT_SYMBOL(ext3_map_inode_page);