aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/autofs4/root.c4
-rw-r--r--fs/cifs/inode.c2
-rw-r--r--fs/ext3/namei.c2
-rw-r--r--fs/fuse/dir.c4
-rw-r--r--fs/hfs/dir.c2
-rw-r--r--fs/hfsplus/dir.c4
-rw-r--r--fs/hpfs/namei.c4
-rw-r--r--fs/jfs/namei.c2
-rw-r--r--fs/msdos/namei.c4
-rw-r--r--fs/nfs/dir.c2
-rw-r--r--fs/qnx4/namei.c2
-rw-r--r--fs/reiserfs/namei.c4
-rw-r--r--fs/udf/namei.c2
-rw-r--r--fs/vfat/namei.c4
-rw-r--r--include/linux/fs.h5
15 files changed, 26 insertions, 21 deletions
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index e21bb466820..c1493524da4 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -638,7 +638,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
638 dput(ino->dentry); 638 dput(ino->dentry);
639 639
640 dentry->d_inode->i_size = 0; 640 dentry->d_inode->i_size = 0;
641 dentry->d_inode->i_nlink = 0; 641 clear_nlink(dentry->d_inode);
642 642
643 dir->i_mtime = CURRENT_TIME; 643 dir->i_mtime = CURRENT_TIME;
644 644
@@ -673,7 +673,7 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
673 } 673 }
674 dput(ino->dentry); 674 dput(ino->dentry);
675 dentry->d_inode->i_size = 0; 675 dentry->d_inode->i_size = 0;
676 dentry->d_inode->i_nlink = 0; 676 clear_nlink(dentry->d_inode);
677 677
678 if (dir->i_nlink) 678 if (dir->i_nlink)
679 drop_nlink(dir); 679 drop_nlink(dir);
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 76b7fb34101..6b90ef98e4c 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -818,7 +818,7 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
818 if (!rc) { 818 if (!rc) {
819 drop_nlink(inode); 819 drop_nlink(inode);
820 i_size_write(direntry->d_inode,0); 820 i_size_write(direntry->d_inode,0);
821 direntry->d_inode->i_nlink = 0; 821 clear_nlink(direntry->d_inode);
822 } 822 }
823 823
824 cifsInode = CIFS_I(direntry->d_inode); 824 cifsInode = CIFS_I(direntry->d_inode);
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index b45c88bd5f7..906731a20f1 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -2045,7 +2045,7 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry)
2045 "empty directory has nlink!=2 (%d)", 2045 "empty directory has nlink!=2 (%d)",
2046 inode->i_nlink); 2046 inode->i_nlink);
2047 inode->i_version++; 2047 inode->i_version++;
2048 inode->i_nlink = 0; 2048 clear_nlink(inode);
2049 /* There's no need to set i_disksize: the fact that i_nlink is 2049 /* There's no need to set i_disksize: the fact that i_nlink is
2050 * zero will ensure that the right thing happens during any 2050 * zero will ensure that the right thing happens during any
2051 * recovery. */ 2051 * recovery. */
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index f85b2a282f1..8605155db17 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -508,7 +508,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry)
508 /* Set nlink to zero so the inode can be cleared, if 508 /* Set nlink to zero so the inode can be cleared, if
509 the inode does have more links this will be 509 the inode does have more links this will be
510 discovered at the next lookup/getattr */ 510 discovered at the next lookup/getattr */
511 inode->i_nlink = 0; 511 clear_nlink(inode);
512 fuse_invalidate_attr(inode); 512 fuse_invalidate_attr(inode);
513 fuse_invalidate_attr(dir); 513 fuse_invalidate_attr(dir);
514 fuse_invalidate_entry_cache(entry); 514 fuse_invalidate_entry_cache(entry);
@@ -534,7 +534,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry)
534 err = req->out.h.error; 534 err = req->out.h.error;
535 fuse_put_request(fc, req); 535 fuse_put_request(fc, req);
536 if (!err) { 536 if (!err) {
537 entry->d_inode->i_nlink = 0; 537 clear_nlink(entry->d_inode);
538 fuse_invalidate_attr(dir); 538 fuse_invalidate_attr(dir);
539 fuse_invalidate_entry_cache(entry); 539 fuse_invalidate_entry_cache(entry);
540 } else if (err == -EINTR) 540 } else if (err == -EINTR)
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index cfef6ad529a..37d681b4f21 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -273,7 +273,7 @@ static int hfs_rmdir(struct inode *dir, struct dentry *dentry)
273 res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name); 273 res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name);
274 if (res) 274 if (res)
275 return res; 275 return res;
276 inode->i_nlink = 0; 276 clear_nlink(inode);
277 inode->i_ctime = CURRENT_TIME_SEC; 277 inode->i_ctime = CURRENT_TIME_SEC;
278 hfs_delete_inode(inode); 278 hfs_delete_inode(inode);
279 mark_inode_dirty(inode); 279 mark_inode_dirty(inode);
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 99b4ed1b87d..7e309751645 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -348,7 +348,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
348 } else 348 } else
349 inode->i_flags |= S_DEAD; 349 inode->i_flags |= S_DEAD;
350 } else 350 } else
351 inode->i_nlink = 0; 351 clear_nlink(inode);
352 inode->i_ctime = CURRENT_TIME_SEC; 352 inode->i_ctime = CURRENT_TIME_SEC;
353 mark_inode_dirty(inode); 353 mark_inode_dirty(inode);
354 354
@@ -387,7 +387,7 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
387 res = hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name); 387 res = hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name);
388 if (res) 388 if (res)
389 return res; 389 return res;
390 inode->i_nlink = 0; 390 clear_nlink(inode);
391 inode->i_ctime = CURRENT_TIME_SEC; 391 inode->i_ctime = CURRENT_TIME_SEC;
392 hfsplus_delete_inode(inode); 392 hfsplus_delete_inode(inode);
393 mark_inode_dirty(inode); 393 mark_inode_dirty(inode);
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 25dd6f81eca..2507e7393f3 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -495,7 +495,7 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
495 break; 495 break;
496 default: 496 default:
497 drop_nlink(dir); 497 drop_nlink(dir);
498 inode->i_nlink = 0; 498 clear_nlink(inode);
499 err = 0; 499 err = 0;
500 } 500 }
501 goto out; 501 goto out;
@@ -590,7 +590,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
590 int r; 590 int r;
591 if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1)) != 2) { 591 if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 1)) != 2) {
592 if ((nde = map_dirent(new_dir, hpfs_i(new_dir)->i_dno, (char *)new_name, new_len, NULL, &qbh1))) { 592 if ((nde = map_dirent(new_dir, hpfs_i(new_dir)->i_dno, (char *)new_name, new_len, NULL, &qbh1))) {
593 new_inode->i_nlink = 0; 593 clear_nlink(new_inode);
594 copy_de(nde, &de); 594 copy_de(nde, &de);
595 memcpy(nde->name, new_name, new_len); 595 memcpy(nde->name, new_name, new_len);
596 hpfs_mark_4buffers_dirty(&qbh1); 596 hpfs_mark_4buffers_dirty(&qbh1);
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 8cef88170aa..b8d16a6aa88 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -414,7 +414,7 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
414 JFS_IP(ip)->acl.flag = 0; 414 JFS_IP(ip)->acl.flag = 0;
415 415
416 /* mark the target directory as deleted */ 416 /* mark the target directory as deleted */
417 ip->i_nlink = 0; 417 clear_nlink(ip);
418 mark_inode_dirty(ip); 418 mark_inode_dirty(ip);
419 419
420 rc = txCommit(tid, 2, &iplist[0], 0); 420 rc = txCommit(tid, 2, &iplist[0], 0);
diff --git a/fs/msdos/namei.c b/fs/msdos/namei.c
index fa868c75590..b0f01b3b053 100644
--- a/fs/msdos/namei.c
+++ b/fs/msdos/namei.c
@@ -345,7 +345,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
345 goto out; 345 goto out;
346 drop_nlink(dir); 346 drop_nlink(dir);
347 347
348 inode->i_nlink = 0; 348 clear_nlink(inode);
349 inode->i_ctime = CURRENT_TIME_SEC; 349 inode->i_ctime = CURRENT_TIME_SEC;
350 fat_detach(inode); 350 fat_detach(inode);
351out: 351out:
@@ -430,7 +430,7 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
430 err = fat_remove_entries(dir, &sinfo); /* and releases bh */ 430 err = fat_remove_entries(dir, &sinfo); /* and releases bh */
431 if (err) 431 if (err)
432 goto out; 432 goto out;
433 inode->i_nlink = 0; 433 clear_nlink(inode);
434 inode->i_ctime = CURRENT_TIME_SEC; 434 inode->i_ctime = CURRENT_TIME_SEC;
435 fat_detach(inode); 435 fat_detach(inode);
436out: 436out:
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 26eecb86f9b..481f8892a91 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1286,7 +1286,7 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry)
1286 error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); 1286 error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name);
1287 /* Ensure the VFS deletes this inode */ 1287 /* Ensure the VFS deletes this inode */
1288 if (error == 0 && dentry->d_inode != NULL) 1288 if (error == 0 && dentry->d_inode != NULL)
1289 dentry->d_inode->i_nlink = 0; 1289 clear_nlink(dentry->d_inode);
1290 nfs_end_data_update(dir); 1290 nfs_end_data_update(dir);
1291 unlock_kernel(); 1291 unlock_kernel();
1292 1292
diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c
index ad5afa4ea8f..733cdf01d64 100644
--- a/fs/qnx4/namei.c
+++ b/fs/qnx4/namei.c
@@ -186,7 +186,7 @@ int qnx4_rmdir(struct inode *dir, struct dentry *dentry)
186 memset(de->di_fname, 0, sizeof de->di_fname); 186 memset(de->di_fname, 0, sizeof de->di_fname);
187 de->di_mode = 0; 187 de->di_mode = 0;
188 mark_buffer_dirty(bh); 188 mark_buffer_dirty(bh);
189 inode->i_nlink = 0; 189 clear_nlink(inode);
190 mark_inode_dirty(inode); 190 mark_inode_dirty(inode);
191 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; 191 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
192 inode_dec_link_count(dir); 192 inode_dec_link_count(dir);
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index cf92e89515f..16e9cff8f15 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -913,7 +913,7 @@ static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
913 reiserfs_warning(inode->i_sb, "%s: empty directory has nlink " 913 reiserfs_warning(inode->i_sb, "%s: empty directory has nlink "
914 "!= 2 (%d)", __FUNCTION__, inode->i_nlink); 914 "!= 2 (%d)", __FUNCTION__, inode->i_nlink);
915 915
916 inode->i_nlink = 0; 916 clear_nlink(inode);
917 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC; 917 inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
918 reiserfs_update_sd(&th, inode); 918 reiserfs_update_sd(&th, inode);
919 919
@@ -1473,7 +1473,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1473 if (new_dentry_inode) { 1473 if (new_dentry_inode) {
1474 // adjust link number of the victim 1474 // adjust link number of the victim
1475 if (S_ISDIR(new_dentry_inode->i_mode)) { 1475 if (S_ISDIR(new_dentry_inode->i_mode)) {
1476 new_dentry_inode->i_nlink = 0; 1476 clear_nlink(new_dentry_inode);
1477 } else { 1477 } else {
1478 drop_nlink(new_dentry_inode); 1478 drop_nlink(new_dentry_inode);
1479 } 1479 }
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index e40c95e6511..73163325e5e 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -876,7 +876,7 @@ static int udf_rmdir(struct inode * dir, struct dentry * dentry)
876 udf_warning(inode->i_sb, "udf_rmdir", 876 udf_warning(inode->i_sb, "udf_rmdir",
877 "empty directory has nlink != 2 (%d)", 877 "empty directory has nlink != 2 (%d)",
878 inode->i_nlink); 878 inode->i_nlink);
879 inode->i_nlink = 0; 879 clear_nlink(inode);
880 inode->i_size = 0; 880 inode->i_size = 0;
881 inode_dec_link_count(inode); 881 inode_dec_link_count(inode);
882 inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); 882 inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb);
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c
index 5846ba2d5d9..edb711ff7b0 100644
--- a/fs/vfat/namei.c
+++ b/fs/vfat/namei.c
@@ -784,7 +784,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
784 goto out; 784 goto out;
785 drop_nlink(dir); 785 drop_nlink(dir);
786 786
787 inode->i_nlink = 0; 787 clear_nlink(inode);
788 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; 788 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
789 fat_detach(inode); 789 fat_detach(inode);
790out: 790out:
@@ -808,7 +808,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
808 err = fat_remove_entries(dir, &sinfo); /* and releases bh */ 808 err = fat_remove_entries(dir, &sinfo); /* and releases bh */
809 if (err) 809 if (err)
810 goto out; 810 goto out;
811 inode->i_nlink = 0; 811 clear_nlink(inode);
812 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; 812 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC;
813 fat_detach(inode); 813 fat_detach(inode);
814out: 814out:
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6a5267da565..3493d2828f7 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1235,6 +1235,11 @@ static inline void drop_nlink(struct inode *inode)
1235 inode->i_nlink--; 1235 inode->i_nlink--;
1236} 1236}
1237 1237
1238static inline void clear_nlink(struct inode *inode)
1239{
1240 inode->i_nlink = 0;
1241}
1242
1238static inline void inode_dec_link_count(struct inode *inode) 1243static inline void inode_dec_link_count(struct inode *inode)
1239{ 1244{
1240 drop_nlink(inode); 1245 drop_nlink(inode);