{
struct pstore_private *p = d_inode(dentry)->i_private;
struct pstore_record *record = p->record;
+ int rc = 0;
if (!record->psi->erase)
return -EPERM;
+ /* Make sure we can't race while removing this file. */
+ mutex_lock(&records_list_lock);
+ if (!list_empty(&p->list))
+ list_del_init(&p->list);
+ else
+ rc = -ENOENT;
+ mutex_unlock(&records_list_lock);
+ if (rc)
+ return rc;
+
mutex_lock(&record->psi->read_mutex);
record->psi->erase(record);
mutex_unlock(&record->psi->read_mutex);
struct pstore_private *p = inode->i_private;
clear_inode(inode);
- if (p) {
- mutex_lock(&records_list_lock);
- list_del(&p->list);
- mutex_unlock(&records_list_lock);
- free_pstore_private(p);
- }
+ free_pstore_private(p);
}
static const struct inode_operations pstore_dir_inode_operations = {
{
kill_litter_super(sb);
pstore_sb = NULL;
+ INIT_LIST_HEAD(&records_list);
}
static struct file_system_type pstore_fs_type = {