aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2011-08-15 09:20:36 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2011-10-21 07:39:26 -0400
commitab9bbda0204dfd0e5342562d9979d1241b14ea5f (patch)
tree621e623d99fbef1432da17b6390c92d7f13224a4 /fs/gfs2/inode.c
parentf18185291d605ea9e442e00e2cf6c917a84d9837 (diff)
GFS2: Use ->dirty_inode()
The aim of this patch is to use the newly enhanced ->dirty_inode() super block operation to deal with atime updates, rather than piggy backing that code into ->write_inode() as is currently done. The net result is a simplification of the code in various places and a reduction of the number of gfs2_dinode_out() calls since this is now implied by ->dirty_inode(). Some of the mark_inode_dirty() calls have been moved under glocks in order to take advantage of then being able to avoid locking in ->dirty_inode() when we already have suitable locks. One consequence is that generic_write_end() now correctly deals with file size updates, so that we do not need a separate check for that afterwards. This also, indirectly, means that fdatasync should work correctly on GFS2 - the current code always syncs the metadata whether it needs to or not. Has survived testing with postmark (with and without atime) and also fsx. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r--fs/gfs2/inode.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 044efe273b97..a0b53d3bd8fa 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -729,8 +729,8 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
729 gfs2_inplace_release(dip); 729 gfs2_inplace_release(dip);
730 gfs2_quota_unlock(dip); 730 gfs2_quota_unlock(dip);
731 gfs2_alloc_put(dip); 731 gfs2_alloc_put(dip);
732 gfs2_glock_dq_uninit_m(2, ghs);
733 mark_inode_dirty(inode); 732 mark_inode_dirty(inode);
733 gfs2_glock_dq_uninit_m(2, ghs);
734 d_instantiate(dentry, inode); 734 d_instantiate(dentry, inode);
735 return 0; 735 return 0;
736 736
@@ -926,8 +926,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
926 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 926 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
927 inc_nlink(&ip->i_inode); 927 inc_nlink(&ip->i_inode);
928 ip->i_inode.i_ctime = CURRENT_TIME; 928 ip->i_inode.i_ctime = CURRENT_TIME;
929 gfs2_dinode_out(ip, dibh->b_data); 929 ihold(inode);
930 mark_inode_dirty(&ip->i_inode); 930 d_instantiate(dentry, inode);
931 mark_inode_dirty(inode);
931 932
932out_brelse: 933out_brelse:
933 brelse(dibh); 934 brelse(dibh);
@@ -949,11 +950,6 @@ out_child:
949out_parent: 950out_parent:
950 gfs2_holder_uninit(ghs); 951 gfs2_holder_uninit(ghs);
951 gfs2_holder_uninit(ghs + 1); 952 gfs2_holder_uninit(ghs + 1);
952 if (!error) {
953 ihold(inode);
954 d_instantiate(dentry, inode);
955 mark_inode_dirty(inode);
956 }
957 return error; 953 return error;
958} 954}
959 955
@@ -1026,8 +1022,6 @@ static int gfs2_unlink_inode(struct gfs2_inode *dip,
1026 clear_nlink(inode); 1022 clear_nlink(inode);
1027 else 1023 else
1028 drop_nlink(inode); 1024 drop_nlink(inode);
1029 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1030 gfs2_dinode_out(ip, bh->b_data);
1031 mark_inode_dirty(inode); 1025 mark_inode_dirty(inode);
1032 if (inode->i_nlink == 0) 1026 if (inode->i_nlink == 0)
1033 gfs2_unlink_di(inode); 1027 gfs2_unlink_di(inode);
@@ -1565,21 +1559,10 @@ int gfs2_permission(struct inode *inode, int mask)
1565 return error; 1559 return error;
1566} 1560}
1567 1561
1568static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) 1562static int __gfs2_setattr_simple(struct inode *inode, struct iattr *attr)
1569{ 1563{
1570 struct inode *inode = &ip->i_inode;
1571 struct buffer_head *dibh;
1572 int error;
1573
1574 error = gfs2_meta_inode_buffer(ip, &dibh);
1575 if (error)
1576 return error;
1577
1578 setattr_copy(inode, attr); 1564 setattr_copy(inode, attr);
1579 mark_inode_dirty(inode); 1565 mark_inode_dirty(inode);
1580 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1581 gfs2_dinode_out(ip, dibh->b_data);
1582 brelse(dibh);
1583 return 0; 1566 return 0;
1584} 1567}
1585 1568
@@ -1591,19 +1574,19 @@ static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
1591 * Returns: errno 1574 * Returns: errno
1592 */ 1575 */
1593 1576
1594int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) 1577int gfs2_setattr_simple(struct inode *inode, struct iattr *attr)
1595{ 1578{
1596 int error; 1579 int error;
1597 1580
1598 if (current->journal_info) 1581 if (current->journal_info)
1599 return __gfs2_setattr_simple(ip, attr); 1582 return __gfs2_setattr_simple(inode, attr);
1600 1583
1601 error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE, 0); 1584 error = gfs2_trans_begin(GFS2_SB(inode), RES_DINODE, 0);
1602 if (error) 1585 if (error)
1603 return error; 1586 return error;
1604 1587
1605 error = __gfs2_setattr_simple(ip, attr); 1588 error = __gfs2_setattr_simple(inode, attr);
1606 gfs2_trans_end(GFS2_SB(&ip->i_inode)); 1589 gfs2_trans_end(GFS2_SB(inode));
1607 return error; 1590 return error;
1608} 1591}
1609 1592
@@ -1641,7 +1624,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
1641 if (error) 1624 if (error)
1642 goto out_gunlock_q; 1625 goto out_gunlock_q;
1643 1626
1644 error = gfs2_setattr_simple(ip, attr); 1627 error = gfs2_setattr_simple(inode, attr);
1645 if (error) 1628 if (error)
1646 goto out_end_trans; 1629 goto out_end_trans;
1647 1630
@@ -1697,12 +1680,12 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
1697 else if ((attr->ia_valid & ATTR_MODE) && IS_POSIXACL(inode)) 1680 else if ((attr->ia_valid & ATTR_MODE) && IS_POSIXACL(inode))
1698 error = gfs2_acl_chmod(ip, attr); 1681 error = gfs2_acl_chmod(ip, attr);
1699 else 1682 else
1700 error = gfs2_setattr_simple(ip, attr); 1683 error = gfs2_setattr_simple(inode, attr);
1701 1684
1702out: 1685out:
1703 gfs2_glock_dq_uninit(&i_gh);
1704 if (!error) 1686 if (!error)
1705 mark_inode_dirty(inode); 1687 mark_inode_dirty(inode);
1688 gfs2_glock_dq_uninit(&i_gh);
1706 return error; 1689 return error;
1707} 1690}
1708 1691