aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2011-10-28 08:13:29 -0400
committerChristoph Hellwig <hch@serles.lst.de>2011-11-02 07:53:43 -0400
commitbfe8684869601dacfcb2cd69ef8cfd9045f62170 (patch)
tree4e213aaa766b26f43f0f9ec7998a7745239d9377 /fs
parent6d6b77f163c7eabedbba00ed2abb7d4a570bff76 (diff)
filesystems: add set_nlink()
Replace remaining direct i_nlink updates with a new set_nlink() updater function. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Tested-by: Toshiyuki Okajima <toshi.okajima@jp.fujitsu.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/vfs_inode.c4
-rw-r--r--fs/9p/vfs_inode_dotl.c4
-rw-r--r--fs/adfs/inode.c2
-rw-r--r--fs/affs/amigaffs.c2
-rw-r--r--fs/affs/inode.c8
-rw-r--r--fs/afs/fsclient.c2
-rw-r--r--fs/afs/inode.c4
-rw-r--r--fs/autofs4/inode.c2
-rw-r--r--fs/befs/linuxvfs.c2
-rw-r--r--fs/bfs/dir.c2
-rw-r--r--fs/bfs/inode.c2
-rw-r--r--fs/btrfs/delayed-inode.c2
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/btrfs/inode.c4
-rw-r--r--fs/btrfs/tree-log.c2
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/ceph/inode.c2
-rw-r--r--fs/cifs/inode.c6
-rw-r--r--fs/coda/coda_linux.c2
-rw-r--r--fs/devpts/inode.c2
-rw-r--r--fs/ecryptfs/inode.c12
-rw-r--r--fs/efs/inode.c2
-rw-r--r--fs/exofs/inode.c2
-rw-r--r--fs/ext2/inode.c2
-rw-r--r--fs/ext3/inode.c2
-rw-r--r--fs/ext3/namei.c4
-rw-r--r--fs/ext4/inode.c2
-rw-r--r--fs/ext4/namei.c6
-rw-r--r--fs/fat/inode.c4
-rw-r--r--fs/fat/namei_msdos.c2
-rw-r--r--fs/fat/namei_vfat.c2
-rw-r--r--fs/freevxfs/vxfs_inode.c2
-rw-r--r--fs/fuse/control.c2
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/gfs2/glops.c2
-rw-r--r--fs/hfs/inode.c4
-rw-r--r--fs/hfsplus/inode.c10
-rw-r--r--fs/hostfs/hostfs_kern.c2
-rw-r--r--fs/hpfs/dir.c2
-rw-r--r--fs/hpfs/inode.c8
-rw-r--r--fs/hpfs/namei.c8
-rw-r--r--fs/hppfs/hppfs.c2
-rw-r--r--fs/isofs/inode.c4
-rw-r--r--fs/isofs/rock.c4
-rw-r--r--fs/jffs2/dir.c6
-rw-r--r--fs/jffs2/fs.c6
-rw-r--r--fs/jfs/jfs_imap.c6
-rw-r--r--fs/jfs/namei.c2
-rw-r--r--fs/libfs.c2
-rw-r--r--fs/logfs/readwrite.c2
-rw-r--r--fs/minix/inode.c4
-rw-r--r--fs/ncpfs/inode.c2
-rw-r--r--fs/nfs/inode.c4
-rw-r--r--fs/nilfs2/inode.c2
-rw-r--r--fs/nilfs2/namei.c2
-rw-r--r--fs/ntfs/inode.c8
-rw-r--r--fs/ocfs2/dir.c4
-rw-r--r--fs/ocfs2/dlmglue.c2
-rw-r--r--fs/ocfs2/inode.c4
-rw-r--r--fs/ocfs2/namei.c8
-rw-r--r--fs/openpromfs/inode.c4
-rw-r--r--fs/proc/base.c12
-rw-r--r--fs/proc/generic.c2
-rw-r--r--fs/proc/inode.c2
-rw-r--r--fs/qnx4/inode.c2
-rw-r--r--fs/reiserfs/inode.c6
-rw-r--r--fs/reiserfs/namei.c4
-rw-r--r--fs/romfs/super.c2
-rw-r--r--fs/squashfs/inode.c18
-rw-r--r--fs/stack.c2
-rw-r--r--fs/sysfs/inode.c2
-rw-r--r--fs/sysv/inode.c2
-rw-r--r--fs/ubifs/super.c2
-rw-r--r--fs/ubifs/xattr.c2
-rw-r--r--fs/udf/inode.c8
-rw-r--r--fs/udf/namei.c4
-rw-r--r--fs/ufs/inode.c4
-rw-r--r--fs/xfs/xfs_iops.c2
78 files changed, 148 insertions, 146 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index b5a1076aaa6c..879ed8851737 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1138,7 +1138,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
1138 struct v9fs_session_info *v9ses = sb->s_fs_info; 1138 struct v9fs_session_info *v9ses = sb->s_fs_info;
1139 struct v9fs_inode *v9inode = V9FS_I(inode); 1139 struct v9fs_inode *v9inode = V9FS_I(inode);
1140 1140
1141 inode->i_nlink = 1; 1141 set_nlink(inode, 1);
1142 1142
1143 inode->i_atime.tv_sec = stat->atime; 1143 inode->i_atime.tv_sec = stat->atime;
1144 inode->i_mtime.tv_sec = stat->mtime; 1144 inode->i_mtime.tv_sec = stat->mtime;
@@ -1164,7 +1164,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
1164 /* HARDLINKCOUNT %u */ 1164 /* HARDLINKCOUNT %u */
1165 sscanf(ext, "%13s %u", tag_name, &i_nlink); 1165 sscanf(ext, "%13s %u", tag_name, &i_nlink);
1166 if (!strncmp(tag_name, "HARDLINKCOUNT", 13)) 1166 if (!strncmp(tag_name, "HARDLINKCOUNT", 13))
1167 inode->i_nlink = i_nlink; 1167 set_nlink(inode, i_nlink);
1168 } 1168 }
1169 } 1169 }
1170 mode = stat->mode & S_IALLUGO; 1170 mode = stat->mode & S_IALLUGO;
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index aded79fcd5cf..0b5745e21946 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -606,7 +606,7 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
606 inode->i_ctime.tv_nsec = stat->st_ctime_nsec; 606 inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
607 inode->i_uid = stat->st_uid; 607 inode->i_uid = stat->st_uid;
608 inode->i_gid = stat->st_gid; 608 inode->i_gid = stat->st_gid;
609 inode->i_nlink = stat->st_nlink; 609 set_nlink(inode, stat->st_nlink);
610 610
611 mode = stat->st_mode & S_IALLUGO; 611 mode = stat->st_mode & S_IALLUGO;
612 mode |= inode->i_mode & ~S_IALLUGO; 612 mode |= inode->i_mode & ~S_IALLUGO;
@@ -632,7 +632,7 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
632 if (stat->st_result_mask & P9_STATS_GID) 632 if (stat->st_result_mask & P9_STATS_GID)
633 inode->i_gid = stat->st_gid; 633 inode->i_gid = stat->st_gid;
634 if (stat->st_result_mask & P9_STATS_NLINK) 634 if (stat->st_result_mask & P9_STATS_NLINK)
635 inode->i_nlink = stat->st_nlink; 635 set_nlink(inode, stat->st_nlink);
636 if (stat->st_result_mask & P9_STATS_MODE) { 636 if (stat->st_result_mask & P9_STATS_MODE) {
637 inode->i_mode = stat->st_mode; 637 inode->i_mode = stat->st_mode;
638 if ((S_ISBLK(inode->i_mode)) || 638 if ((S_ISBLK(inode->i_mode)) ||
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index d5250c5aae21..1dab6a174d6a 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -247,7 +247,7 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
247 inode->i_gid = ADFS_SB(sb)->s_gid; 247 inode->i_gid = ADFS_SB(sb)->s_gid;
248 inode->i_ino = obj->file_id; 248 inode->i_ino = obj->file_id;
249 inode->i_size = obj->size; 249 inode->i_size = obj->size;
250 inode->i_nlink = 2; 250 set_nlink(inode, 2);
251 inode->i_blocks = (inode->i_size + sb->s_blocksize - 1) >> 251 inode->i_blocks = (inode->i_size + sb->s_blocksize - 1) >>
252 sb->s_blocksize_bits; 252 sb->s_blocksize_bits;
253 253
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 8f12723bbc97..de37ec842340 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -215,7 +215,7 @@ affs_remove_link(struct dentry *dentry)
215 break; 215 break;
216 default: 216 default:
217 if (!AFFS_TAIL(sb, bh)->link_chain) 217 if (!AFFS_TAIL(sb, bh)->link_chain)
218 inode->i_nlink = 1; 218 set_nlink(inode, 1);
219 } 219 }
220 affs_free_block(sb, link_ino); 220 affs_free_block(sb, link_ino);
221 goto done; 221 goto done;
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 5d828903ac69..88a4b0b50058 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -54,7 +54,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
54 prot = be32_to_cpu(tail->protect); 54 prot = be32_to_cpu(tail->protect);
55 55
56 inode->i_size = 0; 56 inode->i_size = 0;
57 inode->i_nlink = 1; 57 set_nlink(inode, 1);
58 inode->i_mode = 0; 58 inode->i_mode = 0;
59 AFFS_I(inode)->i_extcnt = 1; 59 AFFS_I(inode)->i_extcnt = 1;
60 AFFS_I(inode)->i_ext_last = ~1; 60 AFFS_I(inode)->i_ext_last = ~1;
@@ -137,7 +137,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
137 sbi->s_hashsize + 1; 137 sbi->s_hashsize + 1;
138 } 138 }
139 if (tail->link_chain) 139 if (tail->link_chain)
140 inode->i_nlink = 2; 140 set_nlink(inode, 2);
141 inode->i_mapping->a_ops = (sbi->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops; 141 inode->i_mapping->a_ops = (sbi->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops;
142 inode->i_op = &affs_file_inode_operations; 142 inode->i_op = &affs_file_inode_operations;
143 inode->i_fop = &affs_file_operations; 143 inode->i_fop = &affs_file_operations;
@@ -304,7 +304,7 @@ affs_new_inode(struct inode *dir)
304 inode->i_uid = current_fsuid(); 304 inode->i_uid = current_fsuid();
305 inode->i_gid = current_fsgid(); 305 inode->i_gid = current_fsgid();
306 inode->i_ino = block; 306 inode->i_ino = block;
307 inode->i_nlink = 1; 307 set_nlink(inode, 1);
308 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 308 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
309 atomic_set(&AFFS_I(inode)->i_opencnt, 0); 309 atomic_set(&AFFS_I(inode)->i_opencnt, 0);
310 AFFS_I(inode)->i_blkcnt = 0; 310 AFFS_I(inode)->i_blkcnt = 0;
@@ -387,7 +387,7 @@ affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s3
387 AFFS_TAIL(sb, inode_bh)->link_chain = cpu_to_be32(block); 387 AFFS_TAIL(sb, inode_bh)->link_chain = cpu_to_be32(block);
388 affs_adjust_checksum(inode_bh, block - be32_to_cpu(chain)); 388 affs_adjust_checksum(inode_bh, block - be32_to_cpu(chain));
389 mark_buffer_dirty_inode(inode_bh, inode); 389 mark_buffer_dirty_inode(inode_bh, inode);
390 inode->i_nlink = 2; 390 set_nlink(inode, 2);
391 ihold(inode); 391 ihold(inode);
392 } 392 }
393 affs_fix_checksum(sb, bh); 393 affs_fix_checksum(sb, bh);
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 346e3289abd7..2f213d109c21 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -90,7 +90,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
90 vnode->vfs_inode.i_uid = status->owner; 90 vnode->vfs_inode.i_uid = status->owner;
91 vnode->vfs_inode.i_gid = status->group; 91 vnode->vfs_inode.i_gid = status->group;
92 vnode->vfs_inode.i_generation = vnode->fid.unique; 92 vnode->vfs_inode.i_generation = vnode->fid.unique;
93 vnode->vfs_inode.i_nlink = status->nlink; 93 set_nlink(&vnode->vfs_inode, status->nlink);
94 94
95 mode = vnode->vfs_inode.i_mode; 95 mode = vnode->vfs_inode.i_mode;
96 mode &= ~S_IALLUGO; 96 mode &= ~S_IALLUGO;
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 0fdab6e03d87..d890ae3b2ce6 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -67,7 +67,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)
67 fscache_attr_changed(vnode->cache); 67 fscache_attr_changed(vnode->cache);
68#endif 68#endif
69 69
70 inode->i_nlink = vnode->status.nlink; 70 set_nlink(inode, vnode->status.nlink);
71 inode->i_uid = vnode->status.owner; 71 inode->i_uid = vnode->status.owner;
72 inode->i_gid = 0; 72 inode->i_gid = 0;
73 inode->i_size = vnode->status.size; 73 inode->i_size = vnode->status.size;
@@ -174,7 +174,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
174 inode->i_size = 0; 174 inode->i_size = 0;
175 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; 175 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
176 inode->i_op = &afs_autocell_inode_operations; 176 inode->i_op = &afs_autocell_inode_operations;
177 inode->i_nlink = 2; 177 set_nlink(inode, 2);
178 inode->i_uid = 0; 178 inode->i_uid = 0;
179 inode->i_gid = 0; 179 inode->i_gid = 0;
180 inode->i_ctime.tv_sec = get_seconds(); 180 inode->i_ctime.tv_sec = get_seconds();
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 180fa2425e49..8179f1ab8175 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -342,7 +342,7 @@ struct inode *autofs4_get_inode(struct super_block *sb, mode_t mode)
342 inode->i_ino = get_next_ino(); 342 inode->i_ino = get_next_ino();
343 343
344 if (S_ISDIR(mode)) { 344 if (S_ISDIR(mode)) {
345 inode->i_nlink = 2; 345 set_nlink(inode, 2);
346 inode->i_op = &autofs4_dir_inode_operations; 346 inode->i_op = &autofs4_dir_inode_operations;
347 inode->i_fop = &autofs4_dir_operations; 347 inode->i_fop = &autofs4_dir_operations;
348 } else if (S_ISLNK(mode)) { 348 } else if (S_ISLNK(mode)) {
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 720d885e8dca..8342ca67abcd 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -357,7 +357,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
357 inode->i_gid = befs_sb->mount_opts.use_gid ? 357 inode->i_gid = befs_sb->mount_opts.use_gid ?
358 befs_sb->mount_opts.gid : (gid_t) fs32_to_cpu(sb, raw_inode->gid); 358 befs_sb->mount_opts.gid : (gid_t) fs32_to_cpu(sb, raw_inode->gid);
359 359
360 inode->i_nlink = 1; 360 set_nlink(inode, 1);
361 361
362 /* 362 /*
363 * BEFS's time is 64 bits, but current VFS is 32 bits... 363 * BEFS's time is 64 bits, but current VFS is 32 bits...
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index b14cebfd9047..9cc074019479 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -199,7 +199,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
199 printf("unlinking non-existent file %s:%lu (nlink=%d)\n", 199 printf("unlinking non-existent file %s:%lu (nlink=%d)\n",
200 inode->i_sb->s_id, inode->i_ino, 200 inode->i_sb->s_id, inode->i_ino,
201 inode->i_nlink); 201 inode->i_nlink);
202 inode->i_nlink = 1; 202 set_nlink(inode, 1);
203 } 203 }
204 de->ino = 0; 204 de->ino = 0;
205 mark_buffer_dirty_inode(bh, dir); 205 mark_buffer_dirty_inode(bh, dir);
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index a8e37f81d097..697af5bf70b3 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -78,7 +78,7 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
78 BFS_I(inode)->i_dsk_ino = le16_to_cpu(di->i_ino); 78 BFS_I(inode)->i_dsk_ino = le16_to_cpu(di->i_ino);
79 inode->i_uid = le32_to_cpu(di->i_uid); 79 inode->i_uid = le32_to_cpu(di->i_uid);
80 inode->i_gid = le32_to_cpu(di->i_gid); 80 inode->i_gid = le32_to_cpu(di->i_gid);
81 inode->i_nlink = le32_to_cpu(di->i_nlink); 81 set_nlink(inode, le32_to_cpu(di->i_nlink));
82 inode->i_size = BFS_FILESIZE(di); 82 inode->i_size = BFS_FILESIZE(di);
83 inode->i_blocks = BFS_FILEBLOCKS(di); 83 inode->i_blocks = BFS_FILEBLOCKS(di);
84 inode->i_atime.tv_sec = le32_to_cpu(di->i_atime); 84 inode->i_atime.tv_sec = le32_to_cpu(di->i_atime);
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index b52c672f4c18..ae4d9cd10961 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1641,7 +1641,7 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev)
1641 inode->i_gid = btrfs_stack_inode_gid(inode_item); 1641 inode->i_gid = btrfs_stack_inode_gid(inode_item);
1642 btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item)); 1642 btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item));
1643 inode->i_mode = btrfs_stack_inode_mode(inode_item); 1643 inode->i_mode = btrfs_stack_inode_mode(inode_item);
1644 inode->i_nlink = btrfs_stack_inode_nlink(inode_item); 1644 set_nlink(inode, btrfs_stack_inode_nlink(inode_item));
1645 inode_set_bytes(inode, btrfs_stack_inode_nbytes(inode_item)); 1645 inode_set_bytes(inode, btrfs_stack_inode_nbytes(inode_item));
1646 BTRFS_I(inode)->generation = btrfs_stack_inode_generation(inode_item); 1646 BTRFS_I(inode)->generation = btrfs_stack_inode_generation(inode_item);
1647 BTRFS_I(inode)->sequence = btrfs_stack_inode_sequence(inode_item); 1647 BTRFS_I(inode)->sequence = btrfs_stack_inode_sequence(inode_item);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 07b3ac662e19..07ea91879a91 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1705,7 +1705,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1705 sb->s_bdi = &fs_info->bdi; 1705 sb->s_bdi = &fs_info->bdi;
1706 1706
1707 fs_info->btree_inode->i_ino = BTRFS_BTREE_INODE_OBJECTID; 1707 fs_info->btree_inode->i_ino = BTRFS_BTREE_INODE_OBJECTID;
1708 fs_info->btree_inode->i_nlink = 1; 1708 set_nlink(fs_info->btree_inode, 1);
1709 /* 1709 /*
1710 * we set the i_size on the btree inode to the max possible int. 1710 * we set the i_size on the btree inode to the max possible int.
1711 * the real end of the address space is determined by all of 1711 * the real end of the address space is determined by all of
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b2d004ad66a0..75686a61bd45 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2534,7 +2534,7 @@ static void btrfs_read_locked_inode(struct inode *inode)
2534 inode_item = btrfs_item_ptr(leaf, path->slots[0], 2534 inode_item = btrfs_item_ptr(leaf, path->slots[0],
2535 struct btrfs_inode_item); 2535 struct btrfs_inode_item);
2536 inode->i_mode = btrfs_inode_mode(leaf, inode_item); 2536 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
2537 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item); 2537 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
2538 inode->i_uid = btrfs_inode_uid(leaf, inode_item); 2538 inode->i_uid = btrfs_inode_uid(leaf, inode_item);
2539 inode->i_gid = btrfs_inode_gid(leaf, inode_item); 2539 inode->i_gid = btrfs_inode_gid(leaf, inode_item);
2540 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item)); 2540 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
@@ -6728,7 +6728,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
6728 inode->i_op = &btrfs_dir_inode_operations; 6728 inode->i_op = &btrfs_dir_inode_operations;
6729 inode->i_fop = &btrfs_dir_file_operations; 6729 inode->i_fop = &btrfs_dir_file_operations;
6730 6730
6731 inode->i_nlink = 1; 6731 set_nlink(inode, 1);
6732 btrfs_i_size_write(inode, 0); 6732 btrfs_i_size_write(inode, 0);
6733 6733
6734 err = btrfs_update_inode(trans, new_root, inode); 6734 err = btrfs_update_inode(trans, new_root, inode);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 786639fca067..0618aa39740b 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1030,7 +1030,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
1030 } 1030 }
1031 btrfs_release_path(path); 1031 btrfs_release_path(path);
1032 if (nlink != inode->i_nlink) { 1032 if (nlink != inode->i_nlink) {
1033 inode->i_nlink = nlink; 1033 set_nlink(inode, nlink);
1034 btrfs_update_inode(trans, root, inode); 1034 btrfs_update_inode(trans, root, inode);
1035 } 1035 }
1036 BTRFS_I(inode)->index_cnt = (u64)-1; 1036 BTRFS_I(inode)->index_cnt = (u64)-1;
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index b8731bf3ef1f..15b21e35078a 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2363,7 +2363,7 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2363 } 2363 }
2364 2364
2365 if ((issued & CEPH_CAP_LINK_EXCL) == 0) 2365 if ((issued & CEPH_CAP_LINK_EXCL) == 0)
2366 inode->i_nlink = le32_to_cpu(grant->nlink); 2366 set_nlink(inode, le32_to_cpu(grant->nlink));
2367 2367
2368 if ((issued & CEPH_CAP_XATTR_EXCL) == 0 && grant->xattr_len) { 2368 if ((issued & CEPH_CAP_XATTR_EXCL) == 0 && grant->xattr_len) {
2369 int len = le32_to_cpu(grant->xattr_len); 2369 int len = le32_to_cpu(grant->xattr_len);
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 5dde7d51dc11..1616a0d37cbd 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -618,7 +618,7 @@ static int fill_inode(struct inode *inode,
618 } 618 }
619 619
620 if ((issued & CEPH_CAP_LINK_EXCL) == 0) 620 if ((issued & CEPH_CAP_LINK_EXCL) == 0)
621 inode->i_nlink = le32_to_cpu(info->nlink); 621 set_nlink(inode, le32_to_cpu(info->nlink));
622 622
623 /* be careful with mtime, atime, size */ 623 /* be careful with mtime, atime, size */
624 ceph_decode_timespec(&atime, &info->atime); 624 ceph_decode_timespec(&atime, &info->atime);
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 2c50bd2f65d1..e851d5b8931e 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -132,7 +132,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
132 inode->i_mtime = fattr->cf_mtime; 132 inode->i_mtime = fattr->cf_mtime;
133 inode->i_ctime = fattr->cf_ctime; 133 inode->i_ctime = fattr->cf_ctime;
134 inode->i_rdev = fattr->cf_rdev; 134 inode->i_rdev = fattr->cf_rdev;
135 inode->i_nlink = fattr->cf_nlink; 135 set_nlink(inode, fattr->cf_nlink);
136 inode->i_uid = fattr->cf_uid; 136 inode->i_uid = fattr->cf_uid;
137 inode->i_gid = fattr->cf_gid; 137 inode->i_gid = fattr->cf_gid;
138 138
@@ -905,7 +905,7 @@ struct inode *cifs_root_iget(struct super_block *sb)
905 if (rc && tcon->ipc) { 905 if (rc && tcon->ipc) {
906 cFYI(1, "ipc connection - fake read inode"); 906 cFYI(1, "ipc connection - fake read inode");
907 inode->i_mode |= S_IFDIR; 907 inode->i_mode |= S_IFDIR;
908 inode->i_nlink = 2; 908 set_nlink(inode, 2);
909 inode->i_op = &cifs_ipc_inode_ops; 909 inode->i_op = &cifs_ipc_inode_ops;
910 inode->i_fop = &simple_dir_operations; 910 inode->i_fop = &simple_dir_operations;
911 inode->i_uid = cifs_sb->mnt_uid; 911 inode->i_uid = cifs_sb->mnt_uid;
@@ -1367,7 +1367,7 @@ mkdir_get_info:
1367 /* setting nlink not necessary except in cases where we 1367 /* setting nlink not necessary except in cases where we
1368 * failed to get it from the server or was set bogus */ 1368 * failed to get it from the server or was set bogus */
1369 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) 1369 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
1370 direntry->d_inode->i_nlink = 2; 1370 set_nlink(direntry->d_inode, 2);
1371 1371
1372 mode &= ~current_umask(); 1372 mode &= ~current_umask();
1373 /* must turn on setgid bit if parent dir has it */ 1373 /* must turn on setgid bit if parent dir has it */
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index 2bdbcc11b373..854ace712685 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -104,7 +104,7 @@ void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr)
104 if (attr->va_gid != -1) 104 if (attr->va_gid != -1)
105 inode->i_gid = (gid_t) attr->va_gid; 105 inode->i_gid = (gid_t) attr->va_gid;
106 if (attr->va_nlink != -1) 106 if (attr->va_nlink != -1)
107 inode->i_nlink = attr->va_nlink; 107 set_nlink(inode, attr->va_nlink);
108 if (attr->va_size != -1) 108 if (attr->va_size != -1)
109 inode->i_size = attr->va_size; 109 inode->i_size = attr->va_size;
110 if (attr->va_size != -1) 110 if (attr->va_size != -1)
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index c196e544c64e..d5d5297efe97 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -307,7 +307,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
307 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 307 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
308 inode->i_op = &simple_dir_inode_operations; 308 inode->i_op = &simple_dir_inode_operations;
309 inode->i_fop = &simple_dir_operations; 309 inode->i_fop = &simple_dir_operations;
310 inode->i_nlink = 2; 310 set_nlink(inode, 2);
311 311
312 s->s_root = d_alloc_root(inode); 312 s->s_root = d_alloc_root(inode);
313 if (s->s_root) 313 if (s->s_root)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 11f8582d7218..a36d327f1521 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -474,8 +474,8 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
474 goto out_lock; 474 goto out_lock;
475 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); 475 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
476 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); 476 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
477 old_dentry->d_inode->i_nlink = 477 set_nlink(old_dentry->d_inode,
478 ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink; 478 ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink);
479 i_size_write(new_dentry->d_inode, file_size_save); 479 i_size_write(new_dentry->d_inode, file_size_save);
480out_lock: 480out_lock:
481 unlock_dir(lower_dir_dentry); 481 unlock_dir(lower_dir_dentry);
@@ -499,8 +499,8 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
499 goto out_unlock; 499 goto out_unlock;
500 } 500 }
501 fsstack_copy_attr_times(dir, lower_dir_inode); 501 fsstack_copy_attr_times(dir, lower_dir_inode);
502 dentry->d_inode->i_nlink = 502 set_nlink(dentry->d_inode,
503 ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink; 503 ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink);
504 dentry->d_inode->i_ctime = dir->i_ctime; 504 dentry->d_inode->i_ctime = dir->i_ctime;
505 d_drop(dentry); 505 d_drop(dentry);
506out_unlock: 506out_unlock:
@@ -565,7 +565,7 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
565 goto out; 565 goto out;
566 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); 566 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
567 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); 567 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
568 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; 568 set_nlink(dir, lower_dir_dentry->d_inode->i_nlink);
569out: 569out:
570 unlock_dir(lower_dir_dentry); 570 unlock_dir(lower_dir_dentry);
571 if (!dentry->d_inode) 571 if (!dentry->d_inode)
@@ -588,7 +588,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
588 if (!rc && dentry->d_inode) 588 if (!rc && dentry->d_inode)
589 clear_nlink(dentry->d_inode); 589 clear_nlink(dentry->d_inode);
590 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); 590 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
591 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; 591 set_nlink(dir, lower_dir_dentry->d_inode->i_nlink);
592 unlock_dir(lower_dir_dentry); 592 unlock_dir(lower_dir_dentry);
593 if (!rc) 593 if (!rc)
594 d_drop(dentry); 594 d_drop(dentry);
diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index 9c13412e6c99..bc84f365d75c 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -96,7 +96,7 @@ struct inode *efs_iget(struct super_block *super, unsigned long ino)
96 efs_inode = (struct efs_dinode *) (bh->b_data + offset); 96 efs_inode = (struct efs_dinode *) (bh->b_data + offset);
97 97
98 inode->i_mode = be16_to_cpu(efs_inode->di_mode); 98 inode->i_mode = be16_to_cpu(efs_inode->di_mode);
99 inode->i_nlink = be16_to_cpu(efs_inode->di_nlink); 99 set_nlink(inode, be16_to_cpu(efs_inode->di_nlink));
100 inode->i_uid = (uid_t)be16_to_cpu(efs_inode->di_uid); 100 inode->i_uid = (uid_t)be16_to_cpu(efs_inode->di_uid);
101 inode->i_gid = (gid_t)be16_to_cpu(efs_inode->di_gid); 101 inode->i_gid = (gid_t)be16_to_cpu(efs_inode->di_gid);
102 inode->i_size = be32_to_cpu(efs_inode->di_size); 102 inode->i_size = be32_to_cpu(efs_inode->di_size);
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 3e5f3a6be90a..f6dbf7768ce6 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -1165,7 +1165,7 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
1165 inode->i_mode = le16_to_cpu(fcb.i_mode); 1165 inode->i_mode = le16_to_cpu(fcb.i_mode);
1166 inode->i_uid = le32_to_cpu(fcb.i_uid); 1166 inode->i_uid = le32_to_cpu(fcb.i_uid);
1167 inode->i_gid = le32_to_cpu(fcb.i_gid); 1167 inode->i_gid = le32_to_cpu(fcb.i_gid);
1168 inode->i_nlink = le16_to_cpu(fcb.i_links_count); 1168 set_nlink(inode, le16_to_cpu(fcb.i_links_count));
1169 inode->i_ctime.tv_sec = (signed)le32_to_cpu(fcb.i_ctime); 1169 inode->i_ctime.tv_sec = (signed)le32_to_cpu(fcb.i_ctime);
1170 inode->i_atime.tv_sec = (signed)le32_to_cpu(fcb.i_atime); 1170 inode->i_atime.tv_sec = (signed)le32_to_cpu(fcb.i_atime);
1171 inode->i_mtime.tv_sec = (signed)le32_to_cpu(fcb.i_mtime); 1171 inode->i_mtime.tv_sec = (signed)le32_to_cpu(fcb.i_mtime);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index a8a58f63f07c..91a6945af6d8 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1321,7 +1321,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
1321 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; 1321 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
1322 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; 1322 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
1323 } 1323 }
1324 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); 1324 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
1325 inode->i_size = le32_to_cpu(raw_inode->i_size); 1325 inode->i_size = le32_to_cpu(raw_inode->i_size);
1326 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime); 1326 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
1327 inode->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime); 1327 inode->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime);
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 12661e1deedd..85fe655fe3e0 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -2899,7 +2899,7 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2899 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; 2899 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2900 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; 2900 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2901 } 2901 }
2902 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); 2902 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2903 inode->i_size = le32_to_cpu(raw_inode->i_size); 2903 inode->i_size = le32_to_cpu(raw_inode->i_size);
2904 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime); 2904 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2905 inode->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime); 2905 inode->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime);
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 8a60e3327659..642dc6d66dfd 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1821,7 +1821,7 @@ retry:
1821 de->name_len = 2; 1821 de->name_len = 2;
1822 strcpy (de->name, ".."); 1822 strcpy (de->name, "..");
1823 ext3_set_de_type(dir->i_sb, de, S_IFDIR); 1823 ext3_set_de_type(dir->i_sb, de, S_IFDIR);
1824 inode->i_nlink = 2; 1824 set_nlink(inode, 2);
1825 BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata"); 1825 BUFFER_TRACE(dir_block, "call ext3_journal_dirty_metadata");
1826 err = ext3_journal_dirty_metadata(handle, dir_block); 1826 err = ext3_journal_dirty_metadata(handle, dir_block);
1827 if (err) 1827 if (err)
@@ -2170,7 +2170,7 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry)
2170 ext3_warning (inode->i_sb, "ext3_unlink", 2170 ext3_warning (inode->i_sb, "ext3_unlink",
2171 "Deleting nonexistent file (%lu), %d", 2171 "Deleting nonexistent file (%lu), %d",
2172 inode->i_ino, inode->i_nlink); 2172 inode->i_ino, inode->i_nlink);
2173 inode->i_nlink = 1; 2173 set_nlink(inode, 1);
2174 } 2174 }
2175 retval = ext3_delete_entry(handle, dir, de, bh); 2175 retval = ext3_delete_entry(handle, dir, de, bh);
2176 if (retval) 2176 if (retval)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0defe0bfe019..be6668bbc1b3 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3418,7 +3418,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
3418 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; 3418 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3419 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; 3419 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3420 } 3420 }
3421 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); 3421 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3422 3422
3423 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ 3423 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3424 ei->i_dir_start_lookup = 0; 3424 ei->i_dir_start_lookup = 0;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 4623c082f3b2..5f7fb46293be 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1694,7 +1694,7 @@ static void ext4_inc_count(handle_t *handle, struct inode *inode)
1694 if (is_dx(inode) && inode->i_nlink > 1) { 1694 if (is_dx(inode) && inode->i_nlink > 1) {
1695 /* limit is 16-bit i_links_count */ 1695 /* limit is 16-bit i_links_count */
1696 if (inode->i_nlink >= EXT4_LINK_MAX || inode->i_nlink == 2) { 1696 if (inode->i_nlink >= EXT4_LINK_MAX || inode->i_nlink == 2) {
1697 inode->i_nlink = 1; 1697 set_nlink(inode, 1);
1698 EXT4_SET_RO_COMPAT_FEATURE(inode->i_sb, 1698 EXT4_SET_RO_COMPAT_FEATURE(inode->i_sb,
1699 EXT4_FEATURE_RO_COMPAT_DIR_NLINK); 1699 EXT4_FEATURE_RO_COMPAT_DIR_NLINK);
1700 } 1700 }
@@ -1861,7 +1861,7 @@ retry:
1861 de->name_len = 2; 1861 de->name_len = 2;
1862 strcpy(de->name, ".."); 1862 strcpy(de->name, "..");
1863 ext4_set_de_type(dir->i_sb, de, S_IFDIR); 1863 ext4_set_de_type(dir->i_sb, de, S_IFDIR);
1864 inode->i_nlink = 2; 1864 set_nlink(inode, 2);
1865 BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata"); 1865 BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata");
1866 err = ext4_handle_dirty_metadata(handle, dir, dir_block); 1866 err = ext4_handle_dirty_metadata(handle, dir, dir_block);
1867 if (err) 1867 if (err)
@@ -2214,7 +2214,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
2214 ext4_warning(inode->i_sb, 2214 ext4_warning(inode->i_sb,
2215 "Deleting nonexistent file (%lu), %d", 2215 "Deleting nonexistent file (%lu), %d",
2216 inode->i_ino, inode->i_nlink); 2216 inode->i_ino, inode->i_nlink);
2217 inode->i_nlink = 1; 2217 set_nlink(inode, 1);
2218 } 2218 }
2219 retval = ext4_delete_entry(handle, dir, de, bh); 2219 retval = ext4_delete_entry(handle, dir, de, bh);
2220 if (retval) 2220 if (retval)
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 1726d7303047..808cac7edcfb 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -379,7 +379,7 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
379 return error; 379 return error;
380 MSDOS_I(inode)->mmu_private = inode->i_size; 380 MSDOS_I(inode)->mmu_private = inode->i_size;
381 381
382 inode->i_nlink = fat_subdirs(inode); 382 set_nlink(inode, fat_subdirs(inode));
383 } else { /* not a directory */ 383 } else { /* not a directory */
384 inode->i_generation |= 1; 384 inode->i_generation |= 1;
385 inode->i_mode = fat_make_mode(sbi, de->attr, 385 inode->i_mode = fat_make_mode(sbi, de->attr,
@@ -1233,7 +1233,7 @@ static int fat_read_root(struct inode *inode)
1233 fat_save_attrs(inode, ATTR_DIR); 1233 fat_save_attrs(inode, ATTR_DIR);
1234 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = 0; 1234 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = 0;
1235 inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = 0; 1235 inode->i_mtime.tv_nsec = inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = 0;
1236 inode->i_nlink = fat_subdirs(inode)+2; 1236 set_nlink(inode, fat_subdirs(inode)+2);
1237 1237
1238 return 0; 1238 return 0;
1239} 1239}
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 66e83b845455..216b419f30e2 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -387,7 +387,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode)
387 /* the directory was completed, just return a error */ 387 /* the directory was completed, just return a error */
388 goto out; 388 goto out;
389 } 389 }
390 inode->i_nlink = 2; 390 set_nlink(inode, 2);
391 inode->i_mtime = inode->i_atime = inode->i_ctime = ts; 391 inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
392 /* timestamp is already written, so mark_inode_dirty() is unneeded. */ 392 /* timestamp is already written, so mark_inode_dirty() is unneeded. */
393 393
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index bb3f29c3557b..a87a65663c25 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -900,7 +900,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode)
900 goto out; 900 goto out;
901 } 901 }
902 inode->i_version++; 902 inode->i_version++;
903 inode->i_nlink = 2; 903 set_nlink(inode, 2);
904 inode->i_mtime = inode->i_atime = inode->i_ctime = ts; 904 inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
905 /* timestamp is already written, so mark_inode_dirty() is unneeded. */ 905 /* timestamp is already written, so mark_inode_dirty() is unneeded. */
906 906
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index 1a4311437a8b..7b2af5abe2fa 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -227,7 +227,7 @@ vxfs_iinit(struct inode *ip, struct vxfs_inode_info *vip)
227 ip->i_uid = (uid_t)vip->vii_uid; 227 ip->i_uid = (uid_t)vip->vii_uid;
228 ip->i_gid = (gid_t)vip->vii_gid; 228 ip->i_gid = (gid_t)vip->vii_gid;
229 229
230 ip->i_nlink = vip->vii_nlink; 230 set_nlink(ip, vip->vii_nlink);
231 ip->i_size = vip->vii_size; 231 ip->i_size = vip->vii_size;
232 232
233 ip->i_atime.tv_sec = vip->vii_atime; 233 ip->i_atime.tv_sec = vip->vii_atime;
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 85542a7daf40..42593c587d48 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -231,7 +231,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
231 if (iop) 231 if (iop)
232 inode->i_op = iop; 232 inode->i_op = iop;
233 inode->i_fop = fop; 233 inode->i_fop = fop;
234 inode->i_nlink = nlink; 234 set_nlink(inode, nlink);
235 inode->i_private = fc; 235 inode->i_private = fc;
236 d_add(dentry, inode); 236 d_add(dentry, inode);
237 return dentry; 237 return dentry;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index add96f6ffda5..3e6d72756479 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -151,7 +151,7 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
151 151
152 inode->i_ino = attr->ino; 152 inode->i_ino = attr->ino;
153 inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777); 153 inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
154 inode->i_nlink = attr->nlink; 154 set_nlink(inode, attr->nlink);
155 inode->i_uid = attr->uid; 155 inode->i_uid = attr->uid;
156 inode->i_gid = attr->gid; 156 inode->i_gid = attr->gid;
157 inode->i_blocks = attr->blocks; 157 inode->i_blocks = attr->blocks;
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 78418b4fa857..1656df7aacd2 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -299,7 +299,7 @@ static void gfs2_set_nlink(struct inode *inode, u32 nlink)
299 if (nlink == 0) 299 if (nlink == 0)
300 clear_nlink(inode); 300 clear_nlink(inode);
301 else 301 else
302 inode->i_nlink = nlink; 302 set_nlink(inode, nlink);
303 } 303 }
304} 304}
305 305
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 96a1b625fc74..a1a9fdcd2a00 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -183,7 +183,7 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode)
183 inode->i_mode = mode; 183 inode->i_mode = mode;
184 inode->i_uid = current_fsuid(); 184 inode->i_uid = current_fsuid();
185 inode->i_gid = current_fsgid(); 185 inode->i_gid = current_fsgid();
186 inode->i_nlink = 1; 186 set_nlink(inode, 1);
187 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 187 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
188 HFS_I(inode)->flags = 0; 188 HFS_I(inode)->flags = 0;
189 HFS_I(inode)->rsrc_inode = NULL; 189 HFS_I(inode)->rsrc_inode = NULL;
@@ -313,7 +313,7 @@ static int hfs_read_inode(struct inode *inode, void *data)
313 /* Initialize the inode */ 313 /* Initialize the inode */
314 inode->i_uid = hsb->s_uid; 314 inode->i_uid = hsb->s_uid;
315 inode->i_gid = hsb->s_gid; 315 inode->i_gid = hsb->s_gid;
316 inode->i_nlink = 1; 316 set_nlink(inode, 1);
317 317
318 if (idata->key) 318 if (idata->key)
319 HFS_I(inode)->cat_key = *idata->key; 319 HFS_I(inode)->cat_key = *idata->key;
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 4cc1e3a36ec7..40e1413be4cf 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -391,7 +391,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
391 inode->i_mode = mode; 391 inode->i_mode = mode;
392 inode->i_uid = current_fsuid(); 392 inode->i_uid = current_fsuid();
393 inode->i_gid = current_fsgid(); 393 inode->i_gid = current_fsgid();
394 inode->i_nlink = 1; 394 set_nlink(inode, 1);
395 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 395 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
396 396
397 hip = HFSPLUS_I(inode); 397 hip = HFSPLUS_I(inode);
@@ -512,7 +512,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
512 hfs_bnode_read(fd->bnode, &entry, fd->entryoffset, 512 hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
513 sizeof(struct hfsplus_cat_folder)); 513 sizeof(struct hfsplus_cat_folder));
514 hfsplus_get_perms(inode, &folder->permissions, 1); 514 hfsplus_get_perms(inode, &folder->permissions, 1);
515 inode->i_nlink = 1; 515 set_nlink(inode, 1);
516 inode->i_size = 2 + be32_to_cpu(folder->valence); 516 inode->i_size = 2 + be32_to_cpu(folder->valence);
517 inode->i_atime = hfsp_mt2ut(folder->access_date); 517 inode->i_atime = hfsp_mt2ut(folder->access_date);
518 inode->i_mtime = hfsp_mt2ut(folder->content_mod_date); 518 inode->i_mtime = hfsp_mt2ut(folder->content_mod_date);
@@ -532,11 +532,11 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
532 hfsplus_inode_read_fork(inode, HFSPLUS_IS_RSRC(inode) ? 532 hfsplus_inode_read_fork(inode, HFSPLUS_IS_RSRC(inode) ?
533 &file->rsrc_fork : &file->data_fork); 533 &file->rsrc_fork : &file->data_fork);
534 hfsplus_get_perms(inode, &file->permissions, 0); 534 hfsplus_get_perms(inode, &file->permissions, 0);
535 inode->i_nlink = 1; 535 set_nlink(inode, 1);
536 if (S_ISREG(inode->i_mode)) { 536 if (S_ISREG(inode->i_mode)) {
537 if (file->permissions.dev) 537 if (file->permissions.dev)
538 inode->i_nlink = 538 set_nlink(inode,
539 be32_to_cpu(file->permissions.dev); 539 be32_to_cpu(file->permissions.dev));
540 inode->i_op = &hfsplus_file_inode_operations; 540 inode->i_op = &hfsplus_file_inode_operations;
541 inode->i_fop = &hfsplus_file_operations; 541 inode->i_fop = &hfsplus_file_operations;
542 inode->i_mapping->a_ops = &hfsplus_aops; 542 inode->i_mapping->a_ops = &hfsplus_aops;
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 0d22afdd4611..2f72da5ae686 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -541,7 +541,7 @@ static int read_name(struct inode *ino, char *name)
541 541
542 ino->i_ino = st.ino; 542 ino->i_ino = st.ino;
543 ino->i_mode = st.mode; 543 ino->i_mode = st.mode;
544 ino->i_nlink = st.nlink; 544 set_nlink(ino, st.nlink);
545 ino->i_uid = st.uid; 545 ino->i_uid = st.uid;
546 ino->i_gid = st.gid; 546 ino->i_gid = st.gid;
547 ino->i_atime = st.atime; 547 ino->i_atime = st.atime;
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 96a8ed91cedd..2fa0089a02a8 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -247,7 +247,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, struct name
247 result->i_mode &= ~0111; 247 result->i_mode &= ~0111;
248 result->i_op = &hpfs_file_iops; 248 result->i_op = &hpfs_file_iops;
249 result->i_fop = &hpfs_file_ops; 249 result->i_fop = &hpfs_file_ops;
250 result->i_nlink = 1; 250 set_nlink(result, 1);
251 } 251 }
252 unlock_new_inode(result); 252 unlock_new_inode(result);
253 } 253 }
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index dfe800c8ae38..3b2cec29972b 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -77,7 +77,7 @@ void hpfs_read_inode(struct inode *i)
77 i->i_mode = S_IFLNK | 0777; 77 i->i_mode = S_IFLNK | 0777;
78 i->i_op = &page_symlink_inode_operations; 78 i->i_op = &page_symlink_inode_operations;
79 i->i_data.a_ops = &hpfs_symlink_aops; 79 i->i_data.a_ops = &hpfs_symlink_aops;
80 i->i_nlink = 1; 80 set_nlink(i, 1);
81 i->i_size = ea_size; 81 i->i_size = ea_size;
82 i->i_blocks = 1; 82 i->i_blocks = 1;
83 brelse(bh); 83 brelse(bh);
@@ -101,7 +101,7 @@ void hpfs_read_inode(struct inode *i)
101 } 101 }
102 if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) { 102 if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
103 brelse(bh); 103 brelse(bh);
104 i->i_nlink = 1; 104 set_nlink(i, 1);
105 i->i_size = 0; 105 i->i_size = 0;
106 i->i_blocks = 1; 106 i->i_blocks = 1;
107 init_special_inode(i, mode, 107 init_special_inode(i, mode,
@@ -125,13 +125,13 @@ void hpfs_read_inode(struct inode *i)
125 hpfs_count_dnodes(i->i_sb, hpfs_inode->i_dno, &n_dnodes, &n_subdirs, NULL); 125 hpfs_count_dnodes(i->i_sb, hpfs_inode->i_dno, &n_dnodes, &n_subdirs, NULL);
126 i->i_blocks = 4 * n_dnodes; 126 i->i_blocks = 4 * n_dnodes;
127 i->i_size = 2048 * n_dnodes; 127 i->i_size = 2048 * n_dnodes;
128 i->i_nlink = 2 + n_subdirs; 128 set_nlink(i, 2 + n_subdirs);
129 } else { 129 } else {
130 i->i_mode |= S_IFREG; 130 i->i_mode |= S_IFREG;
131 if (!hpfs_inode->i_ea_mode) i->i_mode &= ~0111; 131 if (!hpfs_inode->i_ea_mode) i->i_mode &= ~0111;
132 i->i_op = &hpfs_file_iops; 132 i->i_op = &hpfs_file_iops;
133 i->i_fop = &hpfs_file_ops; 133 i->i_fop = &hpfs_file_ops;
134 i->i_nlink = 1; 134 set_nlink(i, 1);
135 i->i_size = le32_to_cpu(fnode->file_size); 135 i->i_size = le32_to_cpu(fnode->file_size);
136 i->i_blocks = ((i->i_size + 511) >> 9) + 1; 136 i->i_blocks = ((i->i_size + 511) >> 9) + 1;
137 i->i_data.a_ops = &hpfs_aops; 137 i->i_data.a_ops = &hpfs_aops;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 2df69e2f07cf..ea91fcb0ef9b 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -56,7 +56,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
56 result->i_fop = &hpfs_dir_ops; 56 result->i_fop = &hpfs_dir_ops;
57 result->i_blocks = 4; 57 result->i_blocks = 4;
58 result->i_size = 2048; 58 result->i_size = 2048;
59 result->i_nlink = 2; 59 set_nlink(result, 2);
60 if (dee.read_only) 60 if (dee.read_only)
61 result->i_mode &= ~0222; 61 result->i_mode &= ~0222;
62 62
@@ -150,7 +150,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
150 result->i_mode &= ~0111; 150 result->i_mode &= ~0111;
151 result->i_op = &hpfs_file_iops; 151 result->i_op = &hpfs_file_iops;
152 result->i_fop = &hpfs_file_ops; 152 result->i_fop = &hpfs_file_ops;
153 result->i_nlink = 1; 153 set_nlink(result, 1);
154 hpfs_i(result)->i_parent_dir = dir->i_ino; 154 hpfs_i(result)->i_parent_dir = dir->i_ino;
155 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date)); 155 result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, le32_to_cpu(dee.creation_date));
156 result->i_ctime.tv_nsec = 0; 156 result->i_ctime.tv_nsec = 0;
@@ -242,7 +242,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
242 hpfs_i(result)->i_ea_size = 0; 242 hpfs_i(result)->i_ea_size = 0;
243 result->i_uid = current_fsuid(); 243 result->i_uid = current_fsuid();
244 result->i_gid = current_fsgid(); 244 result->i_gid = current_fsgid();
245 result->i_nlink = 1; 245 set_nlink(result, 1);
246 result->i_size = 0; 246 result->i_size = 0;
247 result->i_blocks = 1; 247 result->i_blocks = 1;
248 init_special_inode(result, mode, rdev); 248 init_special_inode(result, mode, rdev);
@@ -318,7 +318,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
318 result->i_uid = current_fsuid(); 318 result->i_uid = current_fsuid();
319 result->i_gid = current_fsgid(); 319 result->i_gid = current_fsgid();
320 result->i_blocks = 1; 320 result->i_blocks = 1;
321 result->i_nlink = 1; 321 set_nlink(result, 1);
322 result->i_size = strlen(symlink); 322 result->i_size = strlen(symlink);
323 result->i_op = &page_symlink_inode_operations; 323 result->i_op = &page_symlink_inode_operations;
324 result->i_data.a_ops = &hpfs_symlink_aops; 324 result->i_data.a_ops = &hpfs_symlink_aops;
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 970ea987b3f6..f590b1160c6c 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -702,7 +702,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
702 inode->i_ctime = proc_ino->i_ctime; 702 inode->i_ctime = proc_ino->i_ctime;
703 inode->i_ino = proc_ino->i_ino; 703 inode->i_ino = proc_ino->i_ino;
704 inode->i_mode = proc_ino->i_mode; 704 inode->i_mode = proc_ino->i_mode;
705 inode->i_nlink = proc_ino->i_nlink; 705 set_nlink(inode, proc_ino->i_nlink);
706 inode->i_size = proc_ino->i_size; 706 inode->i_size = proc_ino->i_size;
707 inode->i_blocks = proc_ino->i_blocks; 707 inode->i_blocks = proc_ino->i_blocks;
708 708
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index a5d03672d04e..562adabef985 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -1319,7 +1319,7 @@ static int isofs_read_inode(struct inode *inode)
1319 inode->i_mode = S_IFDIR | sbi->s_dmode; 1319 inode->i_mode = S_IFDIR | sbi->s_dmode;
1320 else 1320 else
1321 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; 1321 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
1322 inode->i_nlink = 1; /* 1322 set_nlink(inode, 1); /*
1323 * Set to 1. We know there are 2, but 1323 * Set to 1. We know there are 2, but
1324 * the find utility tries to optimize 1324 * the find utility tries to optimize
1325 * if it is 2, and it screws up. It is 1325 * if it is 2, and it screws up. It is
@@ -1337,7 +1337,7 @@ static int isofs_read_inode(struct inode *inode)
1337 */ 1337 */
1338 inode->i_mode = S_IFREG | S_IRUGO | S_IXUGO; 1338 inode->i_mode = S_IFREG | S_IRUGO | S_IXUGO;
1339 } 1339 }
1340 inode->i_nlink = 1; 1340 set_nlink(inode, 1);
1341 } 1341 }
1342 inode->i_uid = sbi->s_uid; 1342 inode->i_uid = sbi->s_uid;
1343 inode->i_gid = sbi->s_gid; 1343 inode->i_gid = sbi->s_gid;
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 1fbc7de88f50..70e79d0c756a 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -363,7 +363,7 @@ repeat:
363 break; 363 break;
364 case SIG('P', 'X'): 364 case SIG('P', 'X'):
365 inode->i_mode = isonum_733(rr->u.PX.mode); 365 inode->i_mode = isonum_733(rr->u.PX.mode);
366 inode->i_nlink = isonum_733(rr->u.PX.n_links); 366 set_nlink(inode, isonum_733(rr->u.PX.n_links));
367 inode->i_uid = isonum_733(rr->u.PX.uid); 367 inode->i_uid = isonum_733(rr->u.PX.uid);
368 inode->i_gid = isonum_733(rr->u.PX.gid); 368 inode->i_gid = isonum_733(rr->u.PX.gid);
369 break; 369 break;
@@ -496,7 +496,7 @@ repeat:
496 goto out; 496 goto out;
497 } 497 }
498 inode->i_mode = reloc->i_mode; 498 inode->i_mode = reloc->i_mode;
499 inode->i_nlink = reloc->i_nlink; 499 set_nlink(inode, reloc->i_nlink);
500 inode->i_uid = reloc->i_uid; 500 inode->i_uid = reloc->i_uid;
501 inode->i_gid = reloc->i_gid; 501 inode->i_gid = reloc->i_gid;
502 inode->i_rdev = reloc->i_rdev; 502 inode->i_rdev = reloc->i_rdev;
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 9659b7c00468..be6169bd8acd 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -245,7 +245,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry)
245 ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, 245 ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name,
246 dentry->d_name.len, dead_f, now); 246 dentry->d_name.len, dead_f, now);
247 if (dead_f->inocache) 247 if (dead_f->inocache)
248 dentry->d_inode->i_nlink = dead_f->inocache->pino_nlink; 248 set_nlink(dentry->d_inode, dead_f->inocache->pino_nlink);
249 if (!ret) 249 if (!ret)
250 dir_i->i_mtime = dir_i->i_ctime = ITIME(now); 250 dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
251 return ret; 251 return ret;
@@ -278,7 +278,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
278 278
279 if (!ret) { 279 if (!ret) {
280 mutex_lock(&f->sem); 280 mutex_lock(&f->sem);
281 old_dentry->d_inode->i_nlink = ++f->inocache->pino_nlink; 281 set_nlink(old_dentry->d_inode, ++f->inocache->pino_nlink);
282 mutex_unlock(&f->sem); 282 mutex_unlock(&f->sem);
283 d_instantiate(dentry, old_dentry->d_inode); 283 d_instantiate(dentry, old_dentry->d_inode);
284 dir_i->i_mtime = dir_i->i_ctime = ITIME(now); 284 dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
@@ -497,7 +497,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode)
497 f = JFFS2_INODE_INFO(inode); 497 f = JFFS2_INODE_INFO(inode);
498 498
499 /* Directories get nlink 2 at start */ 499 /* Directories get nlink 2 at start */
500 inode->i_nlink = 2; 500 set_nlink(inode, 2);
501 /* but ic->pino_nlink is the parent ino# */ 501 /* but ic->pino_nlink is the parent ino# */
502 f->inocache->pino_nlink = dir_i->i_ino; 502 f->inocache->pino_nlink = dir_i->i_ino;
503 503
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index bbcb9755dd2b..7286e44ac665 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -278,7 +278,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
278 inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime)); 278 inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
279 inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime)); 279 inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
280 280
281 inode->i_nlink = f->inocache->pino_nlink; 281 set_nlink(inode, f->inocache->pino_nlink);
282 282
283 inode->i_blocks = (inode->i_size + 511) >> 9; 283 inode->i_blocks = (inode->i_size + 511) >> 9;
284 284
@@ -291,7 +291,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
291 case S_IFDIR: 291 case S_IFDIR:
292 { 292 {
293 struct jffs2_full_dirent *fd; 293 struct jffs2_full_dirent *fd;
294 inode->i_nlink = 2; /* parent and '.' */ 294 set_nlink(inode, 2); /* parent and '.' */
295 295
296 for (fd=f->dents; fd; fd = fd->next) { 296 for (fd=f->dents; fd; fd = fd->next) {
297 if (fd->type == DT_DIR && fd->ino) 297 if (fd->type == DT_DIR && fd->ino)
@@ -453,7 +453,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r
453 iput(inode); 453 iput(inode);
454 return ERR_PTR(ret); 454 return ERR_PTR(ret);
455 } 455 }
456 inode->i_nlink = 1; 456 set_nlink(inode, 1);
457 inode->i_ino = je32_to_cpu(ri->ino); 457 inode->i_ino = je32_to_cpu(ri->ino);
458 inode->i_mode = jemode_to_cpu(ri->mode); 458 inode->i_mode = jemode_to_cpu(ri->mode);
459 inode->i_gid = je16_to_cpu(ri->gid); 459 inode->i_gid = je16_to_cpu(ri->gid);
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index b78b2f978f04..1b6f15f191b3 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -457,7 +457,7 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
457 /* read the page of fixed disk inode (AIT) in raw mode */ 457 /* read the page of fixed disk inode (AIT) in raw mode */
458 mp = read_metapage(ip, address << sbi->l2nbperpage, PSIZE, 1); 458 mp = read_metapage(ip, address << sbi->l2nbperpage, PSIZE, 1);
459 if (mp == NULL) { 459 if (mp == NULL) {
460 ip->i_nlink = 1; /* Don't want iput() deleting it */ 460 set_nlink(ip, 1); /* Don't want iput() deleting it */
461 iput(ip); 461 iput(ip);
462 return (NULL); 462 return (NULL);
463 } 463 }
@@ -469,7 +469,7 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
469 /* copy on-disk inode to in-memory inode */ 469 /* copy on-disk inode to in-memory inode */
470 if ((copy_from_dinode(dp, ip)) != 0) { 470 if ((copy_from_dinode(dp, ip)) != 0) {
471 /* handle bad return by returning NULL for ip */ 471 /* handle bad return by returning NULL for ip */
472 ip->i_nlink = 1; /* Don't want iput() deleting it */ 472 set_nlink(ip, 1); /* Don't want iput() deleting it */
473 iput(ip); 473 iput(ip);
474 /* release the page */ 474 /* release the page */
475 release_metapage(mp); 475 release_metapage(mp);
@@ -3076,7 +3076,7 @@ static int copy_from_dinode(struct dinode * dip, struct inode *ip)
3076 ip->i_mode |= 0001; 3076 ip->i_mode |= 0001;
3077 } 3077 }
3078 } 3078 }
3079 ip->i_nlink = le32_to_cpu(dip->di_nlink); 3079 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3080 3080
3081 jfs_ip->saved_uid = le32_to_cpu(dip->di_uid); 3081 jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
3082 if (sbi->uid == -1) 3082 if (sbi->uid == -1)
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 94b0a624b85f..a112ad96e474 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -292,7 +292,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
292 goto out3; 292 goto out3;
293 } 293 }
294 294
295 ip->i_nlink = 2; /* for '.' */ 295 set_nlink(ip, 2); /* for '.' */
296 ip->i_op = &jfs_dir_inode_operations; 296 ip->i_op = &jfs_dir_inode_operations;
297 ip->i_fop = &jfs_dir_operations; 297 ip->i_fop = &jfs_dir_operations;
298 298
diff --git a/fs/libfs.c b/fs/libfs.c
index a2c0029cd95f..f6d411eef1e7 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -490,7 +490,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
490 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 490 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
491 inode->i_op = &simple_dir_inode_operations; 491 inode->i_op = &simple_dir_inode_operations;
492 inode->i_fop = &simple_dir_operations; 492 inode->i_fop = &simple_dir_operations;
493 inode->i_nlink = 2; 493 set_nlink(inode, 2);
494 root = d_alloc_root(inode); 494 root = d_alloc_root(inode);
495 if (!root) { 495 if (!root) {
496 iput(inode); 496 iput(inode);
diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c
index d8d09380c7de..2ac4217b7901 100644
--- a/fs/logfs/readwrite.c
+++ b/fs/logfs/readwrite.c
@@ -126,7 +126,7 @@ static void logfs_disk_to_inode(struct logfs_disk_inode *di, struct inode*inode)
126 inode->i_atime = be64_to_timespec(di->di_atime); 126 inode->i_atime = be64_to_timespec(di->di_atime);
127 inode->i_ctime = be64_to_timespec(di->di_ctime); 127 inode->i_ctime = be64_to_timespec(di->di_ctime);
128 inode->i_mtime = be64_to_timespec(di->di_mtime); 128 inode->i_mtime = be64_to_timespec(di->di_mtime);
129 inode->i_nlink = be32_to_cpu(di->di_refcount); 129 set_nlink(inode, be32_to_cpu(di->di_refcount));
130 inode->i_generation = be32_to_cpu(di->di_generation); 130 inode->i_generation = be32_to_cpu(di->di_generation);
131 131
132 switch (inode->i_mode & S_IFMT) { 132 switch (inode->i_mode & S_IFMT) {
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index e7d23e25bf1d..64cdcd662ffc 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -446,7 +446,7 @@ static struct inode *V1_minix_iget(struct inode *inode)
446 inode->i_mode = raw_inode->i_mode; 446 inode->i_mode = raw_inode->i_mode;
447 inode->i_uid = (uid_t)raw_inode->i_uid; 447 inode->i_uid = (uid_t)raw_inode->i_uid;
448 inode->i_gid = (gid_t)raw_inode->i_gid; 448 inode->i_gid = (gid_t)raw_inode->i_gid;
449 inode->i_nlink = raw_inode->i_nlinks; 449 set_nlink(inode, raw_inode->i_nlinks);
450 inode->i_size = raw_inode->i_size; 450 inode->i_size = raw_inode->i_size;
451 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = raw_inode->i_time; 451 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec = raw_inode->i_time;
452 inode->i_mtime.tv_nsec = 0; 452 inode->i_mtime.tv_nsec = 0;
@@ -479,7 +479,7 @@ static struct inode *V2_minix_iget(struct inode *inode)
479 inode->i_mode = raw_inode->i_mode; 479 inode->i_mode = raw_inode->i_mode;
480 inode->i_uid = (uid_t)raw_inode->i_uid; 480 inode->i_uid = (uid_t)raw_inode->i_uid;
481 inode->i_gid = (gid_t)raw_inode->i_gid; 481 inode->i_gid = (gid_t)raw_inode->i_gid;
482 inode->i_nlink = raw_inode->i_nlinks; 482 set_nlink(inode, raw_inode->i_nlinks);
483 inode->i_size = raw_inode->i_size; 483 inode->i_size = raw_inode->i_size;
484 inode->i_mtime.tv_sec = raw_inode->i_mtime; 484 inode->i_mtime.tv_sec = raw_inode->i_mtime;
485 inode->i_atime.tv_sec = raw_inode->i_atime; 485 inode->i_atime.tv_sec = raw_inode->i_atime;
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 202f370526a7..5b5fa33b6b9d 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -228,7 +228,7 @@ static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
228 228
229 DDPRINTK("ncp_read_inode: inode->i_mode = %u\n", inode->i_mode); 229 DDPRINTK("ncp_read_inode: inode->i_mode = %u\n", inode->i_mode);
230 230
231 inode->i_nlink = 1; 231 set_nlink(inode, 1);
232 inode->i_uid = server->m.uid; 232 inode->i_uid = server->m.uid;
233 inode->i_gid = server->m.gid; 233 inode->i_gid = server->m.gid;
234 234
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 1fc715acc2da..c07a55aec838 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -355,7 +355,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
355 | NFS_INO_INVALID_DATA 355 | NFS_INO_INVALID_DATA
356 | NFS_INO_REVAL_PAGECACHE; 356 | NFS_INO_REVAL_PAGECACHE;
357 if (fattr->valid & NFS_ATTR_FATTR_NLINK) 357 if (fattr->valid & NFS_ATTR_FATTR_NLINK)
358 inode->i_nlink = fattr->nlink; 358 set_nlink(inode, fattr->nlink);
359 else if (nfs_server_capable(inode, NFS_CAP_NLINK)) 359 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
360 nfsi->cache_validity |= NFS_INO_INVALID_ATTR; 360 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
361 if (fattr->valid & NFS_ATTR_FATTR_OWNER) 361 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
@@ -1361,7 +1361,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1361 invalid |= NFS_INO_INVALID_ATTR; 1361 invalid |= NFS_INO_INVALID_ATTR;
1362 if (S_ISDIR(inode->i_mode)) 1362 if (S_ISDIR(inode->i_mode))
1363 invalid |= NFS_INO_INVALID_DATA; 1363 invalid |= NFS_INO_INVALID_DATA;
1364 inode->i_nlink = fattr->nlink; 1364 set_nlink(inode, fattr->nlink);
1365 } 1365 }
1366 } else if (server->caps & NFS_CAP_NLINK) 1366 } else if (server->caps & NFS_CAP_NLINK)
1367 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR 1367 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 08ac272b7c28..b50ffb72e5b3 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -396,7 +396,7 @@ int nilfs_read_inode_common(struct inode *inode,
396 inode->i_mode = le16_to_cpu(raw_inode->i_mode); 396 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
397 inode->i_uid = (uid_t)le32_to_cpu(raw_inode->i_uid); 397 inode->i_uid = (uid_t)le32_to_cpu(raw_inode->i_uid);
398 inode->i_gid = (gid_t)le32_to_cpu(raw_inode->i_gid); 398 inode->i_gid = (gid_t)le32_to_cpu(raw_inode->i_gid);
399 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); 399 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
400 inode->i_size = le64_to_cpu(raw_inode->i_size); 400 inode->i_size = le64_to_cpu(raw_inode->i_size);
401 inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime); 401 inode->i_atime.tv_sec = le64_to_cpu(raw_inode->i_mtime);
402 inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime); 402 inode->i_ctime.tv_sec = le64_to_cpu(raw_inode->i_ctime);
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index a3141990061e..768982de10e4 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -289,7 +289,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry)
289 nilfs_warning(inode->i_sb, __func__, 289 nilfs_warning(inode->i_sb, __func__,
290 "deleting nonexistent file (%lu), %d\n", 290 "deleting nonexistent file (%lu), %d\n",
291 inode->i_ino, inode->i_nlink); 291 inode->i_ino, inode->i_nlink);
292 inode->i_nlink = 1; 292 set_nlink(inode, 1);
293 } 293 }
294 err = nilfs_delete_entry(de, page); 294 err = nilfs_delete_entry(de, page);
295 if (err) 295 if (err)
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 1371487da955..97e2dacbc867 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -612,7 +612,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
612 * might be tricky due to vfs interactions. Need to think about this 612 * might be tricky due to vfs interactions. Need to think about this
613 * some more when implementing the unlink command. 613 * some more when implementing the unlink command.
614 */ 614 */
615 vi->i_nlink = le16_to_cpu(m->link_count); 615 set_nlink(vi, le16_to_cpu(m->link_count));
616 /* 616 /*
617 * FIXME: Reparse points can have the directory bit set even though 617 * FIXME: Reparse points can have the directory bit set even though
618 * they would be S_IFLNK. Need to deal with this further below when we 618 * they would be S_IFLNK. Need to deal with this further below when we
@@ -634,7 +634,7 @@ static int ntfs_read_locked_inode(struct inode *vi)
634 vi->i_mode &= ~vol->dmask; 634 vi->i_mode &= ~vol->dmask;
635 /* Things break without this kludge! */ 635 /* Things break without this kludge! */
636 if (vi->i_nlink > 1) 636 if (vi->i_nlink > 1)
637 vi->i_nlink = 1; 637 set_nlink(vi, 1);
638 } else { 638 } else {
639 vi->i_mode |= S_IFREG; 639 vi->i_mode |= S_IFREG;
640 /* Apply the file permissions mask set in the mount options. */ 640 /* Apply the file permissions mask set in the mount options. */
@@ -1242,7 +1242,7 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
1242 vi->i_version = base_vi->i_version; 1242 vi->i_version = base_vi->i_version;
1243 vi->i_uid = base_vi->i_uid; 1243 vi->i_uid = base_vi->i_uid;
1244 vi->i_gid = base_vi->i_gid; 1244 vi->i_gid = base_vi->i_gid;
1245 vi->i_nlink = base_vi->i_nlink; 1245 set_nlink(vi, base_vi->i_nlink);
1246 vi->i_mtime = base_vi->i_mtime; 1246 vi->i_mtime = base_vi->i_mtime;
1247 vi->i_ctime = base_vi->i_ctime; 1247 vi->i_ctime = base_vi->i_ctime;
1248 vi->i_atime = base_vi->i_atime; 1248 vi->i_atime = base_vi->i_atime;
@@ -1508,7 +1508,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1508 vi->i_version = base_vi->i_version; 1508 vi->i_version = base_vi->i_version;
1509 vi->i_uid = base_vi->i_uid; 1509 vi->i_uid = base_vi->i_uid;
1510 vi->i_gid = base_vi->i_gid; 1510 vi->i_gid = base_vi->i_gid;
1511 vi->i_nlink = base_vi->i_nlink; 1511 set_nlink(vi, base_vi->i_nlink);
1512 vi->i_mtime = base_vi->i_mtime; 1512 vi->i_mtime = base_vi->i_mtime;
1513 vi->i_ctime = base_vi->i_ctime; 1513 vi->i_ctime = base_vi->i_ctime;
1514 vi->i_atime = base_vi->i_atime; 1514 vi->i_atime = base_vi->i_atime;
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 8582e3f4f120..e2878b5895fb 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -2292,7 +2292,7 @@ static int ocfs2_fill_new_dir_id(struct ocfs2_super *osb,
2292 ocfs2_journal_dirty(handle, di_bh); 2292 ocfs2_journal_dirty(handle, di_bh);
2293 2293
2294 i_size_write(inode, size); 2294 i_size_write(inode, size);
2295 inode->i_nlink = 2; 2295 set_nlink(inode, 2);
2296 inode->i_blocks = ocfs2_inode_sector_count(inode); 2296 inode->i_blocks = ocfs2_inode_sector_count(inode);
2297 2297
2298 ret = ocfs2_mark_inode_dirty(handle, inode, di_bh); 2298 ret = ocfs2_mark_inode_dirty(handle, inode, di_bh);
@@ -2354,7 +2354,7 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb,
2354 ocfs2_journal_dirty(handle, new_bh); 2354 ocfs2_journal_dirty(handle, new_bh);
2355 2355
2356 i_size_write(inode, inode->i_sb->s_blocksize); 2356 i_size_write(inode, inode->i_sb->s_blocksize);
2357 inode->i_nlink = 2; 2357 set_nlink(inode, 2);
2358 inode->i_blocks = ocfs2_inode_sector_count(inode); 2358 inode->i_blocks = ocfs2_inode_sector_count(inode);
2359 status = ocfs2_mark_inode_dirty(handle, inode, fe_bh); 2359 status = ocfs2_mark_inode_dirty(handle, inode, fe_bh);
2360 if (status < 0) { 2360 if (status < 0) {
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 7642d7ca73e5..e1ed5e502ff2 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2092,7 +2092,7 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
2092 inode->i_uid = be32_to_cpu(lvb->lvb_iuid); 2092 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
2093 inode->i_gid = be32_to_cpu(lvb->lvb_igid); 2093 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
2094 inode->i_mode = be16_to_cpu(lvb->lvb_imode); 2094 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
2095 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink); 2095 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
2096 ocfs2_unpack_timespec(&inode->i_atime, 2096 ocfs2_unpack_timespec(&inode->i_atime,
2097 be64_to_cpu(lvb->lvb_iatime_packed)); 2097 be64_to_cpu(lvb->lvb_iatime_packed));
2098 ocfs2_unpack_timespec(&inode->i_mtime, 2098 ocfs2_unpack_timespec(&inode->i_mtime,
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index b4c8bb6b8d28..a22d2c098890 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -291,7 +291,7 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
291 (unsigned long long)OCFS2_I(inode)->ip_blkno, 291 (unsigned long long)OCFS2_I(inode)->ip_blkno,
292 (unsigned long long)le64_to_cpu(fe->i_blkno)); 292 (unsigned long long)le64_to_cpu(fe->i_blkno));
293 293
294 inode->i_nlink = ocfs2_read_links_count(fe); 294 set_nlink(inode, ocfs2_read_links_count(fe));
295 295
296 trace_ocfs2_populate_inode(OCFS2_I(inode)->ip_blkno, 296 trace_ocfs2_populate_inode(OCFS2_I(inode)->ip_blkno,
297 le32_to_cpu(fe->i_flags)); 297 le32_to_cpu(fe->i_flags));
@@ -1290,7 +1290,7 @@ void ocfs2_refresh_inode(struct inode *inode,
1290 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features); 1290 OCFS2_I(inode)->ip_dyn_features = le16_to_cpu(fe->i_dyn_features);
1291 ocfs2_set_inode_flags(inode); 1291 ocfs2_set_inode_flags(inode);
1292 i_size_write(inode, le64_to_cpu(fe->i_size)); 1292 i_size_write(inode, le64_to_cpu(fe->i_size));
1293 inode->i_nlink = ocfs2_read_links_count(fe); 1293 set_nlink(inode, ocfs2_read_links_count(fe));
1294 inode->i_uid = le32_to_cpu(fe->i_uid); 1294 inode->i_uid = le32_to_cpu(fe->i_uid);
1295 inode->i_gid = le32_to_cpu(fe->i_gid); 1295 inode->i_gid = le32_to_cpu(fe->i_gid);
1296 inode->i_mode = le16_to_cpu(fe->i_mode); 1296 inode->i_mode = le16_to_cpu(fe->i_mode);
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index ea0ecbdda58c..a8b2bfea574e 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -199,7 +199,7 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, int mode)
199 * these are used by the support functions here and in 199 * these are used by the support functions here and in
200 * callers. */ 200 * callers. */
201 if (S_ISDIR(mode)) 201 if (S_ISDIR(mode))
202 inode->i_nlink = 2; 202 set_nlink(inode, 2);
203 inode_init_owner(inode, dir, mode); 203 inode_init_owner(inode, dir, mode);
204 dquot_initialize(inode); 204 dquot_initialize(inode);
205 return inode; 205 return inode;
@@ -2016,7 +2016,7 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
2016 orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data; 2016 orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data;
2017 if (S_ISDIR(inode->i_mode)) 2017 if (S_ISDIR(inode->i_mode))
2018 ocfs2_add_links_count(orphan_fe, 1); 2018 ocfs2_add_links_count(orphan_fe, 1);
2019 orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); 2019 set_nlink(orphan_dir_inode, ocfs2_read_links_count(orphan_fe));
2020 ocfs2_journal_dirty(handle, orphan_dir_bh); 2020 ocfs2_journal_dirty(handle, orphan_dir_bh);
2021 2021
2022 status = __ocfs2_add_entry(handle, orphan_dir_inode, name, 2022 status = __ocfs2_add_entry(handle, orphan_dir_inode, name,
@@ -2114,7 +2114,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb,
2114 orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data; 2114 orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data;
2115 if (S_ISDIR(inode->i_mode)) 2115 if (S_ISDIR(inode->i_mode))
2116 ocfs2_add_links_count(orphan_fe, -1); 2116 ocfs2_add_links_count(orphan_fe, -1);
2117 orphan_dir_inode->i_nlink = ocfs2_read_links_count(orphan_fe); 2117 set_nlink(orphan_dir_inode, ocfs2_read_links_count(orphan_fe));
2118 ocfs2_journal_dirty(handle, orphan_dir_bh); 2118 ocfs2_journal_dirty(handle, orphan_dir_bh);
2119 2119
2120leave: 2120leave:
@@ -2435,7 +2435,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
2435 di = (struct ocfs2_dinode *)di_bh->b_data; 2435 di = (struct ocfs2_dinode *)di_bh->b_data;
2436 le32_add_cpu(&di->i_flags, -OCFS2_ORPHANED_FL); 2436 le32_add_cpu(&di->i_flags, -OCFS2_ORPHANED_FL);
2437 di->i_orphaned_slot = 0; 2437 di->i_orphaned_slot = 0;
2438 inode->i_nlink = 1; 2438 set_nlink(inode, 1);
2439 ocfs2_set_links_count(di, inode->i_nlink); 2439 ocfs2_set_links_count(di, inode->i_nlink);
2440 ocfs2_journal_dirty(handle, di_bh); 2440 ocfs2_journal_dirty(handle, di_bh);
2441 2441
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index a2a5bff774e3..e4e0ff7962e2 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -242,7 +242,7 @@ found:
242 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; 242 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
243 inode->i_op = &openprom_inode_operations; 243 inode->i_op = &openprom_inode_operations;
244 inode->i_fop = &openprom_operations; 244 inode->i_fop = &openprom_operations;
245 inode->i_nlink = 2; 245 set_nlink(inode, 2);
246 break; 246 break;
247 case op_inode_prop: 247 case op_inode_prop:
248 if (!strcmp(dp->name, "options") && (len == 17) && 248 if (!strcmp(dp->name, "options") && (len == 17) &&
@@ -251,7 +251,7 @@ found:
251 else 251 else
252 inode->i_mode = S_IFREG | S_IRUGO; 252 inode->i_mode = S_IFREG | S_IRUGO;
253 inode->i_fop = &openpromfs_prop_ops; 253 inode->i_fop = &openpromfs_prop_ops;
254 inode->i_nlink = 1; 254 set_nlink(inode, 1);
255 inode->i_size = ent_oi->u.prop->length; 255 inode->i_size = ent_oi->u.prop->length;
256 break; 256 break;
257 } 257 }
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8f0087e20e16..851ba3dcdc29 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2248,7 +2248,7 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,
2248 ei = PROC_I(inode); 2248 ei = PROC_I(inode);
2249 inode->i_mode = p->mode; 2249 inode->i_mode = p->mode;
2250 if (S_ISDIR(inode->i_mode)) 2250 if (S_ISDIR(inode->i_mode))
2251 inode->i_nlink = 2; /* Use getattr to fix if necessary */ 2251 set_nlink(inode, 2); /* Use getattr to fix if necessary */
2252 if (p->iop) 2252 if (p->iop)
2253 inode->i_op = p->iop; 2253 inode->i_op = p->iop;
2254 if (p->fop) 2254 if (p->fop)
@@ -2642,7 +2642,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
2642 2642
2643 inode->i_mode = p->mode; 2643 inode->i_mode = p->mode;
2644 if (S_ISDIR(inode->i_mode)) 2644 if (S_ISDIR(inode->i_mode))
2645 inode->i_nlink = 2; 2645 set_nlink(inode, 2);
2646 if (S_ISLNK(inode->i_mode)) 2646 if (S_ISLNK(inode->i_mode))
2647 inode->i_size = 64; 2647 inode->i_size = 64;
2648 if (p->iop) 2648 if (p->iop)
@@ -2981,8 +2981,8 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
2981 inode->i_fop = &proc_tgid_base_operations; 2981 inode->i_fop = &proc_tgid_base_operations;
2982 inode->i_flags|=S_IMMUTABLE; 2982 inode->i_flags|=S_IMMUTABLE;
2983 2983
2984 inode->i_nlink = 2 + pid_entry_count_dirs(tgid_base_stuff, 2984 set_nlink(inode, 2 + pid_entry_count_dirs(tgid_base_stuff,
2985 ARRAY_SIZE(tgid_base_stuff)); 2985 ARRAY_SIZE(tgid_base_stuff)));
2986 2986
2987 d_set_d_op(dentry, &pid_dentry_operations); 2987 d_set_d_op(dentry, &pid_dentry_operations);
2988 2988
@@ -3233,8 +3233,8 @@ static struct dentry *proc_task_instantiate(struct inode *dir,
3233 inode->i_fop = &proc_tid_base_operations; 3233 inode->i_fop = &proc_tid_base_operations;
3234 inode->i_flags|=S_IMMUTABLE; 3234 inode->i_flags|=S_IMMUTABLE;
3235 3235
3236 inode->i_nlink = 2 + pid_entry_count_dirs(tid_base_stuff, 3236 set_nlink(inode, 2 + pid_entry_count_dirs(tid_base_stuff,
3237 ARRAY_SIZE(tid_base_stuff)); 3237 ARRAY_SIZE(tid_base_stuff)));
3238 3238
3239 d_set_d_op(dentry, &pid_dentry_operations); 3239 d_set_d_op(dentry, &pid_dentry_operations);
3240 3240
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 9d99131d0d65..10090d9c7ad5 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -283,7 +283,7 @@ static int proc_getattr(struct vfsmount *mnt, struct dentry *dentry,
283 struct inode *inode = dentry->d_inode; 283 struct inode *inode = dentry->d_inode;
284 struct proc_dir_entry *de = PROC_I(inode)->pde; 284 struct proc_dir_entry *de = PROC_I(inode)->pde;
285 if (de && de->nlink) 285 if (de && de->nlink)
286 inode->i_nlink = de->nlink; 286 set_nlink(inode, de->nlink);
287 287
288 generic_fillattr(inode, stat); 288 generic_fillattr(inode, stat);
289 return 0; 289 return 0;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 7ed72d6c1c6f..7737c5468a40 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -445,7 +445,7 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
445 if (de->size) 445 if (de->size)
446 inode->i_size = de->size; 446 inode->i_size = de->size;
447 if (de->nlink) 447 if (de->nlink)
448 inode->i_nlink = de->nlink; 448 set_nlink(inode, de->nlink);
449 if (de->proc_iops) 449 if (de->proc_iops)
450 inode->i_op = de->proc_iops; 450 inode->i_op = de->proc_iops;
451 if (de->proc_fops) { 451 if (de->proc_fops) {
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 2b0646613f5a..3bdd21418432 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -379,7 +379,7 @@ struct inode *qnx4_iget(struct super_block *sb, unsigned long ino)
379 inode->i_mode = le16_to_cpu(raw_inode->di_mode); 379 inode->i_mode = le16_to_cpu(raw_inode->di_mode);
380 inode->i_uid = (uid_t)le16_to_cpu(raw_inode->di_uid); 380 inode->i_uid = (uid_t)le16_to_cpu(raw_inode->di_uid);
381 inode->i_gid = (gid_t)le16_to_cpu(raw_inode->di_gid); 381 inode->i_gid = (gid_t)le16_to_cpu(raw_inode->di_gid);
382 inode->i_nlink = le16_to_cpu(raw_inode->di_nlink); 382 set_nlink(inode, le16_to_cpu(raw_inode->di_nlink));
383 inode->i_size = le32_to_cpu(raw_inode->di_size); 383 inode->i_size = le32_to_cpu(raw_inode->di_size);
384 inode->i_mtime.tv_sec = le32_to_cpu(raw_inode->di_mtime); 384 inode->i_mtime.tv_sec = le32_to_cpu(raw_inode->di_mtime);
385 inode->i_mtime.tv_nsec = 0; 385 inode->i_mtime.tv_nsec = 0;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index c425441c6942..950f13af0951 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1154,7 +1154,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
1154 set_inode_item_key_version(inode, KEY_FORMAT_3_5); 1154 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
1155 set_inode_sd_version(inode, STAT_DATA_V1); 1155 set_inode_sd_version(inode, STAT_DATA_V1);
1156 inode->i_mode = sd_v1_mode(sd); 1156 inode->i_mode = sd_v1_mode(sd);
1157 inode->i_nlink = sd_v1_nlink(sd); 1157 set_nlink(inode, sd_v1_nlink(sd));
1158 inode->i_uid = sd_v1_uid(sd); 1158 inode->i_uid = sd_v1_uid(sd);
1159 inode->i_gid = sd_v1_gid(sd); 1159 inode->i_gid = sd_v1_gid(sd);
1160 inode->i_size = sd_v1_size(sd); 1160 inode->i_size = sd_v1_size(sd);
@@ -1199,7 +1199,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
1199 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih); 1199 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
1200 1200
1201 inode->i_mode = sd_v2_mode(sd); 1201 inode->i_mode = sd_v2_mode(sd);
1202 inode->i_nlink = sd_v2_nlink(sd); 1202 set_nlink(inode, sd_v2_nlink(sd));
1203 inode->i_uid = sd_v2_uid(sd); 1203 inode->i_uid = sd_v2_uid(sd);
1204 inode->i_size = sd_v2_size(sd); 1204 inode->i_size = sd_v2_size(sd);
1205 inode->i_gid = sd_v2_gid(sd); 1205 inode->i_gid = sd_v2_gid(sd);
@@ -1832,7 +1832,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1832#endif 1832#endif
1833 1833
1834 /* fill stat data */ 1834 /* fill stat data */
1835 inode->i_nlink = (S_ISDIR(mode) ? 2 : 1); 1835 set_nlink(inode, (S_ISDIR(mode) ? 2 : 1));
1836 1836
1837 /* uid and gid must already be set by the caller for quota init */ 1837 /* uid and gid must already be set by the caller for quota init */
1838 1838
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 6ce332821633..80058e8ce361 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -19,7 +19,7 @@
19#include <linux/reiserfs_xattr.h> 19#include <linux/reiserfs_xattr.h>
20#include <linux/quotaops.h> 20#include <linux/quotaops.h>
21 21
22#define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) i->i_nlink=1; } 22#define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) set_nlink(i, 1); }
23#define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i); 23#define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
24 24
25// directory item contains array of entry headers. This performs 25// directory item contains array of entry headers. This performs
@@ -964,7 +964,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
964 reiserfs_warning(inode->i_sb, "reiserfs-7042", 964 reiserfs_warning(inode->i_sb, "reiserfs-7042",
965 "deleting nonexistent file (%lu), %d", 965 "deleting nonexistent file (%lu), %d",
966 inode->i_ino, inode->i_nlink); 966 inode->i_ino, inode->i_nlink);
967 inode->i_nlink = 1; 967 set_nlink(inode, 1);
968 } 968 }
969 969
970 drop_nlink(inode); 970 drop_nlink(inode);
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index 2305e3121cb1..8b4089f30408 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -337,7 +337,7 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)
337 inode->i_metasize = (ROMFH_SIZE + nlen + 1 + ROMFH_PAD) & ROMFH_MASK; 337 inode->i_metasize = (ROMFH_SIZE + nlen + 1 + ROMFH_PAD) & ROMFH_MASK;
338 inode->i_dataoffset = pos + inode->i_metasize; 338 inode->i_dataoffset = pos + inode->i_metasize;
339 339
340 i->i_nlink = 1; /* Hard to decide.. */ 340 set_nlink(i, 1); /* Hard to decide.. */
341 i->i_size = be32_to_cpu(ri.size); 341 i->i_size = be32_to_cpu(ri.size);
342 i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0; 342 i->i_mtime.tv_sec = i->i_atime.tv_sec = i->i_ctime.tv_sec = 0;
343 i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0; 343 i->i_mtime.tv_nsec = i->i_atime.tv_nsec = i->i_ctime.tv_nsec = 0;
diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index 04bebcaa2373..fd7b3b3bda13 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -159,7 +159,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
159 frag_offset = 0; 159 frag_offset = 0;
160 } 160 }
161 161
162 inode->i_nlink = 1; 162 set_nlink(inode, 1);
163 inode->i_size = le32_to_cpu(sqsh_ino->file_size); 163 inode->i_size = le32_to_cpu(sqsh_ino->file_size);
164 inode->i_fop = &generic_ro_fops; 164 inode->i_fop = &generic_ro_fops;
165 inode->i_mode |= S_IFREG; 165 inode->i_mode |= S_IFREG;
@@ -203,7 +203,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
203 } 203 }
204 204
205 xattr_id = le32_to_cpu(sqsh_ino->xattr); 205 xattr_id = le32_to_cpu(sqsh_ino->xattr);
206 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 206 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
207 inode->i_size = le64_to_cpu(sqsh_ino->file_size); 207 inode->i_size = le64_to_cpu(sqsh_ino->file_size);
208 inode->i_op = &squashfs_inode_ops; 208 inode->i_op = &squashfs_inode_ops;
209 inode->i_fop = &generic_ro_fops; 209 inode->i_fop = &generic_ro_fops;
@@ -232,7 +232,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
232 if (err < 0) 232 if (err < 0)
233 goto failed_read; 233 goto failed_read;
234 234
235 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 235 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
236 inode->i_size = le16_to_cpu(sqsh_ino->file_size); 236 inode->i_size = le16_to_cpu(sqsh_ino->file_size);
237 inode->i_op = &squashfs_dir_inode_ops; 237 inode->i_op = &squashfs_dir_inode_ops;
238 inode->i_fop = &squashfs_dir_ops; 238 inode->i_fop = &squashfs_dir_ops;
@@ -257,7 +257,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
257 goto failed_read; 257 goto failed_read;
258 258
259 xattr_id = le32_to_cpu(sqsh_ino->xattr); 259 xattr_id = le32_to_cpu(sqsh_ino->xattr);
260 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 260 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
261 inode->i_size = le32_to_cpu(sqsh_ino->file_size); 261 inode->i_size = le32_to_cpu(sqsh_ino->file_size);
262 inode->i_op = &squashfs_dir_inode_ops; 262 inode->i_op = &squashfs_dir_inode_ops;
263 inode->i_fop = &squashfs_dir_ops; 263 inode->i_fop = &squashfs_dir_ops;
@@ -284,7 +284,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
284 if (err < 0) 284 if (err < 0)
285 goto failed_read; 285 goto failed_read;
286 286
287 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 287 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
288 inode->i_size = le32_to_cpu(sqsh_ino->symlink_size); 288 inode->i_size = le32_to_cpu(sqsh_ino->symlink_size);
289 inode->i_op = &squashfs_symlink_inode_ops; 289 inode->i_op = &squashfs_symlink_inode_ops;
290 inode->i_data.a_ops = &squashfs_symlink_aops; 290 inode->i_data.a_ops = &squashfs_symlink_aops;
@@ -325,7 +325,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
325 inode->i_mode |= S_IFCHR; 325 inode->i_mode |= S_IFCHR;
326 else 326 else
327 inode->i_mode |= S_IFBLK; 327 inode->i_mode |= S_IFBLK;
328 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 328 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
329 rdev = le32_to_cpu(sqsh_ino->rdev); 329 rdev = le32_to_cpu(sqsh_ino->rdev);
330 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev)); 330 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev));
331 331
@@ -349,7 +349,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
349 inode->i_mode |= S_IFBLK; 349 inode->i_mode |= S_IFBLK;
350 xattr_id = le32_to_cpu(sqsh_ino->xattr); 350 xattr_id = le32_to_cpu(sqsh_ino->xattr);
351 inode->i_op = &squashfs_inode_ops; 351 inode->i_op = &squashfs_inode_ops;
352 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 352 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
353 rdev = le32_to_cpu(sqsh_ino->rdev); 353 rdev = le32_to_cpu(sqsh_ino->rdev);
354 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev)); 354 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev));
355 355
@@ -370,7 +370,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
370 inode->i_mode |= S_IFIFO; 370 inode->i_mode |= S_IFIFO;
371 else 371 else
372 inode->i_mode |= S_IFSOCK; 372 inode->i_mode |= S_IFSOCK;
373 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 373 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
374 init_special_inode(inode, inode->i_mode, 0); 374 init_special_inode(inode, inode->i_mode, 0);
375 break; 375 break;
376 } 376 }
@@ -389,7 +389,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
389 inode->i_mode |= S_IFSOCK; 389 inode->i_mode |= S_IFSOCK;
390 xattr_id = le32_to_cpu(sqsh_ino->xattr); 390 xattr_id = le32_to_cpu(sqsh_ino->xattr);
391 inode->i_op = &squashfs_inode_ops; 391 inode->i_op = &squashfs_inode_ops;
392 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 392 set_nlink(inode, le32_to_cpu(sqsh_ino->nlink));
393 init_special_inode(inode, inode->i_mode, 0); 393 init_special_inode(inode, inode->i_mode, 0);
394 break; 394 break;
395 } 395 }
diff --git a/fs/stack.c b/fs/stack.c
index b4f2ab48a61f..9c11519245a6 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -71,6 +71,6 @@ void fsstack_copy_attr_all(struct inode *dest, const struct inode *src)
71 dest->i_ctime = src->i_ctime; 71 dest->i_ctime = src->i_ctime;
72 dest->i_blkbits = src->i_blkbits; 72 dest->i_blkbits = src->i_blkbits;
73 dest->i_flags = src->i_flags; 73 dest->i_flags = src->i_flags;
74 dest->i_nlink = src->i_nlink; 74 set_nlink(dest, src->i_nlink);
75} 75}
76EXPORT_SYMBOL_GPL(fsstack_copy_attr_all); 76EXPORT_SYMBOL_GPL(fsstack_copy_attr_all);
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index e23f28894a3a..c81b22f3ace1 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -218,7 +218,7 @@ static void sysfs_refresh_inode(struct sysfs_dirent *sd, struct inode *inode)
218 } 218 }
219 219
220 if (sysfs_type(sd) == SYSFS_DIR) 220 if (sysfs_type(sd) == SYSFS_DIR)
221 inode->i_nlink = sd->s_dir.subdirs + 2; 221 set_nlink(inode, sd->s_dir.subdirs + 2);
222} 222}
223 223
224int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) 224int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index 0630eb969a28..25ffb3e9a3f8 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -219,7 +219,7 @@ struct inode *sysv_iget(struct super_block *sb, unsigned int ino)
219 inode->i_mode = fs16_to_cpu(sbi, raw_inode->i_mode); 219 inode->i_mode = fs16_to_cpu(sbi, raw_inode->i_mode);
220 inode->i_uid = (uid_t)fs16_to_cpu(sbi, raw_inode->i_uid); 220 inode->i_uid = (uid_t)fs16_to_cpu(sbi, raw_inode->i_uid);
221 inode->i_gid = (gid_t)fs16_to_cpu(sbi, raw_inode->i_gid); 221 inode->i_gid = (gid_t)fs16_to_cpu(sbi, raw_inode->i_gid);
222 inode->i_nlink = fs16_to_cpu(sbi, raw_inode->i_nlink); 222 set_nlink(inode, fs16_to_cpu(sbi, raw_inode->i_nlink));
223 inode->i_size = fs32_to_cpu(sbi, raw_inode->i_size); 223 inode->i_size = fs32_to_cpu(sbi, raw_inode->i_size);
224 inode->i_atime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_atime); 224 inode->i_atime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_atime);
225 inode->i_mtime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_mtime); 225 inode->i_mtime.tv_sec = fs32_to_cpu(sbi, raw_inode->i_mtime);
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index b28121278d46..20403dc5d437 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -129,7 +129,7 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
129 goto out_ino; 129 goto out_ino;
130 130
131 inode->i_flags |= (S_NOCMTIME | S_NOATIME); 131 inode->i_flags |= (S_NOCMTIME | S_NOATIME);
132 inode->i_nlink = le32_to_cpu(ino->nlink); 132 set_nlink(inode, le32_to_cpu(ino->nlink));
133 inode->i_uid = le32_to_cpu(ino->uid); 133 inode->i_uid = le32_to_cpu(ino->uid);
134 inode->i_gid = le32_to_cpu(ino->gid); 134 inode->i_gid = le32_to_cpu(ino->gid);
135 inode->i_atime.tv_sec = (int64_t)le64_to_cpu(ino->atime_sec); 135 inode->i_atime.tv_sec = (int64_t)le64_to_cpu(ino->atime_sec);
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 993adc8f1c87..bf18f7a04544 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -561,7 +561,7 @@ int ubifs_removexattr(struct dentry *dentry, const char *name)
561 clear_nlink(inode); 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 set_nlink(inode, 1);
565 565
566 /* If @i_nlink is 0, 'iput()' will delete the inode */ 566 /* If @i_nlink is 0, 'iput()' will delete the inode */
567 iput(inode); 567 iput(inode);
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1d1358ed80c1..6e73f1d6e93c 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1236,6 +1236,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1236 int offset; 1236 int offset;
1237 struct udf_sb_info *sbi = UDF_SB(inode->i_sb); 1237 struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
1238 struct udf_inode_info *iinfo = UDF_I(inode); 1238 struct udf_inode_info *iinfo = UDF_I(inode);
1239 unsigned int link_count;
1239 1240
1240 fe = (struct fileEntry *)bh->b_data; 1241 fe = (struct fileEntry *)bh->b_data;
1241 efe = (struct extendedFileEntry *)bh->b_data; 1242 efe = (struct extendedFileEntry *)bh->b_data;
@@ -1318,9 +1319,10 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1318 inode->i_mode &= ~sbi->s_umask; 1319 inode->i_mode &= ~sbi->s_umask;
1319 read_unlock(&sbi->s_cred_lock); 1320 read_unlock(&sbi->s_cred_lock);
1320 1321
1321 inode->i_nlink = le16_to_cpu(fe->fileLinkCount); 1322 link_count = le16_to_cpu(fe->fileLinkCount);
1322 if (!inode->i_nlink) 1323 if (!link_count)
1323 inode->i_nlink = 1; 1324 link_count = 1;
1325 set_nlink(inode, link_count);
1324 1326
1325 inode->i_size = le64_to_cpu(fe->informationLength); 1327 inode->i_size = le64_to_cpu(fe->informationLength);
1326 iinfo->i_lenExtents = inode->i_size; 1328 iinfo->i_lenExtents = inode->i_size;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index e8d61b114c1b..f1c64c6a4532 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -667,7 +667,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
667 iput(inode); 667 iput(inode);
668 goto out; 668 goto out;
669 } 669 }
670 inode->i_nlink = 2; 670 set_nlink(inode, 2);
671 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); 671 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
672 cfi.icb.extLocation = cpu_to_lelb(dinfo->i_location); 672 cfi.icb.extLocation = cpu_to_lelb(dinfo->i_location);
673 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 673 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
@@ -837,7 +837,7 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
837 if (!inode->i_nlink) { 837 if (!inode->i_nlink) {
838 udf_debug("Deleting nonexistent file (%lu), %d\n", 838 udf_debug("Deleting nonexistent file (%lu), %d\n",
839 inode->i_ino, inode->i_nlink); 839 inode->i_ino, inode->i_nlink);
840 inode->i_nlink = 1; 840 set_nlink(inode, 1);
841 } 841 }
842 retval = udf_delete_entry(dir, fi, &fibh, &cfi); 842 retval = udf_delete_entry(dir, fi, &fibh, &cfi);
843 if (retval) 843 if (retval)
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index b4d791a83207..879b13436fa4 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -589,7 +589,7 @@ static int ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)
589 * Copy data to the in-core inode. 589 * Copy data to the in-core inode.
590 */ 590 */
591 inode->i_mode = mode = fs16_to_cpu(sb, ufs_inode->ui_mode); 591 inode->i_mode = mode = fs16_to_cpu(sb, ufs_inode->ui_mode);
592 inode->i_nlink = fs16_to_cpu(sb, ufs_inode->ui_nlink); 592 set_nlink(inode, fs16_to_cpu(sb, ufs_inode->ui_nlink));
593 if (inode->i_nlink == 0) { 593 if (inode->i_nlink == 0) {
594 ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino); 594 ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino);
595 return -1; 595 return -1;
@@ -637,7 +637,7 @@ static int ufs2_read_inode(struct inode *inode, struct ufs2_inode *ufs2_inode)
637 * Copy data to the in-core inode. 637 * Copy data to the in-core inode.
638 */ 638 */
639 inode->i_mode = mode = fs16_to_cpu(sb, ufs2_inode->ui_mode); 639 inode->i_mode = mode = fs16_to_cpu(sb, ufs2_inode->ui_mode);
640 inode->i_nlink = fs16_to_cpu(sb, ufs2_inode->ui_nlink); 640 set_nlink(inode, fs16_to_cpu(sb, ufs2_inode->ui_nlink));
641 if (inode->i_nlink == 0) { 641 if (inode->i_nlink == 0) {
642 ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino); 642 ufs_error (sb, "ufs_read_inode", "inode %lu has zero nlink\n", inode->i_ino);
643 return -1; 643 return -1;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 9ba2a07b7343..23ce927973a4 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1153,7 +1153,7 @@ xfs_setup_inode(
1153 hlist_add_fake(&inode->i_hash); 1153 hlist_add_fake(&inode->i_hash);
1154 1154
1155 inode->i_mode = ip->i_d.di_mode; 1155 inode->i_mode = ip->i_d.di_mode;
1156 inode->i_nlink = ip->i_d.di_nlink; 1156 set_nlink(inode, ip->i_d.di_nlink);
1157 inode->i_uid = ip->i_d.di_uid; 1157 inode->i_uid = ip->i_d.di_uid;
1158 inode->i_gid = ip->i_d.di_gid; 1158 inode->i_gid = ip->i_d.di_gid;
1159 1159