aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/inode.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/inode.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/inode.c')
-rw-r--r--fs/gfs2/inode.c48
1 files changed, 1 insertions, 47 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 5a02606b68c0..a8c14c9985e2 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -362,52 +362,6 @@ int gfs2_inode_refresh(struct gfs2_inode *ip)
362 return error; 362 return error;
363} 363}
364 364
365/**
366 * gfs2_change_nlink - Change nlink count on inode
367 * @ip: The GFS2 inode
368 * @diff: The change in the nlink count required
369 *
370 * Returns: errno
371 */
372int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
373{
374 struct buffer_head *dibh;
375 u32 nlink;
376 int error;
377
378 BUG_ON(diff != 1 && diff != -1);
379 nlink = ip->i_inode.i_nlink + diff;
380
381 /* If we are reducing the nlink count, but the new value ends up being
382 bigger than the old one, we must have underflowed. */
383 if (diff < 0 && nlink > ip->i_inode.i_nlink) {
384 if (gfs2_consist_inode(ip))
385 gfs2_dinode_print(ip);
386 return -EIO;
387 }
388
389 error = gfs2_meta_inode_buffer(ip, &dibh);
390 if (error)
391 return error;
392
393 if (diff > 0)
394 inc_nlink(&ip->i_inode);
395 else
396 drop_nlink(&ip->i_inode);
397
398 ip->i_inode.i_ctime = CURRENT_TIME;
399
400 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
401 gfs2_dinode_out(ip, dibh->b_data);
402 brelse(dibh);
403 mark_inode_dirty(&ip->i_inode);
404
405 if (ip->i_inode.i_nlink == 0)
406 gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */
407
408 return error;
409}
410
411struct inode *gfs2_lookup_simple(struct inode *dip, const char *name) 365struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
412{ 366{
413 struct qstr qstr; 367 struct qstr qstr;
@@ -723,7 +677,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
723 goto fail_quota_locks; 677 goto fail_quota_locks;
724 } 678 }
725 679
726 error = gfs2_dir_add(&dip->i_inode, name, ip, IF2DT(ip->i_inode.i_mode)); 680 error = gfs2_dir_add(&dip->i_inode, name, ip);
727 if (error) 681 if (error)
728 goto fail_end_trans; 682 goto fail_end_trans;
729 683