summaryrefslogtreecommitdiffstats
path: root/fs/gfs2/dir.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2011-05-09 08:30:08 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2011-05-09 11:43:53 -0400
commit3d6ecb7d16fd4248fce58387a982a0756ad3fcc2 (patch)
treeb988b57c8a46fcfabe3738ccdb8982d67cd24c97 /fs/gfs2/dir.c
parent855d23ce2665c56437bd88fa6a0d45b6713bd194 (diff)
GFS2: When adding a new dir entry, inc link count if it is a subdir
This adds an increment of the link count when we add a new directory entry, if that entry is itself a directory. This means that we no longer need separate code to perform this operation. Now that both adding and removing directory entries automatically update the parent directory's link count if required, that makes the code shorter and simpler than before. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/dir.c')
-rw-r--r--fs/gfs2/dir.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 410265151ad1..091ee4779538 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -1597,7 +1597,7 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
1597 */ 1597 */
1598 1598
1599int gfs2_dir_add(struct inode *inode, const struct qstr *name, 1599int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1600 const struct gfs2_inode *nip, unsigned type) 1600 const struct gfs2_inode *nip)
1601{ 1601{
1602 struct gfs2_inode *ip = GFS2_I(inode); 1602 struct gfs2_inode *ip = GFS2_I(inode);
1603 struct buffer_head *bh; 1603 struct buffer_head *bh;
@@ -1613,7 +1613,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1613 return PTR_ERR(dent); 1613 return PTR_ERR(dent);
1614 dent = gfs2_init_dirent(inode, dent, name, bh); 1614 dent = gfs2_init_dirent(inode, dent, name, bh);
1615 gfs2_inum_out(nip, dent); 1615 gfs2_inum_out(nip, dent);
1616 dent->de_type = cpu_to_be16(type); 1616 dent->de_type = cpu_to_be16(IF2DT(nip->i_inode.i_mode));
1617 if (ip->i_diskflags & GFS2_DIF_EXHASH) { 1617 if (ip->i_diskflags & GFS2_DIF_EXHASH) {
1618 leaf = (struct gfs2_leaf *)bh->b_data; 1618 leaf = (struct gfs2_leaf *)bh->b_data;
1619 be16_add_cpu(&leaf->lf_entries, 1); 1619 be16_add_cpu(&leaf->lf_entries, 1);
@@ -1625,6 +1625,8 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1625 gfs2_trans_add_bh(ip->i_gl, bh, 1); 1625 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1626 ip->i_entries++; 1626 ip->i_entries++;
1627 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 1627 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1628 if (S_ISDIR(nip->i_inode.i_mode))
1629 inc_nlink(&ip->i_inode);
1628 gfs2_dinode_out(ip, bh->b_data); 1630 gfs2_dinode_out(ip, bh->b_data);
1629 brelse(bh); 1631 brelse(bh);
1630 error = 0; 1632 error = 0;