diff options
Diffstat (limited to 'fs/gfs2/bmap.c')
-rw-r--r-- | fs/gfs2/bmap.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 84da64b551b..6f482809d1a 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -1040,7 +1040,7 @@ static int trunc_start(struct gfs2_inode *ip, u64 size) | |||
1040 | goto out; | 1040 | goto out; |
1041 | 1041 | ||
1042 | if (gfs2_is_stuffed(ip)) { | 1042 | if (gfs2_is_stuffed(ip)) { |
1043 | u64 dsize = size + sizeof(struct gfs2_inode); | 1043 | u64 dsize = size + sizeof(struct gfs2_dinode); |
1044 | ip->i_disksize = size; | 1044 | ip->i_disksize = size; |
1045 | ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; | 1045 | ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; |
1046 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | 1046 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); |
@@ -1244,13 +1244,12 @@ int gfs2_file_dealloc(struct gfs2_inode *ip) | |||
1244 | * @ip: the file being written to | 1244 | * @ip: the file being written to |
1245 | * @offset: the offset to write to | 1245 | * @offset: the offset to write to |
1246 | * @len: the number of bytes being written | 1246 | * @len: the number of bytes being written |
1247 | * @alloc_required: set to 1 if an alloc is required, 0 otherwise | ||
1248 | * | 1247 | * |
1249 | * Returns: errno | 1248 | * Returns: 1 if an alloc is required, 0 otherwise |
1250 | */ | 1249 | */ |
1251 | 1250 | ||
1252 | int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, | 1251 | int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, |
1253 | unsigned int len, int *alloc_required) | 1252 | unsigned int len) |
1254 | { | 1253 | { |
1255 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1254 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
1256 | struct buffer_head bh; | 1255 | struct buffer_head bh; |
@@ -1258,26 +1257,23 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, | |||
1258 | u64 lblock, lblock_stop, size; | 1257 | u64 lblock, lblock_stop, size; |
1259 | u64 end_of_file; | 1258 | u64 end_of_file; |
1260 | 1259 | ||
1261 | *alloc_required = 0; | ||
1262 | |||
1263 | if (!len) | 1260 | if (!len) |
1264 | return 0; | 1261 | return 0; |
1265 | 1262 | ||
1266 | if (gfs2_is_stuffed(ip)) { | 1263 | if (gfs2_is_stuffed(ip)) { |
1267 | if (offset + len > | 1264 | if (offset + len > |
1268 | sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) | 1265 | sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) |
1269 | *alloc_required = 1; | 1266 | return 1; |
1270 | return 0; | 1267 | return 0; |
1271 | } | 1268 | } |
1272 | 1269 | ||
1273 | *alloc_required = 1; | ||
1274 | shift = sdp->sd_sb.sb_bsize_shift; | 1270 | shift = sdp->sd_sb.sb_bsize_shift; |
1275 | BUG_ON(gfs2_is_dir(ip)); | 1271 | BUG_ON(gfs2_is_dir(ip)); |
1276 | end_of_file = (ip->i_disksize + sdp->sd_sb.sb_bsize - 1) >> shift; | 1272 | end_of_file = (ip->i_disksize + sdp->sd_sb.sb_bsize - 1) >> shift; |
1277 | lblock = offset >> shift; | 1273 | lblock = offset >> shift; |
1278 | lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift; | 1274 | lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift; |
1279 | if (lblock_stop > end_of_file) | 1275 | if (lblock_stop > end_of_file) |
1280 | return 0; | 1276 | return 1; |
1281 | 1277 | ||
1282 | size = (lblock_stop - lblock) << shift; | 1278 | size = (lblock_stop - lblock) << shift; |
1283 | do { | 1279 | do { |
@@ -1285,12 +1281,11 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, | |||
1285 | bh.b_size = size; | 1281 | bh.b_size = size; |
1286 | gfs2_block_map(&ip->i_inode, lblock, &bh, 0); | 1282 | gfs2_block_map(&ip->i_inode, lblock, &bh, 0); |
1287 | if (!buffer_mapped(&bh)) | 1283 | if (!buffer_mapped(&bh)) |
1288 | return 0; | 1284 | return 1; |
1289 | size -= bh.b_size; | 1285 | size -= bh.b_size; |
1290 | lblock += (bh.b_size >> ip->i_inode.i_blkbits); | 1286 | lblock += (bh.b_size >> ip->i_inode.i_blkbits); |
1291 | } while(size > 0); | 1287 | } while(size > 0); |
1292 | 1288 | ||
1293 | *alloc_required = 0; | ||
1294 | return 0; | 1289 | return 0; |
1295 | } | 1290 | } |
1296 | 1291 | ||