Skip to content

Commit

Permalink
udf: Skip parent dir link count update if corrupted
Browse files Browse the repository at this point in the history
If the parent directory link count is too low (likely directory inode
corruption), just skip updating its link count as if it goes to 0 too
early it can cause unexpected issues.

Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Jan Kara committed Nov 26, 2024
1 parent ac6f420 commit c556690
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/udf/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,11 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
inode->i_nlink);
clear_nlink(inode);
inode->i_size = 0;
inode_dec_link_count(dir);
if (dir->i_nlink >= 3)
inode_dec_link_count(dir);
else
udf_warn(inode->i_sb, "parent dir link count too low (%u)\n",
dir->i_nlink);
udf_add_fid_counter(dir->i_sb, true, -1);
inode_set_mtime_to_ts(dir,
inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));
Expand Down

0 comments on commit c556690

Please sign in to comment.