コード例 #1
0
ファイル: ext3.c プロジェクト: kandeshvari/embox
static int ext3fs_umount(void *dir) {
	struct fs_driver *drv;
	struct ext2_fs_info *fsi;
	ext3_journal_specific_t *data;
	int res;

	fsi = ((struct node *)dir)->nas->fs->fsi;
	data = fsi->journal->j_fs_specific.data;

	if(NULL == (drv = fs_driver_find_drv(EXT2_NAME))) {
		return -1;
	}

	res = drv->fsop->umount(dir);

	journal_delete(fsi->journal);
	sysfree(data->ext3_journal_inode);
	journal_free_block(fsi->journal, data->j_sb_buffer);
	objfree(&ext3_journal_cache, data);

	return res;
}
コード例 #2
0
ファイル: journal.c プロジェクト: snua12/zlomekfs
bool
journal_insert(journal_t journal, journal_operation_t oper,
			   zfs_fh * local_fh, zfs_fh * master_fh,
			   uint64_t master_version, string * name, bool copy)
{
	journal_entry entry;
	void **slot;

	CHECK_MUTEX_LOCKED(journal->mutex);

	if (oper == JOURNAL_OPERATION_DEL)
	{
		/* If we are adding a DEL entry try to anihilate ;-) it with the
		   corresponding ADD entry.  */
		if (journal_delete(journal, JOURNAL_OPERATION_ADD, name))
		{
			if (!copy)
			{
				/* If we shall not copy NAME the NAME is dynamically allocated
				   and caller does not free it so we have to free it now.  */
				free(name->str);
			}
			return true;
		}
	}

	zfsd_mutex_lock(&journal_mutex);
	entry = (journal_entry) pool_alloc(journal_pool);
	zfsd_mutex_unlock(&journal_mutex);
	entry->oper = oper;
	entry->name = *name;

	slot = htab_find_slot_with_hash(journal->htab, entry, JOURNAL_HASH(entry),
									INSERT);
	if (*slot)
	{
		journal_entry old = (journal_entry) * slot;

		/* When there already is an entry with the same operation and name in
		   the journal, zfsd has crashed and left the journal in inconsistent
		   state. In this case, delete the old entry and add a new one.  */

		if (old->next)
			old->next->prev = old->prev;
		else
			journal->last = old->prev;
		if (old->prev)
			old->prev->next = old->next;
		else
			journal->first = old->next;

		free(old->name.str);
		zfsd_mutex_lock(&journal_mutex);
		pool_free(journal_pool, old);
		zfsd_mutex_unlock(&journal_mutex);
	}

	entry->dev = local_fh->dev;
	entry->ino = local_fh->ino;
	entry->gen = local_fh->gen;
	entry->master_fh = *master_fh;
	entry->master_version = master_version;
	if (copy)
		entry->name.str = (char *)xmemdup(name->str, entry->name.len + 1);

	*slot = entry;
	entry->next = NULL;
	entry->prev = journal->last;
	if (journal->last)
		journal->last->next = entry;
	journal->last = entry;
	if (journal->first == NULL)
		journal->first = entry;
	return true;
}