aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2011-11-21 13:36:17 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2011-11-22 05:25:21 -0500
commit564e12b1157215171e7f3af5b70611ec7154327c (patch)
treef2a6e3394e59209f8e43a36f10f67bf1372c966c /fs/gfs2/inode.c
parentb3e47ca0c2427ec72a74e36c6408784b6098f2b5 (diff)
GFS2: decouple quota allocations from block allocations
This patch separates the code pertaining to allocations into two parts: quota-related information and block reservations. This patch also moves all the block reservation structure allocations to function gfs2_inplace_reserve to simplify the code, and moves the frees to function gfs2_inplace_release. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r--fs/gfs2/inode.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 3ab192bac7d3..ab8c429880a5 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -391,11 +391,11 @@ static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation)
391 int error; 391 int error;
392 int dblocks = 0; 392 int dblocks = 0;
393 393
394 if (gfs2_alloc_get(dip) == NULL) 394 error = gfs2_rindex_update(sdp);
395 return -ENOMEM; 395 if (error)
396 fs_warn(sdp, "rindex update returns %d\n", error);
396 397
397 dip->i_alloc->al_requested = RES_DINODE; 398 error = gfs2_inplace_reserve(dip, RES_DINODE);
398 error = gfs2_inplace_reserve(dip);
399 if (error) 399 if (error)
400 goto out; 400 goto out;
401 401
@@ -410,7 +410,6 @@ static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation)
410out_ipreserv: 410out_ipreserv:
411 gfs2_inplace_release(dip); 411 gfs2_inplace_release(dip);
412out: 412out:
413 gfs2_alloc_put(dip);
414 return error; 413 return error;
415} 414}
416 415
@@ -526,7 +525,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
526 int error; 525 int error;
527 526
528 munge_mode_uid_gid(dip, &mode, &uid, &gid); 527 munge_mode_uid_gid(dip, &mode, &uid, &gid);
529 if (!gfs2_alloc_get(dip)) 528 if (!gfs2_qadata_get(dip))
530 return -ENOMEM; 529 return -ENOMEM;
531 530
532 error = gfs2_quota_lock(dip, uid, gid); 531 error = gfs2_quota_lock(dip, uid, gid);
@@ -548,7 +547,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
548out_quota: 547out_quota:
549 gfs2_quota_unlock(dip); 548 gfs2_quota_unlock(dip);
550out: 549out:
551 gfs2_alloc_put(dip); 550 gfs2_qadata_put(dip);
552 return error; 551 return error;
553} 552}
554 553
@@ -556,13 +555,13 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
556 struct gfs2_inode *ip) 555 struct gfs2_inode *ip)
557{ 556{
558 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 557 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
559 struct gfs2_alloc *al; 558 struct gfs2_qadata *qa;
560 int alloc_required; 559 int alloc_required;
561 struct buffer_head *dibh; 560 struct buffer_head *dibh;
562 int error; 561 int error;
563 562
564 al = gfs2_alloc_get(dip); 563 qa = gfs2_qadata_get(dip);
565 if (!al) 564 if (!qa)
566 return -ENOMEM; 565 return -ENOMEM;
567 566
568 error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); 567 error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
@@ -577,9 +576,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
577 if (error) 576 if (error)
578 goto fail_quota_locks; 577 goto fail_quota_locks;
579 578
580 al->al_requested = sdp->sd_max_dirres; 579 error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
581
582 error = gfs2_inplace_reserve(dip);
583 if (error) 580 if (error)
584 goto fail_quota_locks; 581 goto fail_quota_locks;
585 582
@@ -620,7 +617,7 @@ fail_quota_locks:
620 gfs2_quota_unlock(dip); 617 gfs2_quota_unlock(dip);
621 618
622fail: 619fail:
623 gfs2_alloc_put(dip); 620 gfs2_qadata_put(dip);
624 return error; 621 return error;
625} 622}
626 623
@@ -729,9 +726,12 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
729 brelse(bh); 726 brelse(bh);
730 727
731 gfs2_trans_end(sdp); 728 gfs2_trans_end(sdp);
732 gfs2_inplace_release(dip); 729 /* Check if we reserved space in the rgrp. Function link_dinode may
730 not, depending on whether alloc is required. */
731 if (dip->i_res)
732 gfs2_inplace_release(dip);
733 gfs2_quota_unlock(dip); 733 gfs2_quota_unlock(dip);
734 gfs2_alloc_put(dip); 734 gfs2_qadata_put(dip);
735 mark_inode_dirty(inode); 735 mark_inode_dirty(inode);
736 gfs2_glock_dq_uninit_m(2, ghs); 736 gfs2_glock_dq_uninit_m(2, ghs);
737 d_instantiate(dentry, inode); 737 d_instantiate(dentry, inode);
@@ -876,8 +876,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
876 error = 0; 876 error = 0;
877 877
878 if (alloc_required) { 878 if (alloc_required) {
879 struct gfs2_alloc *al = gfs2_alloc_get(dip); 879 struct gfs2_qadata *qa = gfs2_qadata_get(dip);
880 if (!al) { 880
881 if (!qa) {
881 error = -ENOMEM; 882 error = -ENOMEM;
882 goto out_gunlock; 883 goto out_gunlock;
883 } 884 }
@@ -886,9 +887,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
886 if (error) 887 if (error)
887 goto out_alloc; 888 goto out_alloc;
888 889
889 al->al_requested = sdp->sd_max_dirres; 890 error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
890
891 error = gfs2_inplace_reserve(dip);
892 if (error) 891 if (error)
893 goto out_gunlock_q; 892 goto out_gunlock_q;
894 893
@@ -931,7 +930,7 @@ out_gunlock_q:
931 gfs2_quota_unlock(dip); 930 gfs2_quota_unlock(dip);
932out_alloc: 931out_alloc:
933 if (alloc_required) 932 if (alloc_required)
934 gfs2_alloc_put(dip); 933 gfs2_qadata_put(dip);
935out_gunlock: 934out_gunlock:
936 gfs2_glock_dq(ghs + 1); 935 gfs2_glock_dq(ghs + 1);
937out_child: 936out_child:
@@ -1354,8 +1353,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
1354 error = 0; 1353 error = 0;
1355 1354
1356 if (alloc_required) { 1355 if (alloc_required) {
1357 struct gfs2_alloc *al = gfs2_alloc_get(ndip); 1356 struct gfs2_qadata *qa = gfs2_qadata_get(ndip);
1358 if (!al) { 1357
1358 if (!qa) {
1359 error = -ENOMEM; 1359 error = -ENOMEM;
1360 goto out_gunlock; 1360 goto out_gunlock;
1361 } 1361 }
@@ -1364,9 +1364,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
1364 if (error) 1364 if (error)
1365 goto out_alloc; 1365 goto out_alloc;
1366 1366
1367 al->al_requested = sdp->sd_max_dirres; 1367 error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres);
1368
1369 error = gfs2_inplace_reserve(ndip);
1370 if (error) 1368 if (error)
1371 goto out_gunlock_q; 1369 goto out_gunlock_q;
1372 1370
@@ -1427,7 +1425,7 @@ out_gunlock_q:
1427 gfs2_quota_unlock(ndip); 1425 gfs2_quota_unlock(ndip);
1428out_alloc: 1426out_alloc:
1429 if (alloc_required) 1427 if (alloc_required)
1430 gfs2_alloc_put(ndip); 1428 gfs2_qadata_put(ndip);
1431out_gunlock: 1429out_gunlock:
1432 while (x--) { 1430 while (x--) {
1433 gfs2_glock_dq(ghs + x); 1431 gfs2_glock_dq(ghs + x);
@@ -1588,7 +1586,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
1588 if (!(attr->ia_valid & ATTR_GID) || ogid == ngid) 1586 if (!(attr->ia_valid & ATTR_GID) || ogid == ngid)
1589 ogid = ngid = NO_QUOTA_CHANGE; 1587 ogid = ngid = NO_QUOTA_CHANGE;
1590 1588
1591 if (!gfs2_alloc_get(ip)) 1589 if (!gfs2_qadata_get(ip))
1592 return -ENOMEM; 1590 return -ENOMEM;
1593 1591
1594 error = gfs2_quota_lock(ip, nuid, ngid); 1592 error = gfs2_quota_lock(ip, nuid, ngid);
@@ -1620,7 +1618,7 @@ out_end_trans:
1620out_gunlock_q: 1618out_gunlock_q:
1621 gfs2_quota_unlock(ip); 1619 gfs2_quota_unlock(ip);
1622out_alloc: 1620out_alloc:
1623 gfs2_alloc_put(ip); 1621 gfs2_qadata_put(ip);
1624 return error; 1622 return error;
1625} 1623}
1626 1624