Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-map_inode_page.patch
index 80f14de..675dc95 100644 (file)
@@ -5,25 +5,40 @@
  fs/ext3/inode.c        |   55 +++++++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 58 insertions(+)
 
---- linux-2.4.20-l18/fs/ext3/inode.c~ext3-map_inode_page       Tue Jul  8 20:07:23 2003
-+++ linux-2.4.20-l18-phil/fs/ext3/inode.c      Wed Jul  9 03:56:41 2003
-@@ -2867,3 +2867,58 @@ int ext3_prep_san_write(struct inode *in
+Index: lum/fs/ext3/inode.c
+===================================================================
+--- lum.orig/fs/ext3/inode.c   Sat Nov 22 16:38:51 2003
++++ lum/fs/ext3/inode.c        Fri Nov 28 00:37:18 2003
+@@ -2979,3 +2979,75 @@
                ret = ret2;
        return ret;
  }
 +
++/* copied from fs/buffer.c */
++static void unmap_underlying_metadata(struct buffer_head * bh)
++{
++      struct buffer_head *old_bh;
++
++      old_bh = get_hash_table(bh->b_dev, bh->b_blocknr, bh->b_size);
++      if (old_bh) {
++              mark_buffer_clean(old_bh);
++              wait_on_buffer(old_bh);
++              clear_bit(BH_Req, &old_bh->b_state);
++              __brelse(old_bh);
++      }
++}
++
 +int ext3_map_inode_page(struct inode *inode, struct page *page,
 +                        unsigned long *blocks, int *created, int create)
 +{
 +        unsigned int blocksize, blocks_per_page;
 +        unsigned long iblock;
-+        struct buffer_head dummy;
 +        void *handle;
 +        int i, rc = 0, failed = 0, needed_blocks;
 +
 +        blocksize = inode->i_sb->s_blocksize;
 +        blocks_per_page = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
-+        iblock = page->index >> (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
++        iblock = page->index * blocks_per_page;
 +
 +        for (i = 0; i < blocks_per_page; i++, iblock++) {
 +                blocks[i] = ext3_bmap(inode->i_mapping, iblock);
 +        if (failed == 0 || create == 0)
 +                return 0;
 +
-+        needed_blocks = ext3_writepage_trans_blocks(inode) * failed;
++        needed_blocks = ext3_writepage_trans_blocks(inode);
 +        lock_kernel();
 +        handle = ext3_journal_start(inode, needed_blocks);
 +        unlock_kernel();
 +        if (IS_ERR(handle))
 +                return PTR_ERR(handle);
 +
-+        iblock = page->index >> (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
++        iblock = page->index * blocks_per_page;
 +        for (i = 0; i < blocks_per_page; i++, iblock++) {
++                struct buffer_head bh;
++
 +                if (blocks[i] != 0)
 +                        continue;
 +
-+                rc = ext3_get_block_handle(handle, inode, iblock, &dummy, 1);
++                rc = ext3_get_block_handle(handle, inode, iblock, &bh, 1);
 +                if (rc) {
-+                        printk(KERN_INFO "ext3_map_inode_page: error reading "
-+                               "block %ld\n", iblock);
++                        printk(KERN_INFO "ext3_map_inode_page: error %d "
++                               "allocating block %ld\n", rc, iblock);
 +                        goto out;
 +                }
-+                blocks[i] = dummy.b_blocknr;
++                if (buffer_new(&bh))
++                        unmap_underlying_metadata(&bh);
++                blocks[i] = bh.b_blocknr;
 +                created[i] = 1;
 +        }
 +
 +      unlock_kernel();
 +        return rc;
 +}
---- linux-2.4.20-l18/fs/ext3/ext3-exports.c~ext3-map_inode_page        Tue Jul  8 20:07:10 2003
-+++ linux-2.4.20-l18-phil/fs/ext3/ext3-exports.c       Tue Jul  8 20:09:02 2003
+Index: lum/fs/ext3/ext3-exports.c
+===================================================================
+--- lum.orig/fs/ext3/ext3-exports.c    Sat Nov 22 16:38:51 2003
++++ lum/fs/ext3/ext3-exports.c Sat Nov 22 16:38:51 2003
 @@ -9,6 +9,8 @@
  
  int ext3_prep_san_write(struct inode *inode, long *blocks,
@@ -77,7 +98,7 @@
  
  EXPORT_SYMBOL(ext3_force_commit);
  EXPORT_SYMBOL(ext3_bread);
-@@ -18,3 +20,4 @@ EXPORT_SYMBOL(ext3_xattr_get);
+@@ -18,3 +20,4 @@
  EXPORT_SYMBOL(ext3_xattr_list);
  EXPORT_SYMBOL(ext3_xattr_set);
  EXPORT_SYMBOL(ext3_prep_san_write);