Skip to content

Commit

Permalink
ocfs2: add duplicated ino number check
Browse files Browse the repository at this point in the history
Add duplicated ino number check, to avoid adding a file into the file
check list when this file is being checked.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Gang He <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Junxiao Bi <[email protected]>
Cc: Joseph Qi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Gang He authored and torvalds committed Apr 6, 2018
1 parent 5f483c4 commit 39ec377
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion fs/ocfs2/filecheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,22 @@ static ssize_t ocfs2_filecheck_attr_show(struct kobject *kobj,
return total;
}

static inline int
ocfs2_filecheck_is_dup_entry(struct ocfs2_filecheck_sysfs_entry *ent,
unsigned long ino)
{
struct ocfs2_filecheck_entry *p;

list_for_each_entry(p, &ent->fs_fcheck->fc_head, fe_list) {
if (!p->fe_done) {
if (p->fe_ino == ino)
return 1;
}
}

return 0;
}

static inline int
ocfs2_filecheck_erase_entry(struct ocfs2_filecheck_sysfs_entry *ent)
{
Expand Down Expand Up @@ -467,7 +483,10 @@ static ssize_t ocfs2_filecheck_attr_store(struct kobject *kobj,
}

spin_lock(&ent->fs_fcheck->fc_lock);
if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) &&
if (ocfs2_filecheck_is_dup_entry(ent, args.fa_ino)) {
ret = -EEXIST;
kfree(entry);
} else if ((ent->fs_fcheck->fc_size >= ent->fs_fcheck->fc_max) &&
(ent->fs_fcheck->fc_done == 0)) {
mlog(ML_NOTICE,
"Cannot do more file check "
Expand Down

0 comments on commit 39ec377

Please sign in to comment.