Commit 6d6b77f1 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Christoph Hellwig

filesystems: add missing nlink wrappers

Replace direct i_nlink updates with the respective updater function
(inc_nlink, drop_nlink, clear_nlink, inode_dec_link_count).
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
parent dd2a981f
...@@ -359,7 +359,7 @@ static struct dentry *hypfs_create_file(struct super_block *sb, ...@@ -359,7 +359,7 @@ static struct dentry *hypfs_create_file(struct super_block *sb,
} else if (mode & S_IFDIR) { } else if (mode & S_IFDIR) {
inode->i_op = &simple_dir_inode_operations; inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations; inode->i_fop = &simple_dir_operations;
parent->d_inode->i_nlink++; inc_nlink(parent->d_inode);
} else } else
BUG(); BUG();
inode->i_private = data; inode->i_private = data;
......
...@@ -1144,7 +1144,7 @@ static void mtdchar_notify_remove(struct mtd_info *mtd) ...@@ -1144,7 +1144,7 @@ static void mtdchar_notify_remove(struct mtd_info *mtd)
if (mtd_ino) { if (mtd_ino) {
/* Destroy the inode if it exists */ /* Destroy the inode if it exists */
mtd_ino->i_nlink = 0; clear_nlink(mtd_ino);
iput(mtd_ino); iput(mtd_ino);
} }
} }
......
...@@ -316,7 +316,7 @@ affs_remove_header(struct dentry *dentry) ...@@ -316,7 +316,7 @@ affs_remove_header(struct dentry *dentry)
if (inode->i_nlink > 1) if (inode->i_nlink > 1)
retval = affs_remove_link(dentry); retval = affs_remove_link(dentry);
else else
inode->i_nlink = 0; clear_nlink(inode);
affs_unlock_link(inode); affs_unlock_link(inode);
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode); mark_inode_dirty(inode);
......
...@@ -277,7 +277,7 @@ affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata ...@@ -277,7 +277,7 @@ affs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata
inode->i_mapping->a_ops = (AFFS_SB(sb)->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops; inode->i_mapping->a_ops = (AFFS_SB(sb)->s_flags & SF_OFS) ? &affs_aops_ofs : &affs_aops;
error = affs_add_entry(dir, inode, dentry, ST_FILE); error = affs_add_entry(dir, inode, dentry, ST_FILE);
if (error) { if (error) {
inode->i_nlink = 0; clear_nlink(inode);
iput(inode); iput(inode);
return error; return error;
} }
...@@ -305,7 +305,7 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -305,7 +305,7 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
error = affs_add_entry(dir, inode, dentry, ST_USERDIR); error = affs_add_entry(dir, inode, dentry, ST_USERDIR);
if (error) { if (error) {
inode->i_nlink = 0; clear_nlink(inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
iput(inode); iput(inode);
return error; return error;
...@@ -392,7 +392,7 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) ...@@ -392,7 +392,7 @@ affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
return 0; return 0;
err: err:
inode->i_nlink = 0; clear_nlink(inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
iput(inode); iput(inode);
return error; return error;
......
...@@ -521,7 +521,7 @@ static void kill_node(Node *e) ...@@ -521,7 +521,7 @@ static void kill_node(Node *e)
write_unlock(&entries_lock); write_unlock(&entries_lock);
if (dentry) { if (dentry) {
dentry->d_inode->i_nlink--; drop_nlink(dentry->d_inode);
d_drop(dentry); d_drop(dentry);
dput(dentry); dput(dentry);
simple_release_fs(&bm_mnt, &entry_count); simple_release_fs(&bm_mnt, &entry_count);
......
...@@ -433,7 +433,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, ...@@ -433,7 +433,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
if (old_file->d_inode) { if (old_file->d_inode) {
cifsInode = CIFS_I(old_file->d_inode); cifsInode = CIFS_I(old_file->d_inode);
if (rc == 0) { if (rc == 0) {
old_file->d_inode->i_nlink++; inc_nlink(old_file->d_inode);
/* BB should we make this contingent on superblock flag NOATIME? */ /* BB should we make this contingent on superblock flag NOATIME? */
/* old_file->d_inode->i_ctime = CURRENT_TIME;*/ /* old_file->d_inode->i_ctime = CURRENT_TIME;*/
/* parent dir timestamps will update from srv /* parent dir timestamps will update from srv
......
...@@ -340,7 +340,7 @@ static int coda_rmdir(struct inode *dir, struct dentry *de) ...@@ -340,7 +340,7 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
if (!error) { if (!error) {
/* VFS may delete the child */ /* VFS may delete the child */
if (de->d_inode) if (de->d_inode)
de->d_inode->i_nlink = 0; clear_nlink(de->d_inode);
/* fix the link count of the parent */ /* fix the link count of the parent */
coda_dir_drop_nlink(dir); coda_dir_drop_nlink(dir);
......
...@@ -549,7 +549,7 @@ void devpts_pty_kill(struct tty_struct *tty) ...@@ -549,7 +549,7 @@ void devpts_pty_kill(struct tty_struct *tty)
dentry = d_find_alias(inode); dentry = d_find_alias(inode);
inode->i_nlink--; drop_nlink(inode);
d_delete(dentry); d_delete(dentry);
dput(dentry); /* d_alloc_name() in devpts_pty_new() */ dput(dentry); /* d_alloc_name() in devpts_pty_new() */
dput(dentry); /* d_find_alias above */ dput(dentry); /* d_find_alias above */
......
...@@ -601,7 +601,7 @@ struct inode *ext2_new_inode(struct inode *dir, int mode, ...@@ -601,7 +601,7 @@ struct inode *ext2_new_inode(struct inode *dir, int mode,
fail_drop: fail_drop:
dquot_drop(inode); dquot_drop(inode);
inode->i_flags |= S_NOQUOTA; inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0; clear_nlink(inode);
unlock_new_inode(inode); unlock_new_inode(inode);
iput(inode); iput(inode);
return ERR_PTR(err); return ERR_PTR(err);
......
...@@ -621,7 +621,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, ...@@ -621,7 +621,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir,
fail_drop: fail_drop:
dquot_drop(inode); dquot_drop(inode);
inode->i_flags |= S_NOQUOTA; inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0; clear_nlink(inode);
unlock_new_inode(inode); unlock_new_inode(inode);
iput(inode); iput(inode);
brelse(bitmap_bh); brelse(bitmap_bh);
......
...@@ -1833,7 +1833,7 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode) ...@@ -1833,7 +1833,7 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode)
if (err) { if (err) {
out_clear_inode: out_clear_inode:
inode->i_nlink = 0; clear_nlink(inode);
unlock_new_inode(inode); unlock_new_inode(inode);
ext3_mark_inode_dirty(handle, inode); ext3_mark_inode_dirty(handle, inode);
iput (inode); iput (inode);
......
...@@ -1084,7 +1084,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode, ...@@ -1084,7 +1084,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode,
fail_drop: fail_drop:
dquot_drop(inode); dquot_drop(inode);
inode->i_flags |= S_NOQUOTA; inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0; clear_nlink(inode);
unlock_new_inode(inode); unlock_new_inode(inode);
iput(inode); iput(inode);
brelse(inode_bitmap_bh); brelse(inode_bitmap_bh);
......
...@@ -507,7 +507,7 @@ int ext4_ext_migrate(struct inode *inode) ...@@ -507,7 +507,7 @@ int ext4_ext_migrate(struct inode *inode)
* Set the i_nlink to zero so it will be deleted later * Set the i_nlink to zero so it will be deleted later
* when we drop inode reference. * when we drop inode reference.
*/ */
tmp_inode->i_nlink = 0; clear_nlink(tmp_inode);
ext4_ext_tree_init(handle, tmp_inode); ext4_ext_tree_init(handle, tmp_inode);
ext4_orphan_add(handle, tmp_inode); ext4_orphan_add(handle, tmp_inode);
......
...@@ -2539,7 +2539,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2539,7 +2539,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
if (new_inode) { if (new_inode) {
/* checked empty_dir above, can't have another parent, /* checked empty_dir above, can't have another parent,
* ext4_dec_count() won't work for many-linked dirs */ * ext4_dec_count() won't work for many-linked dirs */
new_inode->i_nlink = 0; clear_nlink(new_inode);
} else { } else {
ext4_inc_count(handle, new_dir); ext4_inc_count(handle, new_dir);
ext4_update_dx_flag(new_dir); ext4_update_dx_flag(new_dir);
......
...@@ -198,7 +198,7 @@ static int hfs_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -198,7 +198,7 @@ static int hfs_create(struct inode *dir, struct dentry *dentry, int mode,
res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode); res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode);
if (res) { if (res) {
inode->i_nlink = 0; clear_nlink(inode);
hfs_delete_inode(inode); hfs_delete_inode(inode);
iput(inode); iput(inode);
return res; return res;
...@@ -227,7 +227,7 @@ static int hfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -227,7 +227,7 @@ static int hfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode); res = hfs_cat_create(inode->i_ino, dir, &dentry->d_name, inode);
if (res) { if (res) {
inode->i_nlink = 0; clear_nlink(inode);
hfs_delete_inode(inode); hfs_delete_inode(inode);
iput(inode); iput(inode);
return res; return res;
......
...@@ -415,7 +415,7 @@ static int hfsplus_symlink(struct inode *dir, struct dentry *dentry, ...@@ -415,7 +415,7 @@ static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
goto out; goto out;
out_err: out_err:
inode->i_nlink = 0; clear_nlink(inode);
hfsplus_delete_inode(inode); hfsplus_delete_inode(inode);
iput(inode); iput(inode);
out: out:
...@@ -440,7 +440,7 @@ static int hfsplus_mknod(struct inode *dir, struct dentry *dentry, ...@@ -440,7 +440,7 @@ static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,
res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode); res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode);
if (res) { if (res) {
inode->i_nlink = 0; clear_nlink(inode);
hfsplus_delete_inode(inode); hfsplus_delete_inode(inode);
iput(inode); iput(inode);
goto out; goto out;
......
...@@ -53,7 +53,7 @@ void hpfs_read_inode(struct inode *i) ...@@ -53,7 +53,7 @@ void hpfs_read_inode(struct inode *i)
i->i_mode &= ~0111; i->i_mode &= ~0111;
i->i_op = &hpfs_file_iops; i->i_op = &hpfs_file_iops;
i->i_fop = &hpfs_file_ops; i->i_fop = &hpfs_file_ops;
i->i_nlink = 0;*/ clear_nlink(i);*/
make_bad_inode(i); make_bad_inode(i);
return; return;
} }
......
...@@ -970,7 +970,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, ...@@ -970,7 +970,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size,
d_instantiate(path.dentry, inode); d_instantiate(path.dentry, inode);
inode->i_size = size; inode->i_size = size;
inode->i_nlink = 0; clear_nlink(inode);
error = -ENFILE; error = -ENFILE;
file = alloc_file(&path, FMODE_WRITE | FMODE_READ, file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
......
...@@ -157,7 +157,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode) ...@@ -157,7 +157,7 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
dquot_drop(inode); dquot_drop(inode);
inode->i_flags |= S_NOQUOTA; inode->i_flags |= S_NOQUOTA;
fail_unlock: fail_unlock:
inode->i_nlink = 0; clear_nlink(inode);
unlock_new_inode(inode); unlock_new_inode(inode);
fail_put: fail_put:
iput(inode); iput(inode);
......
...@@ -172,7 +172,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, ...@@ -172,7 +172,7 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
mutex_unlock(&JFS_IP(dip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex);
if (rc) { if (rc) {
free_ea_wmap(ip); free_ea_wmap(ip);
ip->i_nlink = 0; clear_nlink(ip);
unlock_new_inode(ip); unlock_new_inode(ip);
iput(ip); iput(ip);
} else { } else {
...@@ -311,7 +311,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) ...@@ -311,7 +311,7 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
mutex_unlock(&JFS_IP(dip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex);
if (rc) { if (rc) {
free_ea_wmap(ip); free_ea_wmap(ip);
ip->i_nlink = 0; clear_nlink(ip);
unlock_new_inode(ip); unlock_new_inode(ip);
iput(ip); iput(ip);
} else { } else {
...@@ -844,7 +844,7 @@ static int jfs_link(struct dentry *old_dentry, ...@@ -844,7 +844,7 @@ static int jfs_link(struct dentry *old_dentry,
rc = txCommit(tid, 2, &iplist[0], 0); rc = txCommit(tid, 2, &iplist[0], 0);
if (rc) { if (rc) {
ip->i_nlink--; /* never instantiated */ drop_nlink(ip); /* never instantiated */
iput(ip); iput(ip);
} else } else
d_instantiate(dentry, ip); d_instantiate(dentry, ip);
...@@ -1048,7 +1048,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, ...@@ -1048,7 +1048,7 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
mutex_unlock(&JFS_IP(dip)->commit_mutex); mutex_unlock(&JFS_IP(dip)->commit_mutex);
if (rc) { if (rc) {
free_ea_wmap(ip); free_ea_wmap(ip);
ip->i_nlink = 0; clear_nlink(ip);
unlock_new_inode(ip); unlock_new_inode(ip);
iput(ip); iput(ip);
} else { } else {
...@@ -1433,7 +1433,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -1433,7 +1433,7 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
mutex_unlock(&JFS_IP(dir)->commit_mutex); mutex_unlock(&JFS_IP(dir)->commit_mutex);
if (rc) { if (rc) {
free_ea_wmap(ip); free_ea_wmap(ip);
ip->i_nlink = 0; clear_nlink(ip);
unlock_new_inode(ip); unlock_new_inode(ip);
iput(ip); iput(ip);
} else { } else {
......
...@@ -197,7 +197,7 @@ static int logfs_remove_inode(struct inode *inode) ...@@ -197,7 +197,7 @@ static int logfs_remove_inode(struct inode *inode)
{ {
int ret; int ret;
inode->i_nlink--; drop_nlink(inode);
ret = write_inode(inode); ret = write_inode(inode);
LOGFS_BUG_ON(ret, inode->i_sb); LOGFS_BUG_ON(ret, inode->i_sb);
return ret; return ret;
...@@ -433,7 +433,7 @@ static int __logfs_create(struct inode *dir, struct dentry *dentry, ...@@ -433,7 +433,7 @@ static int __logfs_create(struct inode *dir, struct dentry *dentry,
ta = kzalloc(sizeof(*ta), GFP_KERNEL); ta = kzalloc(sizeof(*ta), GFP_KERNEL);
if (!ta) { if (!ta) {
inode->i_nlink--; drop_nlink(inode);
iput(inode); iput(inode);
return -ENOMEM; return -ENOMEM;
} }
...@@ -456,7 +456,7 @@ static int __logfs_create(struct inode *dir, struct dentry *dentry, ...@@ -456,7 +456,7 @@ static int __logfs_create(struct inode *dir, struct dentry *dentry,
abort_transaction(inode, ta); abort_transaction(inode, ta);
li->li_flags |= LOGFS_IF_STILLBORN; li->li_flags |= LOGFS_IF_STILLBORN;
/* FIXME: truncate symlink */ /* FIXME: truncate symlink */
inode->i_nlink--; drop_nlink(inode);
iput(inode); iput(inode);
goto out; goto out;
} }
...@@ -563,7 +563,7 @@ static int logfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -563,7 +563,7 @@ static int logfs_link(struct dentry *old_dentry, struct inode *dir,
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME; inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
ihold(inode); ihold(inode);
inode->i_nlink++; inc_nlink(inode);
mark_inode_dirty_sync(inode); mark_inode_dirty_sync(inode);
return __logfs_create(dir, dentry, inode, NULL, 0); return __logfs_create(dir, dentry, inode, NULL, 0);
......
...@@ -93,7 +93,7 @@ static struct inode *__logfs_iget(struct super_block *sb, ino_t ino) ...@@ -93,7 +93,7 @@ static struct inode *__logfs_iget(struct super_block *sb, ino_t ino)
/* inode->i_nlink == 0 can be true when called from /* inode->i_nlink == 0 can be true when called from
* block validator */ * block validator */
/* set i_nlink to 0 to prevent caching */ /* set i_nlink to 0 to prevent caching */
inode->i_nlink = 0; clear_nlink(inode);
logfs_inode(inode)->li_flags |= LOGFS_IF_ZOMBIE; logfs_inode(inode)->li_flags |= LOGFS_IF_ZOMBIE;
iget_failed(inode); iget_failed(inode);
if (!err) if (!err)
......
...@@ -320,7 +320,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr) ...@@ -320,7 +320,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
memset(&inode->i_ctime, 0, sizeof(inode->i_ctime)); memset(&inode->i_ctime, 0, sizeof(inode->i_ctime));
inode->i_version = 0; inode->i_version = 0;
inode->i_size = 0; inode->i_size = 0;
inode->i_nlink = 0; clear_nlink(inode);
inode->i_uid = -2; inode->i_uid = -2;
inode->i_gid = -2; inode->i_gid = -2;
inode->i_blocks = 0; inode->i_blocks = 0;
......
...@@ -354,7 +354,7 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode) ...@@ -354,7 +354,7 @@ struct inode *nilfs_new_inode(struct inode *dir, int mode)
failed_acl: failed_acl:
failed_bmap: failed_bmap:
inode->i_nlink = 0; clear_nlink(inode);
iput(inode); /* raw_inode will be deleted through iput(inode); /* raw_inode will be deleted through
generic_delete_inode() */ generic_delete_inode() */
goto failed; goto failed;
......
...@@ -1377,7 +1377,7 @@ static int ocfs2_rename(struct inode *old_dir, ...@@ -1377,7 +1377,7 @@ static int ocfs2_rename(struct inode *old_dir,
} }
if (new_inode) { if (new_inode) {
new_inode->i_nlink--; drop_nlink(new_inode);
new_inode->i_ctime = CURRENT_TIME; new_inode->i_ctime = CURRENT_TIME;
} }
old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
...@@ -1385,9 +1385,9 @@ static int ocfs2_rename(struct inode *old_dir, ...@@ -1385,9 +1385,9 @@ static int ocfs2_rename(struct inode *old_dir,
if (update_dot_dot) { if (update_dot_dot) {
status = ocfs2_update_entry(old_inode, handle, status = ocfs2_update_entry(old_inode, handle,
&old_inode_dot_dot_res, new_dir); &old_inode_dot_dot_res, new_dir);
old_dir->i_nlink--; drop_nlink(old_dir);
if (new_inode) { if (new_inode) {
new_inode->i_nlink--; drop_nlink(new_inode);
} else { } else {
inc_nlink(new_dir); inc_nlink(new_dir);
mark_inode_dirty(new_dir); mark_inode_dirty(new_dir);
...@@ -2280,7 +2280,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir, ...@@ -2280,7 +2280,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
goto leave; goto leave;
} }
inode->i_nlink = 0; clear_nlink(inode);
/* do the real work now. */ /* do the real work now. */
status = __ocfs2_mknod_locked(dir, inode, status = __ocfs2_mknod_locked(dir, inode,
0, &new_di_bh, parent_di_bh, handle, 0, &new_di_bh, parent_di_bh, handle,
......
...@@ -39,7 +39,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, ...@@ -39,7 +39,7 @@ static struct inode *proc_sys_make_inode(struct super_block *sb,
inode->i_fop = &proc_sys_file_operations; inode->i_fop = &proc_sys_file_operations;
} else { } else {
inode->i_mode |= S_IFDIR; inode->i_mode |= S_IFDIR;
inode->i_nlink = 0; clear_nlink(inode);
inode->i_op = &proc_sys_dir_operations; inode->i_op = &proc_sys_dir_operations;
inode->i_fop = &proc_sys_dir_file_operations; inode->i_fop = &proc_sys_dir_file_operations;
} }
......
...@@ -1444,7 +1444,7 @@ void reiserfs_read_locked_inode(struct inode *inode, ...@@ -1444,7 +1444,7 @@ void reiserfs_read_locked_inode(struct inode *inode,
/* a stale NFS handle can trigger this without it being an error */ /* a stale NFS handle can trigger this without it being an error */
pathrelse(&path_to_sd); pathrelse(&path_to_sd);
reiserfs_make_bad_inode(inode); reiserfs_make_bad_inode(inode);
inode->i_nlink = 0; clear_nlink(inode);
return; return;
} }
...@@ -1987,7 +1987,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, ...@@ -1987,7 +1987,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
make_bad_inode(inode); make_bad_inode(inode);
out_inserted_sd: out_inserted_sd:
inode->i_nlink = 0; clear_nlink(inode);
th->t_trans_id = 0; /* so the caller can't use this handle later */ th->t_trans_id = 0; /* so the caller can't use this handle later */
unlock_new_inode(inode); /* OK to do even if we hadn't locked it */ unlock_new_inode(inode); /* OK to do even if we hadn't locked it */
iput(inode); iput(inode);
......
...@@ -622,7 +622,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -622,7 +622,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
dentry->d_name.len, inode, 1 /*visible */ ); dentry->d_name.len, inode, 1 /*visible */ );
if (retval) { if (retval) {
int err; int err;
inode->i_nlink--; drop_nlink(inode);
reiserfs_update_sd(&th, inode); reiserfs_update_sd(&th, inode);
err = journal_end(&th, dir->i_sb, jbegin_count); err = journal_end(&th, dir->i_sb, jbegin_count);
if (err) if (err)
...@@ -702,7 +702,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode, ...@@ -702,7 +702,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
dentry->d_name.len, inode, 1 /*visible */ ); dentry->d_name.len, inode, 1 /*visible */ );
if (retval) { if (retval) {
int err; int err;
inode->i_nlink--; drop_nlink(inode);
reiserfs_update_sd(&th, inode); reiserfs_update_sd(&th, inode);
err = journal_end(&th, dir->i_sb, jbegin_count); err = journal_end(&th, dir->i_sb, jbegin_count);
if (err) if (err)
...@@ -787,7 +787,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -787,7 +787,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
dentry->d_name.len, inode, 1 /*visible */ ); dentry->d_name.len, inode, 1 /*visible */ );
if (retval) { if (retval) {
int err; int err;
inode->i_nlink = 0; clear_nlink(inode);
DEC_DIR_INODE_NLINK(dir); DEC_DIR_INODE_NLINK(dir);
reiserfs_update_sd(&th, inode); reiserfs_update_sd(&th, inode);
err = journal_end(&th, dir->i_sb, jbegin_count); err = journal_end(&th, dir->i_sb, jbegin_count);
...@@ -1086,7 +1086,7 @@ static int reiserfs_symlink(struct inode *parent_dir, ...@@ -1086,7 +1086,7 @@ static int reiserfs_symlink(struct inode *parent_dir,
dentry->d_name.len, inode, 1 /*visible */ ); dentry->d_name.len, inode, 1 /*visible */ );
if (retval) { if (retval) {
int err; int err;
inode->i_nlink--; drop_nlink(inode);
reiserfs_update_sd(&th, inode); reiserfs_update_sd(&th, inode);
err = journal_end(&th, parent_dir->i_sb, jbegin_count); err = journal_end(&th, parent_dir->i_sb, jbegin_count);
if (err) if (err)
...@@ -1129,7 +1129,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -1129,7 +1129,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
retval = journal_begin(&th, dir->i_sb, jbegin_count); retval = journal_begin(&th, dir->i_sb, jbegin_count);
if (retval) { if (retval) {
inode->i_nlink--; drop_nlink(inode);
reiserfs_write_unlock(dir->i_sb); reiserfs_write_unlock(dir->i_sb);
return retval; return retval;
} }
...@@ -1144,7 +1144,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -1144,7 +1144,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
if (retval) { if (retval) {
int err; int err;
inode->i_nlink--; drop_nlink(inode);
err = journal_end(&th, dir->i_sb, jbegin_count); err = journal_end(&th, dir->i_sb, jbegin_count);
reiserfs_write_unlock(dir->i_sb); reiserfs_write_unlock(dir->i_sb);
return err ? err : retval; return err ? err : retval;
......
...@@ -558,7 +558,7 @@ int ubifs_removexattr(struct dentry *dentry, const char *name) ...@@ -558,7 +558,7 @@ int ubifs_removexattr(struct dentry *dentry, const char *name)
} }
ubifs_assert(inode->i_nlink == 1); ubifs_assert(inode->i_nlink == 1);
inode->i_nlink = 0; clear_nlink(inode);
err = remove_xattr(c, host, inode, &nm); err = remove_xattr(c, host, inode, &nm);
if (err) if (err)
inode->i_nlink = 1; inode->i_nlink = 1;
......
...@@ -577,8 +577,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -577,8 +577,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
if (!fi) { if (!fi) {
inode->i_nlink--; inode_dec_link_count(inode);
mark_inode_dirty(inode);
iput(inode); iput(inode);
return err; return err;
} }
...@@ -618,8 +617,7 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, ...@@ -618,8 +617,7 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
init_special_inode(inode, mode, rdev); init_special_inode(inode, mode, rdev);
fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
if (!fi) { if (!fi) {
inode->i_nlink--; inode_dec_link_count(inode);
mark_inode_dirty(inode);
iput(inode); iput(inode);
return err; return err;
} }
...@@ -665,8 +663,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -665,8 +663,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
inode->i_fop = &udf_dir_operations; inode->i_fop = &udf_dir_operations;
fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err);
if (!fi) { if (!fi) {
inode->i_nlink--; inode_dec_link_count(inode);
mark_inode_dirty(inode);
iput(inode); iput(inode);
goto out; goto out;
} }
...@@ -683,7 +680,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -683,7 +680,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
if (!fi) { if (!fi) {
inode->i_nlink = 0; clear_nlink(inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
iput(inode); iput(inode);
goto out; goto out;
......
...@@ -341,7 +341,7 @@ struct inode * ufs_new_inode(struct inode * dir, int mode) ...@@ -341,7 +341,7 @@ struct inode * ufs_new_inode(struct inode * dir, int mode)
fail_remove_inode: fail_remove_inode:
unlock_super(sb); unlock_super(sb);
inode->i_nlink = 0; clear_nlink(inode);
iput(inode); iput(inode);
UFSD("EXIT (FAILED): err %d\n", err); UFSD("EXIT (FAILED): err %d\n", err);
return ERR_PTR(err); return ERR_PTR(err);
......
...@@ -2503,7 +2503,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags ...@@ -2503,7 +2503,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
d_instantiate(path.dentry, inode); d_instantiate(path.dentry, inode);
inode->i_size = size; inode->i_size = size;
inode->i_nlink = 0; /* It is unlinked */ clear_nlink(inode); /* It is unlinked */
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
error = ramfs_nommu_expand_for_mapping(inode, size); error = ramfs_nommu_expand_for_mapping(inode, size);
if (error) if (error)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment