Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23076
b: refs/heads/master
c: 3257545
h: refs/heads/master
v: v3
  • Loading branch information
Alexey Dobriyan authored and Linus Torvalds committed Mar 23, 2006
1 parent a30b765 commit 0b2e6bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a513b035eadf80bb9ce0be4c5dd9f242cfb9eecc
refs/heads/master: 3257545e40a769cbef98cf13eabe50f00712991e
48 changes: 18 additions & 30 deletions trunk/fs/ufs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,14 @@
#define UFSD(x)
#endif

static inline void ufs_inc_count(struct inode *inode)
{
inode->i_nlink++;
mark_inode_dirty(inode);
}

static inline void ufs_dec_count(struct inode *inode)
{
inode->i_nlink--;
mark_inode_dirty(inode);
}

static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
{
int err = ufs_add_link(dentry, inode);
if (!err) {
d_instantiate(dentry, inode);
return 0;
}
ufs_dec_count(inode);
inode_dec_link_count(inode);
iput(inode);
return err;
}
Expand Down Expand Up @@ -173,7 +161,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
return err;

out_fail:
ufs_dec_count(inode);
inode_dec_link_count(inode);
iput(inode);
goto out;
}
Expand All @@ -191,7 +179,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
}

inode->i_ctime = CURRENT_TIME_SEC;
ufs_inc_count(inode);
inode_inc_link_count(inode);
atomic_inc(&inode->i_count);

error = ufs_add_nondir(dentry, inode);
Expand All @@ -208,7 +196,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
goto out;

lock_kernel();
ufs_inc_count(dir);
inode_inc_link_count(dir);

inode = ufs_new_inode(dir, S_IFDIR|mode);
err = PTR_ERR(inode);
Expand All @@ -218,7 +206,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
inode->i_op = &ufs_dir_inode_operations;
inode->i_fop = &ufs_dir_operations;

ufs_inc_count(inode);
inode_inc_link_count(inode);

err = ufs_make_empty(inode, dir);
if (err)
Expand All @@ -234,11 +222,11 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
return err;

out_fail:
ufs_dec_count(inode);
ufs_dec_count(inode);
inode_dec_link_count(inode);
inode_dec_link_count(inode);
iput (inode);
out_dir:
ufs_dec_count(dir);
inode_dec_link_count(dir);
unlock_kernel();
goto out;
}
Expand All @@ -260,7 +248,7 @@ static int ufs_unlink(struct inode * dir, struct dentry *dentry)
goto out;

inode->i_ctime = dir->i_ctime;
ufs_dec_count(inode);
inode_dec_link_count(inode);
err = 0;
out:
unlock_kernel();
Expand All @@ -277,8 +265,8 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
err = ufs_unlink(dir, dentry);
if (!err) {
inode->i_size = 0;
ufs_dec_count(inode);
ufs_dec_count(dir);
inode_dec_link_count(inode);
inode_dec_link_count(dir);
}
}
unlock_kernel();
Expand Down Expand Up @@ -319,35 +307,35 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
new_de = ufs_find_entry (new_dentry, &new_bh);
if (!new_de)
goto out_dir;
ufs_inc_count(old_inode);
inode_inc_link_count(old_inode);
ufs_set_link(new_dir, new_de, new_bh, old_inode);
new_inode->i_ctime = CURRENT_TIME_SEC;
if (dir_de)
new_inode->i_nlink--;
ufs_dec_count(new_inode);
inode_dec_link_count(new_inode);
} else {
if (dir_de) {
err = -EMLINK;
if (new_dir->i_nlink >= UFS_LINK_MAX)
goto out_dir;
}
ufs_inc_count(old_inode);
inode_inc_link_count(old_inode);
err = ufs_add_link(new_dentry, old_inode);
if (err) {
ufs_dec_count(old_inode);
inode_dec_link_count(old_inode);
goto out_dir;
}
if (dir_de)
ufs_inc_count(new_dir);
inode_inc_link_count(new_dir);
}

ufs_delete_entry (old_dir, old_de, old_bh);

ufs_dec_count(old_inode);
inode_dec_link_count(old_inode);

if (dir_de) {
ufs_set_link(old_inode, dir_de, dir_bh, new_dir);
ufs_dec_count(old_dir);
inode_dec_link_count(old_dir);
}
unlock_kernel();
return 0;
Expand Down

0 comments on commit 0b2e6bd

Please sign in to comment.