@@ -217,14 +217,12 @@ ocfs2_filecheck_handle_entry(struct ocfs2_super *osb,
int ocfs2_filecheck_add_inode(struct ocfs2_super *osb,
unsigned long ino)
{
- struct ocfs2_filecheck_entry *entry;
+ struct ocfs2_filecheck_entry *entry, *p;
ssize_t ret = 0;
entry = kmalloc(sizeof(struct ocfs2_filecheck_entry), GFP_NOFS);
- if (!entry) {
- ret = -ENOMEM;
- goto exit;
- }
+ if (!entry)
+ return -ENOMEM;
spin_lock(&osb->fc_lock);
if ((osb->fc_size >= osb->fc_max) &&
@@ -244,6 +242,12 @@ int ocfs2_filecheck_add_inode(struct ocfs2_super *osb,
*/
BUG_ON(!ocfs2_filecheck_erase_entry(osb));
}
+ list_for_each_entry(p, &osb->file_check_entries, fe_list)
+ if (p->fe_ino == ino) {
+ ret = -EEXIST;
+ kfree(entry);
+ goto unlock;
+ }
entry->fe_ino = ino;
entry->fe_type = OCFS2_FILECHECK_TYPE_CHK;
@@ -252,11 +256,15 @@ int ocfs2_filecheck_add_inode(struct ocfs2_super *osb,
list_add_tail(&entry->fe_list, &osb->file_check_entries);
osb->fc_size++;
}
+unlock:
spin_unlock(&osb->fc_lock);
- if (!ret)
- ocfs2_filecheck_handle_entry(osb, entry);
+ if (ret)
+ return ret;
-exit:
- return ret;
+ entry->fe_status = ocfs2_filecheck_handle(osb,
+ entry->fe_ino, OCFS2_FI_FLAG_FILECHECK_CHK);
+
+ ocfs2_filecheck_done_entry(osb, entry);
+ return 0;
}