aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2011-10-28 08:13:28 -0400
committerChristoph Hellwig <hch@serles.lst.de>2011-11-02 07:53:43 -0400
commit6d6b77f163c7eabedbba00ed2abb7d4a570bff76 (patch)
tree6ce074a7dd5a25fae28ef9de6f59ddee08ea4e61 /fs
parentdd2a981f46a0903a8770a784f213d4d40bbb6f19 (diff)
filesystems: add missing nlink wrappers
Replace direct i_nlink updates with the respective updater function (inc_nlink, drop_nlink, clear_nlink, inode_dec_link_count). Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r--fs/affs/amigaffs.c2
-rw-r--r--fs/affs/namei.c6
-rw-r--r--fs/binfmt_misc.c2
-rw-r--r--fs/cifs/link.c2
-rw-r--r--fs/coda/dir.c2
-rw-r--r--fs/devpts/inode.c2
-rw-r--r--fs/ext2/ialloc.c2
-rw-r--r--fs/ext3/ialloc.c2
-rw-r--r--fs/ext3/namei.c2
-rw-r--r--fs/ext4/ialloc.c2
-rw-r--r--fs/ext4/migrate.c2
-rw-r--r--fs/ext4/namei.c2
-rw-r--r--fs/hfs/dir.c4
-rw-r--r--fs/hfsplus/dir.c4
-rw-r--r--fs/hpfs/inode.c2
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/jfs/jfs_inode.c2
-rw-r--r--fs/jfs/namei.c10
-rw-r--r--fs/logfs/dir.c8
-rw-r--r--fs/logfs/inode.c2
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/nilfs2/inode.c2
-rw-r--r--fs/ocfs2/namei.c8
-rw-r--r--fs/proc/proc_sysctl.c2
-rw-r--r--fs/reiserfs/inode.c4
-rw-r--r--fs/reiserfs/namei.c12
-rw-r--r--fs/ubifs/xattr.c2
-rw-r--r--fs/udf/namei.c11
-rw-r--r--fs/ufs/ialloc.c2
29 files changed, 52 insertions, 55 deletions
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 3a4557e8325c..8f12723bbc97 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -316,7 +316,7 @@ affs_remove_header(struct dentry *dentry)
316 if (inode->i_nlink > 1) 316 if (inode->i_nlink > 1)
317 retval = affs_remove_link(dentry); 317 retval = affs_remove_link(dentry);
318 else 318 else
319 inode->i_nlink = 0; 319 clear_nlink(inode);
320 affs_unlock_link(inode); 320 affs_unlock_link(inode);
321 inode->i_ctime = CURRENT_TIME_SEC; 321 inode->i_ctime = CURRENT_TIME_SEC;
322 mark_inode_dirty(inode); 322 mark_inode_dirty(inode);
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index e3e9efc1fdd8..780a11dc6318 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -277,7 +277,7 @@ affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata
277 inode->i_mapping->a_ops = (AFFS_SB(sb)->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops; 277 inode->i_mapping->a_ops = (AFFS_SB(sb)->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops;
278 error = affs_add_entry(dir, inode, dentry, ST_FILE); 278 error = affs_add_entry(dir, inode, dentry, ST_FILE);
279 if (error) { 279 if (error) {
280 inode->i_nlink = 0; 280 clear_nlink(inode);
281 iput(inode); 281 iput(inode);
282 return error; 282 return error;
283 } 283 }
@@ -305,7 +305,7 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
305 305
306 error = affs_add_entry(dir, inode, dentry, ST_USERDIR); 306 error = affs_add_entry(dir, inode, dentry, ST_USERDIR);
307 if (error) { 307 if (error) {
308 inode->i_nlink = 0; 308 clear_nlink(inode);
309 mark_inode_dirty(inode); 309 mark_inode_dirty(inode);
310 iput(inode); 310 iput(inode);
311 return error; 311 return error;
@@ -392,7 +392,7 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
392 return 0; 392 return 0;
393 393
394err: 394err:
395 inode->i_nlink = 0; 395 clear_nlink(inode);
396 mark_inode_dirty(inode); 396 mark_inode_dirty(inode);
397 iput(inode); 397 iput(inode);
398 return error; 398 return error;
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index ba1a1ae4a18a..1e9edbdeda7e 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -521,7 +521,7 @@ static void kill_node(Node *e)
521 write_unlock(&entries_lock); 521 write_unlock(&entries_lock);
522 522
523 if (dentry) { 523 if (dentry) {
524 dentry->d_inode->i_nlink--; 524 drop_nlink(dentry->d_inode);
525 d_drop(dentry); 525 d_drop(dentry);
526 dput(dentry); 526 dput(dentry);
527 simple_release_fs(&bm_mnt, &entry_count); 527 simple_release_fs(&bm_mnt, &entry_count);
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 8693b5d0e180..6b0e06434391 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -433,7 +433,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
433 if (old_file->d_inode) { 433 if (old_file->d_inode) {
434 cifsInode = CIFS_I(old_file->d_inode); 434 cifsInode = CIFS_I(old_file->d_inode);
435 if (rc == 0) { 435 if (rc == 0) {
436 old_file->d_inode->i_nlink++; 436 inc_nlink(old_file->d_inode);
437/* BB should we make this contingent on superblock flag NOATIME? */ 437/* BB should we make this contingent on superblock flag NOATIME? */
438/* old_file->d_inode->i_ctime = CURRENT_TIME;*/ 438/* old_file->d_inode->i_ctime = CURRENT_TIME;*/
439 /* parent dir timestamps will update from srv 439 /* parent dir timestamps will update from srv
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 0239433f50cb..28e7e135cfab 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -340,7 +340,7 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
340 if (!error) { 340 if (!error) {
341 /* VFS may delete the child */ 341 /* VFS may delete the child */
342 if (de->d_inode) 342 if (de->d_inode)
343 de->d_inode->i_nlink = 0; 343 clear_nlink(de->d_inode);
344 344
345 /* fix the link count of the parent */ 345 /* fix the link count of the parent */
346 coda_dir_drop_nlink(dir); 346 coda_dir_drop_nlink(dir);
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 2f27e578d466..c196e544c64e 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -549,7 +549,7 @@ void devpts_pty_kill(struct tty_struct *tty)
549 549
550 dentry = d_find_alias(inode); 550 dentry = d_find_alias(inode);
551 551
552 inode->i_nlink--; 552 drop_nlink(inode);
553 d_delete(dentry); 553 d_delete(dentry);
554 dput(dentry); /* d_alloc_name() in devpts_pty_new() */ 554 dput(dentry); /* d_alloc_name() in devpts_pty_new() */
555 dput(dentry); /* d_find_alias above */ 555 dput(dentry); /* d_find_alias above */
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index ee9ed31948e1..c4e81dfb74ba 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -601,7 +601,7 @@ fail_free_drop:
601fail_drop: 601fail_drop:
602 dquot_drop(inode); 602 dquot_drop(inode);
603 inode->i_flags |= S_NOQUOTA; 603 inode->i_flags |= S_NOQUOTA;
604 inode->i_nlink = 0; 604 clear_nlink(inode);
605 unlock_new_inode(inode); 605 unlock_new_inode(inode);
606 iput(inode); 606 iput(inode);
607 return ERR_PTR(err); 607 return ERR_PTR(err);
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index bf09cbf938cc..835d4ea61b0e 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -621,7 +621,7 @@ fail_free_drop:
621fail_drop: 621fail_drop:
622 dquot_drop(inode); 622 dquot_drop(inode);
623 inode->i_flags |= S_NOQUOTA; 623 inode->i_flags |= S_NOQUOTA;
624 inode->i_nlink = 0; 624 clear_nlink(inode);
625 unlock_new_inode(inode); 625 unlock_new_inode(inode);
626 iput(inode); 626 iput(inode);
627 brelse(bitmap_bh); 627 brelse(bitmap_bh);
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 0629e09f6511..8a60e3327659 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1833,7 +1833,7 @@ retry:
1833 1833
1834 if (err) { 1834 if (err) {
1835out_clear_inode: 1835out_clear_inode:
1836 inode->i_nlink = 0; 1836 clear_nlink(inode);
1837 unlock_new_inode(inode); 1837 unlock_new_inode(inode);
1838 ext3_mark_inode_dirty(handle, inode); 1838 ext3_mark_inode_dirty(handle, inode);
1839 iput (inode); 1839 iput (inode);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 9c63f273b550..ecc55bd2f997 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1084,7 +1084,7 @@ fail_free_drop:
1084fail_drop: 1084fail_drop:
1085 dquot_drop(inode); 1085 dquot_drop(inode);
1086 inode->i_flags |= S_NOQUOTA; 1086 inode->i_flags |= S_NOQUOTA;
1087 inode->i_nlink = 0; 1087 clear_nlink(inode);
1088 unlock_new_inode(inode); 1088 unlock_new_inode(inode);
1089 iput(inode); 1089 iput(inode);
1090 brelse(inode_bitmap_bh); 1090 brelse(inode_bitmap_bh);
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index b57b98fb44d1..667cc880bc0c 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -507,7 +507,7 @@ int ext4_ext_migrate(struct inode *inode)
507 * Set the i_nlink to zero so it will be deleted later 507 * Set the i_nlink to zero so it will be deleted later
508 * when we drop inode reference. 508 * when we drop inode reference.
509 */ 509 */
510 tmp_inode->i_nlink = 0; 510 clear_nlink(tmp_inode);
511 511
512 ext4_ext_tree_init(handle, tmp_inode); 512 ext4_ext_tree_init(handle, tmp_inode);
513 ext4_orphan_add(handle, tmp_inode); 513 ext4_orphan_add(handle, tmp_inode);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 1c924faeb6c8..4623c082f3b2 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2539,7 +2539,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
2539 if (new_inode) { 2539 if (new_inode) {
2540 /* checked empty_dir above, can't have another parent, 2540 /* checked empty_dir above, can't have another parent,
2541 * ext4_dec_count() won't work for many-linked dirs */ 2541 * ext4_dec_count() won't work for many-linked dirs */
2542 new_inode->i_nlink = 0; 2542 clear_nlink(new_inode);
2543 } else { 2543 } else {
2544 ext4_inc_count(handle, new_dir); 2544 ext4_inc_count(handle, new_dir);
2545 ext4_update_dx_flag(new_dir); 2545 ext4_update_dx_flag(new_dir);
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index b4d70b13be92..bce4eef91a06 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -198,7 +198,7 @@ static int hfs_create(struct inode *dir, struct dentry *dentry, int mode,
198 198
199 res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode); 199 res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode);
200 if (res) { 200 if (res) {
201 inode->i_nlink = 0; 201 clear_nlink(inode);
202 hfs_delete_inode(inode); 202 hfs_delete_inode(inode);
203 iput(inode); 203 iput(inode);
204 return res; 204 return res;
@@ -227,7 +227,7 @@ static int hfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
227 227
228 res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode); 228 res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode);
229 if (res) { 229 if (res) {
230 inode->i_nlink = 0; 230 clear_nlink(inode);
231 hfs_delete_inode(inode); 231 hfs_delete_inode(inode);
232 iput(inode); 232 iput(inode);
233 return res; 233 return res;
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 25b2443a004c..4536cd3f15ae 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -415,7 +415,7 @@ static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
415 goto out; 415 goto out;
416 416
417out_err: 417out_err:
418 inode->i_nlink = 0; 418 clear_nlink(inode);
419 hfsplus_delete_inode(inode); 419 hfsplus_delete_inode(inode);
420 iput(inode); 420 iput(inode);
421out: 421out:
@@ -440,7 +440,7 @@ static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,
440 440
441 res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode); 441 res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode);
442 if (res) { 442 if (res) {
443 inode->i_nlink = 0; 443 clear_nlink(inode);
444 hfsplus_delete_inode(inode); 444 hfsplus_delete_inode(inode);
445 iput(inode); 445 iput(inode);
446 goto out; 446 goto out;
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 338cd8368451..dfe800c8ae38 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -53,7 +53,7 @@ void hpfs_read_inode(struct inode *i)
53 i->i_mode &= ~0111; 53 i->i_mode &= ~0111;
54 i->i_op = &hpfs_file_iops; 54 i->i_op = &hpfs_file_iops;
55 i->i_fop = &hpfs_file_ops; 55 i->i_fop = &hpfs_file_ops;
56 i->i_nlink = 0;*/ 56 clear_nlink(i);*/
57 make_bad_inode(i); 57 make_bad_inode(i);
58 return; 58 return;
59 } 59 }
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index ec889538e5a6..0be5a78598d0 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -970,7 +970,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size,
970 970
971 d_instantiate(path.dentry, inode); 971 d_instantiate(path.dentry, inode);
972 inode->i_size = size; 972 inode->i_size = size;
973 inode->i_nlink = 0; 973 clear_nlink(inode);
974 974
975 error = -ENFILE; 975 error = -ENFILE;
976 file = alloc_file(&path, FMODE_WRITE | FMODE_READ, 976 file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c
index 2686531e235a..c1a3e603279c 100644
--- a/fs/jfs/jfs_inode.c
+++ b/fs/jfs/jfs_inode.c
@@ -157,7 +157,7 @@ fail_drop:
157 dquot_drop(inode); 157 dquot_drop(inode);
158 inode->i_flags |= S_NOQUOTA; 158 inode->i_flags |= S_NOQUOTA;
159fail_unlock: 159fail_unlock:
160 inode->i_nlink = 0; 160 clear_nlink(inode);
161 unlock_new_inode(inode); 161 unlock_new_inode(inode);
162fail_put: 162fail_put:
163 iput(inode); 163 iput(inode);
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index e17545e15664..94b0a624b85f 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -172,7 +172,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
172 mutex_unlock(&JFS_IP(dip)->commit_mutex); 172 mutex_unlock(&JFS_IP(dip)->commit_mutex);
173 if (rc) { 173 if (rc) {
174 free_ea_wmap(ip); 174 free_ea_wmap(ip);
175 ip->i_nlink = 0; 175 clear_nlink(ip);
176 unlock_new_inode(ip); 176 unlock_new_inode(ip);
177 iput(ip); 177 iput(ip);
178 } else { 178 } else {
@@ -311,7 +311,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
311 mutex_unlock(&JFS_IP(dip)->commit_mutex); 311 mutex_unlock(&JFS_IP(dip)->commit_mutex);
312 if (rc) { 312 if (rc) {
313 free_ea_wmap(ip); 313 free_ea_wmap(ip);
314 ip->i_nlink = 0; 314 clear_nlink(ip);
315 unlock_new_inode(ip); 315 unlock_new_inode(ip);
316 iput(ip); 316 iput(ip);
317 } else { 317 } else {
@@ -844,7 +844,7 @@ static int jfs_link(struct dentry *old_dentry,
844 rc = txCommit(tid, 2, &iplist[0], 0); 844 rc = txCommit(tid, 2, &iplist[0], 0);
845 845
846 if (rc) { 846 if (rc) {
847 ip->i_nlink--; /* never instantiated */ 847 drop_nlink(ip); /* never instantiated */
848 iput(ip); 848 iput(ip);
849 } else 849 } else
850 d_instantiate(dentry, ip); 850 d_instantiate(dentry, ip);
@@ -1048,7 +1048,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
1048 mutex_unlock(&JFS_IP(dip)->commit_mutex); 1048 mutex_unlock(&JFS_IP(dip)->commit_mutex);
1049 if (rc) { 1049 if (rc) {
1050 free_ea_wmap(ip); 1050 free_ea_wmap(ip);
1051 ip->i_nlink = 0; 1051 clear_nlink(ip);
1052 unlock_new_inode(ip); 1052 unlock_new_inode(ip);
1053 iput(ip); 1053 iput(ip);
1054 } else { 1054 } else {
@@ -1433,7 +1433,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
1433 mutex_unlock(&JFS_IP(dir)->commit_mutex); 1433 mutex_unlock(&JFS_IP(dir)->commit_mutex);
1434 if (rc) { 1434 if (rc) {
1435 free_ea_wmap(ip); 1435 free_ea_wmap(ip);
1436 ip->i_nlink = 0; 1436 clear_nlink(ip);
1437 unlock_new_inode(ip); 1437 unlock_new_inode(ip);
1438 iput(ip); 1438 iput(ip);
1439 } else { 1439 } else {
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index b3ff3d894165..b7d7f67cee5a 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -197,7 +197,7 @@ static int logfs_remove_inode(struct inode *inode)
197{ 197{
198 int ret; 198 int ret;
199 199
200 inode->i_nlink--; 200 drop_nlink(inode);
201 ret = write_inode(inode); 201 ret = write_inode(inode);
202 LOGFS_BUG_ON(ret, inode->i_sb); 202 LOGFS_BUG_ON(ret, inode->i_sb);
203 return ret; 203 return ret;
@@ -433,7 +433,7 @@ static int __logfs_create(struct inode *dir, struct dentry *dentry,
433 433
434 ta = kzalloc(sizeof(*ta), GFP_KERNEL); 434 ta = kzalloc(sizeof(*ta), GFP_KERNEL);
435 if (!ta) { 435 if (!ta) {
436 inode->i_nlink--; 436 drop_nlink(inode);
437 iput(inode); 437 iput(inode);
438 return -ENOMEM; 438 return -ENOMEM;
439 } 439 }
@@ -456,7 +456,7 @@ static int __logfs_create(struct inode *dir, struct dentry *dentry,
456 abort_transaction(inode, ta); 456 abort_transaction(inode, ta);
457 li->li_flags |= LOGFS_IF_STILLBORN; 457 li->li_flags |= LOGFS_IF_STILLBORN;
458 /* FIXME: truncate symlink */ 458 /* FIXME: truncate symlink */
459 inode->i_nlink--; 459 drop_nlink(inode);
460 iput(inode); 460 iput(inode);
461 goto out; 461 goto out;
462 } 462 }
@@ -563,7 +563,7 @@ static int logfs_link(struct dentry *old_dentry, struct inode *dir,
563 563
564 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; 564 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
565 ihold(inode); 565 ihold(inode);
566 inode->i_nlink++; 566 inc_nlink(inode);
567 mark_inode_dirty_sync(inode); 567 mark_inode_dirty_sync(inode);
568 568
569 return __logfs_create(dir, dentry, inode, NULL, 0); 569 return __logfs_create(dir, dentry, inode, NULL, 0);
diff --git a/fs/logfs/inode.c b/fs/logfs/inode.c
index 9abb048b96c0..7e441ad5f792 100644
--- a/fs/logfs/inode.c
+++ b/fs/logfs/inode.c
@@ -93,7 +93,7 @@ static struct inode *__logfs_iget(struct super_block *sb, ino_t ino)
93 /* inode->i_nlink == 0 can be true when called from 93 /* inode->i_nlink == 0 can be true when called from
94 * block validator */ 94 * block validator */
95 /* set i_nlink to 0 to prevent caching */ 95 /* set i_nlink to 0 to prevent caching */
96 inode->i_nlink = 0; 96 clear_nlink(inode);
97 logfs_inode(inode)->li_flags |= LOGFS_IF_ZOMBIE; 97 logfs_inode(inode)->li_flags |= LOGFS_IF_ZOMBIE;
98 iget_failed(inode); 98 iget_failed(inode);
99 if (!err) 99 if (!err)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 4dc6d078f108..1fc715acc2da 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -320,7 +320,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
320 memset(&inode->i_ctime, 0, sizeof(inode->i_ctime)); 320 memset(&inode->i_ctime, 0, sizeof(inode->i_ctime));
321 inode->i_version = 0; 321 inode->i_version = 0;
322 inode->i_size = 0; 322 inode->i_size = 0;
323 inode->i_nlink = 0; 323 clear_nlink(inode);
324 inode->i_uid = -2; 324 inode->i_uid = -2;
325 inode->i_gid = -2; 325 inode->i_gid = -2;
326 inode->i_blocks = 0; 326 inode->i_blocks = 0;
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 666628b395f1..08ac272b7c28 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -354,7 +354,7 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
354 354
355 failed_acl: 355 failed_acl:
356 failed_bmap: 356 failed_bmap:
357 inode->i_nlink = 0; 357 clear_nlink(inode);
358 iput(inode); /* raw_inode will be deleted through 358 iput(inode); /* raw_inode will be deleted through
359 generic_delete_inode() */ 359 generic_delete_inode() */
360 goto failed; 360 goto failed;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 0181f63dd463..ea0ecbdda58c 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1377,7 +1377,7 @@ static int ocfs2_rename(struct inode *old_dir,
1377 } 1377 }
1378 1378
1379 if (new_inode) { 1379 if (new_inode) {
1380 new_inode->i_nlink--; 1380 drop_nlink(new_inode);
1381 new_inode->i_ctime = CURRENT_TIME; 1381 new_inode->i_ctime = CURRENT_TIME;
1382 } 1382 }
1383 old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; 1383 old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
@@ -1385,9 +1385,9 @@ static int ocfs2_rename(struct inode *old_dir,
1385 if (update_dot_dot) { 1385 if (update_dot_dot) {
1386 status = ocfs2_update_entry(old_inode, handle, 1386 status = ocfs2_update_entry(old_inode, handle,
1387 &old_inode_dot_dot_res, new_dir); 1387 &old_inode_dot_dot_res, new_dir);
1388 old_dir->i_nlink--; 1388 drop_nlink(old_dir);
1389 if (new_inode) { 1389 if (new_inode) {
1390 new_inode->i_nlink--; 1390 drop_nlink(new_inode);
1391 } else { 1391 } else {
1392 inc_nlink(new_dir); 1392 inc_nlink(new_dir);
1393 mark_inode_dirty(new_dir); 1393 mark_inode_dirty(new_dir);
@@ -2280,7 +2280,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
2280 goto leave; 2280 goto leave;
2281 } 2281 }
2282 2282
2283 inode->i_nlink = 0; 2283 clear_nlink(inode);
2284 /* do the real work now. */ 2284 /* do the real work now. */
2285 status = __ocfs2_mknod_locked(dir, inode, 2285 status = __ocfs2_mknod_locked(dir, inode,
2286 0, &new_di_bh, parent_di_bh, handle, 2286 0, &new_di_bh, parent_di_bh, handle,
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 1a77dbef226f..b44113279e30 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -39,7 +39,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
39 inode->i_fop = &proc_sys_file_operations; 39 inode->i_fop = &proc_sys_file_operations;
40 } else { 40 } else {
41 inode->i_mode |= S_IFDIR; 41 inode->i_mode |= S_IFDIR;
42 inode->i_nlink = 0; 42 clear_nlink(inode);
43 inode->i_op = &proc_sys_dir_operations; 43 inode->i_op = &proc_sys_dir_operations;
44 inode->i_fop = &proc_sys_dir_file_operations; 44 inode->i_fop = &proc_sys_dir_file_operations;
45 } 45 }
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 9b0d4b78b4fb..c425441c6942 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1444,7 +1444,7 @@ void reiserfs_read_locked_inode(struct inode *inode,
1444 /* a stale NFS handle can trigger this without it being an error */ 1444 /* a stale NFS handle can trigger this without it being an error */
1445 pathrelse(&path_to_sd); 1445 pathrelse(&path_to_sd);
1446 reiserfs_make_bad_inode(inode); 1446 reiserfs_make_bad_inode(inode);
1447 inode->i_nlink = 0; 1447 clear_nlink(inode);
1448 return; 1448 return;
1449 } 1449 }
1450 1450
@@ -1987,7 +1987,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1987 make_bad_inode(inode); 1987 make_bad_inode(inode);
1988 1988
1989 out_inserted_sd: 1989 out_inserted_sd:
1990 inode->i_nlink = 0; 1990 clear_nlink(inode);
1991 th->t_trans_id = 0; /* so the caller can't use this handle later */ 1991 th->t_trans_id = 0; /* so the caller can't use this handle later */
1992 unlock_new_inode(inode); /* OK to do even if we hadn't locked it */ 1992 unlock_new_inode(inode); /* OK to do even if we hadn't locked it */
1993 iput(inode); 1993 iput(inode);
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index ef392324bbf1..6ce332821633 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -622,7 +622,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
622 dentry->d_name.len, inode, 1 /*visible */ ); 622 dentry->d_name.len, inode, 1 /*visible */ );
623 if (retval) { 623 if (retval) {
624 int err; 624 int err;
625 inode->i_nlink--; 625 drop_nlink(inode);
626 reiserfs_update_sd(&th, inode); 626 reiserfs_update_sd(&th, inode);
627 err = journal_end(&th, dir->i_sb, jbegin_count); 627 err = journal_end(&th, dir->i_sb, jbegin_count);
628 if (err) 628 if (err)
@@ -702,7 +702,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
702 dentry->d_name.len, inode, 1 /*visible */ ); 702 dentry->d_name.len, inode, 1 /*visible */ );
703 if (retval) { 703 if (retval) {
704 int err; 704 int err;
705 inode->i_nlink--; 705 drop_nlink(inode);
706 reiserfs_update_sd(&th, inode); 706 reiserfs_update_sd(&th, inode);
707 err = journal_end(&th, dir->i_sb, jbegin_count); 707 err = journal_end(&th, dir->i_sb, jbegin_count);
708 if (err) 708 if (err)
@@ -787,7 +787,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
787 dentry->d_name.len, inode, 1 /*visible */ ); 787 dentry->d_name.len, inode, 1 /*visible */ );
788 if (retval) { 788 if (retval) {
789 int err; 789 int err;
790 inode->i_nlink = 0; 790 clear_nlink(inode);
791 DEC_DIR_INODE_NLINK(dir); 791 DEC_DIR_INODE_NLINK(dir);
792 reiserfs_update_sd(&th, inode); 792 reiserfs_update_sd(&th, inode);
793 err = journal_end(&th, dir->i_sb, jbegin_count); 793 err = journal_end(&th, dir->i_sb, jbegin_count);
@@ -1086,7 +1086,7 @@ static int reiserfs_symlink(struct inode *parent_dir,
1086 dentry->d_name.len, inode, 1 /*visible */ ); 1086 dentry->d_name.len, inode, 1 /*visible */ );
1087 if (retval) { 1087 if (retval) {
1088 int err; 1088 int err;
1089 inode->i_nlink--; 1089 drop_nlink(inode);
1090 reiserfs_update_sd(&th, inode); 1090 reiserfs_update_sd(&th, inode);
1091 err = journal_end(&th, parent_dir->i_sb, jbegin_count); 1091 err = journal_end(&th, parent_dir->i_sb, jbegin_count);
1092 if (err) 1092 if (err)
@@ -1129,7 +1129,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
1129 1129
1130 retval = journal_begin(&th, dir->i_sb, jbegin_count); 1130 retval = journal_begin(&th, dir->i_sb, jbegin_count);
1131 if (retval) { 1131 if (retval) {
1132 inode->i_nlink--; 1132 drop_nlink(inode);
1133 reiserfs_write_unlock(dir->i_sb); 1133 reiserfs_write_unlock(dir->i_sb);
1134 return retval; 1134 return retval;
1135 } 1135 }
@@ -1144,7 +1144,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
1144 1144
1145 if (retval) { 1145 if (retval) {
1146 int err; 1146 int err;
1147 inode->i_nlink--; 1147 drop_nlink(inode);
1148 err = journal_end(&th, dir->i_sb, jbegin_count); 1148 err = journal_end(&th, dir->i_sb, jbegin_count);
1149 reiserfs_write_unlock(dir->i_sb); 1149 reiserfs_write_unlock(dir->i_sb);
1150 return err ? err : retval; 1150 return err ? err : retval;
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 16f19f55e63f..993adc8f1c87 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -558,7 +558,7 @@ int ubifs_removexattr(struct dentry *dentry, const char *name)
558 } 558 }
559 559
560 ubifs_assert(inode->i_nlink == 1); 560 ubifs_assert(inode->i_nlink == 1);
561 inode->i_nlink = 0; 561 clear_nlink(inode);
562 err = remove_xattr(c, host, inode, &nm); 562 err = remove_xattr(c, host, inode, &nm);
563 if (err) 563 if (err)
564 inode->i_nlink = 1; 564 inode->i_nlink = 1;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index f1dce848ef96..e8d61b114c1b 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -577,8 +577,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
577 577
578 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); 578 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
579 if (!fi) { 579 if (!fi) {
580 inode->i_nlink--; 580 inode_dec_link_count(inode);
581 mark_inode_dirty(inode);
582 iput(inode); 581 iput(inode);
583 return err; 582 return err;
584 } 583 }
@@ -618,8 +617,7 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
618 init_special_inode(inode, mode, rdev); 617 init_special_inode(inode, mode, rdev);
619 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); 618 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
620 if (!fi) { 619 if (!fi) {
621 inode->i_nlink--; 620 inode_dec_link_count(inode);
622 mark_inode_dirty(inode);
623 iput(inode); 621 iput(inode);
624 return err; 622 return err;
625 } 623 }
@@ -665,8 +663,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
665 inode->i_fop = &udf_dir_operations; 663 inode->i_fop = &udf_dir_operations;
666 fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); 664 fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err);
667 if (!fi) { 665 if (!fi) {
668 inode->i_nlink--; 666 inode_dec_link_count(inode);
669 mark_inode_dirty(inode);
670 iput(inode); 667 iput(inode);
671 goto out; 668 goto out;
672 } 669 }
@@ -683,7 +680,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
683 680
684 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); 681 fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
685 if (!fi) { 682 if (!fi) {
686 inode->i_nlink = 0; 683 clear_nlink(inode);
687 mark_inode_dirty(inode); 684 mark_inode_dirty(inode);
688 iput(inode); 685 iput(inode);
689 goto out; 686 goto out;
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index 2eabf04af3de..78a4c70d46b5 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -341,7 +341,7 @@ cg_found:
341 341
342fail_remove_inode: 342fail_remove_inode:
343 unlock_super(sb); 343 unlock_super(sb);
344 inode->i_nlink = 0; 344 clear_nlink(inode);
345 iput(inode); 345 iput(inode);
346 UFSD("EXIT (FAILED): err %d\n", err); 346 UFSD("EXIT (FAILED): err %d\n", err);
347 return ERR_PTR(err); 347 return ERR_PTR(err);