aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2010-06-24 19:21:20 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2010-07-29 04:36:56 -0400
commit461cb419f074aab16836a660efb8e855b6c1609c (patch)
tree0b4ca5ab5c01efc37505a43ad96dbc94ae2bb95b /fs/gfs2
parentba6e93645f039bd357e04b7b9d18f4e67757725e (diff)
GFS2: Simplify gfs2_write_alloc_required
Function gfs2_write_alloc_required always returned zero as its return code. Therefore, it doesn't need to return a return code at all. Given that, we can use the return value to return whether or not the dinode needs block allocations rather than passing that value in, which in turn simplifies a bunch of error checking. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/aops.c4
-rw-r--r--fs/gfs2/bmap.c15
-rw-r--r--fs/gfs2/bmap.h2
-rw-r--r--fs/gfs2/file.c4
-rw-r--r--fs/gfs2/quota.c15
-rw-r--r--fs/gfs2/super.c9
6 files changed, 14 insertions, 35 deletions
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 9485a882d80b..5e96cbd8a454 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -634,9 +634,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
634 } 634 }
635 } 635 }
636 636
637 error = gfs2_write_alloc_required(ip, pos, len, &alloc_required); 637 alloc_required = gfs2_write_alloc_required(ip, pos, len);
638 if (error)
639 goto out_unlock;
640 638
641 if (alloc_required || gfs2_is_jdata(ip)) 639 if (alloc_required || gfs2_is_jdata(ip))
642 gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks); 640 gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 84da64b551b2..744c29e2dcf4 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -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
1252int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, 1251int 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
diff --git a/fs/gfs2/bmap.h b/fs/gfs2/bmap.h
index c983177e05ac..a20a5213135a 100644
--- a/fs/gfs2/bmap.h
+++ b/fs/gfs2/bmap.h
@@ -52,6 +52,6 @@ int gfs2_truncatei(struct gfs2_inode *ip, u64 size);
52int gfs2_truncatei_resume(struct gfs2_inode *ip); 52int gfs2_truncatei_resume(struct gfs2_inode *ip);
53int gfs2_file_dealloc(struct gfs2_inode *ip); 53int gfs2_file_dealloc(struct gfs2_inode *ip);
54int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, 54int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
55 unsigned int len, int *alloc_required); 55 unsigned int len);
56 56
57#endif /* __BMAP_DOT_H__ */ 57#endif /* __BMAP_DOT_H__ */
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index ed9a94f0ef15..4edd662c8232 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -351,7 +351,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
351 unsigned long last_index; 351 unsigned long last_index;
352 u64 pos = page->index << PAGE_CACHE_SHIFT; 352 u64 pos = page->index << PAGE_CACHE_SHIFT;
353 unsigned int data_blocks, ind_blocks, rblocks; 353 unsigned int data_blocks, ind_blocks, rblocks;
354 int alloc_required = 0;
355 struct gfs2_holder gh; 354 struct gfs2_holder gh;
356 struct gfs2_alloc *al; 355 struct gfs2_alloc *al;
357 int ret; 356 int ret;
@@ -364,8 +363,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
364 set_bit(GLF_DIRTY, &ip->i_gl->gl_flags); 363 set_bit(GLF_DIRTY, &ip->i_gl->gl_flags);
365 set_bit(GIF_SW_PAGED, &ip->i_flags); 364 set_bit(GIF_SW_PAGED, &ip->i_flags);
366 365
367 ret = gfs2_write_alloc_required(ip, pos, PAGE_CACHE_SIZE, &alloc_required); 366 if (!gfs2_write_alloc_required(ip, pos, PAGE_CACHE_SIZE))
368 if (ret || !alloc_required)
369 goto out_unlock; 367 goto out_unlock;
370 ret = -ENOMEM; 368 ret = -ENOMEM;
371 al = gfs2_alloc_get(ip); 369 al = gfs2_alloc_get(ip);
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 8f02d3db8f42..8bb643cb2658 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -787,15 +787,9 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
787 goto out; 787 goto out;
788 788
789 for (x = 0; x < num_qd; x++) { 789 for (x = 0; x < num_qd; x++) {
790 int alloc_required;
791
792 offset = qd2offset(qda[x]); 790 offset = qd2offset(qda[x]);
793 error = gfs2_write_alloc_required(ip, offset, 791 if (gfs2_write_alloc_required(ip, offset,
794 sizeof(struct gfs2_quota), 792 sizeof(struct gfs2_quota)))
795 &alloc_required);
796 if (error)
797 goto out_gunlock;
798 if (alloc_required)
799 nalloc++; 793 nalloc++;
800 } 794 }
801 795
@@ -1584,10 +1578,7 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
1584 goto out_i; 1578 goto out_i;
1585 1579
1586 offset = qd2offset(qd); 1580 offset = qd2offset(qd);
1587 error = gfs2_write_alloc_required(ip, offset, sizeof(struct gfs2_quota), 1581 alloc_required = gfs2_write_alloc_required(ip, offset, sizeof(struct gfs2_quota));
1588 &alloc_required);
1589 if (error)
1590 goto out_i;
1591 if (alloc_required) { 1582 if (alloc_required) {
1592 al = gfs2_alloc_get(ip); 1583 al = gfs2_alloc_get(ip);
1593 if (al == NULL) 1584 if (al == NULL)
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 4d1aad38f1b1..4140811a921c 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -342,8 +342,6 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
342{ 342{
343 struct gfs2_inode *ip = GFS2_I(jd->jd_inode); 343 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
344 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 344 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
345 int ar;
346 int error;
347 345
348 if (ip->i_disksize < (8 << 20) || ip->i_disksize > (1 << 30) || 346 if (ip->i_disksize < (8 << 20) || ip->i_disksize > (1 << 30) ||
349 (ip->i_disksize & (sdp->sd_sb.sb_bsize - 1))) { 347 (ip->i_disksize & (sdp->sd_sb.sb_bsize - 1))) {
@@ -352,13 +350,12 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
352 } 350 }
353 jd->jd_blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift; 351 jd->jd_blocks = ip->i_disksize >> sdp->sd_sb.sb_bsize_shift;
354 352
355 error = gfs2_write_alloc_required(ip, 0, ip->i_disksize, &ar); 353 if (gfs2_write_alloc_required(ip, 0, ip->i_disksize)) {
356 if (!error && ar) {
357 gfs2_consist_inode(ip); 354 gfs2_consist_inode(ip);
358 error = -EIO; 355 return -EIO;
359 } 356 }
360 357
361 return error; 358 return 0;
362} 359}
363 360
364/** 361/**