]> err.no Git - linux-2.6/blobdiff - fs/gfs2/bmap.c
ext[234]: use ext[234]_get_group_desc()
[linux-2.6] / fs / gfs2 / bmap.c
index 49486029edc2d67c0bdef4b886cf642e3ccfcd28..e9456ebd3bb619c0dc269331ec793d54e3eee319 100644 (file)
@@ -469,6 +469,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
        unsigned int maxlen = bh_map->b_size >> inode->i_blkbits;
        struct metapath mp;
        u64 size;
+       struct buffer_head *dibh = NULL;
 
        BUG_ON(maxlen == 0);
 
@@ -499,6 +500,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
        error = gfs2_meta_inode_buffer(ip, &bh);
        if (error)
                goto out_fail;
+       dibh = bh;
+       get_bh(dibh);
 
        for (x = 0; x < end_of_metadata; x++) {
                lookup_block(ip, bh, x, &mp, create, &new, &dblock);
@@ -517,13 +520,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
                if (boundary)
                        set_buffer_boundary(bh_map);
                if (new) {
-                       struct buffer_head *dibh;
-                       error = gfs2_meta_inode_buffer(ip, &dibh);
-                       if (!error) {
-                               gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-                               gfs2_dinode_out(ip, dibh->b_data);
-                               brelse(dibh);
-                       }
+                       gfs2_trans_add_bh(ip->i_gl, dibh, 1);
+                       gfs2_dinode_out(ip, dibh->b_data);
                        set_buffer_new(bh_map);
                        goto out_brelse;
                }
@@ -544,6 +542,8 @@ out_brelse:
 out_ok:
        error = 0;
 out_fail:
+       if (dibh)
+               brelse(dibh);
        bmap_unlock(inode, create);
        return error;
 }
@@ -683,7 +683,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
        if (metadata)
                revokes = (height) ? sdp->sd_inptrs : sdp->sd_diptrs;
 
-       error = gfs2_rindex_hold(sdp, &ip->i_alloc.al_ri_gh);
+       error = gfs2_rindex_hold(sdp, &ip->i_alloc->al_ri_gh);
        if (error)
                return error;
 
@@ -785,7 +785,7 @@ out_rg_gunlock:
 out_rlist:
        gfs2_rlist_free(&rlist);
 out:
-       gfs2_glock_dq_uninit(&ip->i_alloc.al_ri_gh);
+       gfs2_glock_dq_uninit(&ip->i_alloc->al_ri_gh);
        return error;
 }
 
@@ -932,7 +932,7 @@ static int gfs2_block_truncate_page(struct address_space *mapping)
        if (!gfs2_is_writeback(ip))
                gfs2_trans_add_bh(ip->i_gl, bh, 0);
 
-       zero_user_page(page, offset, length, KM_USER0);
+       zero_user(page, offset, length);
 
 unlock:
        unlock_page(page);
@@ -1222,8 +1222,13 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
                do_div(lblock_stop, bsize);
        } else {
                unsigned int shift = sdp->sd_sb.sb_bsize_shift;
+               u64 end_of_file = (ip->i_di.di_size + sdp->sd_sb.sb_bsize - 1) >> shift;
                lblock = offset >> shift;
                lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift;
+               if (lblock_stop > end_of_file) {
+                       *alloc_required = 1;
+                       return 0;
+               }
        }
 
        for (; lblock < lblock_stop; lblock += extlen) {