Skip to content

Commit

Permalink
ext[34]: avoid i_nlink warnings triggered by drop_nlink/inc_nlink klu…
Browse files Browse the repository at this point in the history
…dge in symlink()

Both ext3 and ext4 put the half-created symlink inode into the orphan list
for a while (see the comment in ext[34]_symlink() for gory details).  Then,
if everything went fine, they pull it out of the orphan list and bump the
link count back to 1.  The thing is, inc_nlink() is going to complain about
seeing somebody changing i_nlink from 0 to 1.  With a good reason, since
normally something like that is a bug.  Explicit set_nlink(inode, 1) does
the same thing as inc_nlink() here, but it does *not* complain - exactly
because it should be usable in strange situations like this one.

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jan 9, 2012
1 parent da01636 commit 0ce8c01
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fs/ext3/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ static int ext3_symlink (struct inode * dir,
err = PTR_ERR(handle);
goto err_drop_inode;
}
inc_nlink(inode);
set_nlink(inode, 1);
err = ext3_orphan_del(handle, inode);
if (err) {
ext3_journal_stop(handle);
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2315,7 +2315,7 @@ static int ext4_symlink(struct inode *dir,
err = PTR_ERR(handle);
goto err_drop_inode;
}
inc_nlink(inode);
set_nlink(inode, 1);
err = ext4_orphan_del(handle, inode);
if (err) {
ext4_journal_stop(handle);
Expand Down

0 comments on commit 0ce8c01

Please sign in to comment.