aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2012-06-06 06:17:59 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2012-06-06 06:17:59 -0400
commit0a305e496059a113f93bdd3ad27a5aaa917fe34d (patch)
treeb0b6ce3997fef4c4e28f598a98e2e08c939414a6 /fs/gfs2/inode.c
parenteea5b5510fc5545d15b69da8e485a7424ae388cf (diff)
GFS2: Extend the life of the reservations
This patch lengthens the lifespan of the reservations structure for inodes. Before, they were allocated and deallocated for every write operation. With this patch, they are allocated when the first write occurs, and deallocated when the last process closes the file. It's more efficient to do it this way because it saves GFS2 a lot of unnecessary allocates and frees. It also gives us more flexibility for the future: (1) we can now fold the qadata structure back into the structure and save those alloc/frees, (2) we can use this for multi-block reservations. 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.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index a9ba2444e077..2a1b4b5a648c 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -667,6 +667,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
667 if (!name->len || name->len > GFS2_FNAMESIZE) 667 if (!name->len || name->len > GFS2_FNAMESIZE)
668 return -ENAMETOOLONG; 668 return -ENAMETOOLONG;
669 669
670 error = gfs2_rs_alloc(dip);
671 if (error)
672 return error;
673
670 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); 674 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
671 if (error) 675 if (error)
672 goto fail; 676 goto fail;
@@ -704,6 +708,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
704 if (error) 708 if (error)
705 goto fail_gunlock2; 709 goto fail_gunlock2;
706 710
711 /* the new inode needs a reservation so it can allocate xattrs. */
712 error = gfs2_rs_alloc(GFS2_I(inode));
713 if (error)
714 goto fail_gunlock2;
715
707 error = gfs2_acl_create(dip, inode); 716 error = gfs2_acl_create(dip, inode);
708 if (error) 717 if (error)
709 goto fail_gunlock2; 718 goto fail_gunlock2;
@@ -722,7 +731,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
722 gfs2_trans_end(sdp); 731 gfs2_trans_end(sdp);
723 /* Check if we reserved space in the rgrp. Function link_dinode may 732 /* Check if we reserved space in the rgrp. Function link_dinode may
724 not, depending on whether alloc is required. */ 733 not, depending on whether alloc is required. */
725 if (dip->i_res) 734 if (gfs2_mb_reserved(dip))
726 gfs2_inplace_release(dip); 735 gfs2_inplace_release(dip);
727 gfs2_quota_unlock(dip); 736 gfs2_quota_unlock(dip);
728 gfs2_qadata_put(dip); 737 gfs2_qadata_put(dip);
@@ -819,6 +828,10 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
819 if (S_ISDIR(inode->i_mode)) 828 if (S_ISDIR(inode->i_mode))
820 return -EPERM; 829 return -EPERM;
821 830
831 error = gfs2_rs_alloc(dip);
832 if (error)
833 return error;
834
822 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); 835 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
823 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); 836 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
824 837
@@ -1234,6 +1247,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
1234 if (error) 1247 if (error)
1235 return error; 1248 return error;
1236 1249
1250 error = gfs2_rs_alloc(ndip);
1251 if (error)
1252 return error;
1253
1237 if (odip != ndip) { 1254 if (odip != ndip) {
1238 error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE, 1255 error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE,
1239 0, &r_gh); 1256 0, &r_gh);
@@ -1644,6 +1661,10 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
1644 struct gfs2_holder i_gh; 1661 struct gfs2_holder i_gh;
1645 int error; 1662 int error;
1646 1663
1664 error = gfs2_rs_alloc(ip);
1665 if (error)
1666 return error;
1667
1647 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh); 1668 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &i_gh);
1648 if (error) 1669 if (error)
1649 return error; 1670 return error;