Esempio n. 1
0
//!	btrfs_io() callback hook
static status_t
iterative_io_finished_hook(void* cookie, io_request* request, status_t status,
	bool partialTransfer, size_t bytesTransferred)
{
	Inode* inode = (Inode*)cookie;
	rw_lock_read_unlock(inode->Lock());
	return B_OK;
}
Esempio n. 2
0
	bool TestDegrade(TestContext& context)
	{
		TEST_ASSERT(rw_lock_write_lock(&fLock) == B_OK);
		TEST_ASSERT(rw_lock_read_lock(&fLock) == B_OK);
		rw_lock_write_unlock(&fLock);
		rw_lock_read_unlock(&fLock);

		return true;
	}
/*static*/ VMAddressSpace*
VMAddressSpace::Get(team_id teamID)
{
	rw_lock_read_lock(&sAddressSpaceTableLock);
	VMAddressSpace* addressSpace = sAddressSpaceTable.Lookup(teamID);
	if (addressSpace)
		addressSpace->Get();
	rw_lock_read_unlock(&sAddressSpaceTableLock);

	return addressSpace;
}
Esempio n. 4
0
	bool TestSimple(TestContext& context)
	{
		for (int32 i = 0; i < 3; i++) {
			TEST_ASSERT(rw_lock_read_lock(&fLock) == B_OK);
			rw_lock_read_unlock(&fLock);

			TEST_ASSERT(rw_lock_write_lock(&fLock) == B_OK);
			rw_lock_write_unlock(&fLock);
		}

		return true;
	}
Esempio n. 5
0
	bool TestNestedWriteRead(TestContext& context)
	{
		TEST_ASSERT(rw_lock_write_lock(&fLock) == B_OK);

		for (int32 i = 0; i < 10; i++)
			TEST_ASSERT(rw_lock_read_lock(&fLock) == B_OK);

		for (int32 i = 0; i < 10; i++)
			rw_lock_read_unlock(&fLock);

		rw_lock_write_unlock(&fLock);

		return true;
	}
Esempio n. 6
0
static status_t
ext2_write_pages(fs_volume* _volume, fs_vnode* _node, void* _cookie,
	off_t pos, const iovec* vecs, size_t count, size_t* _numBytes)
{
	Volume* volume = (Volume*)_volume->private_volume;
	Inode* inode = (Inode*)_node->private_node;

	if (volume->IsReadOnly())
		return B_READ_ONLY_DEVICE;

	if (inode->FileCache() == NULL)
		return B_BAD_VALUE;

	rw_lock_read_lock(inode->Lock());

	uint32 vecIndex = 0;
	size_t vecOffset = 0;
	size_t bytesLeft = *_numBytes;
	status_t status;

	while (true) {
		file_io_vec fileVecs[8];
		size_t fileVecCount = 8;

		status = file_map_translate(inode->Map(), pos, bytesLeft, fileVecs,
			&fileVecCount, 0);
		if (status != B_OK && status != B_BUFFER_OVERFLOW)
			break;

		bool bufferOverflow = status == B_BUFFER_OVERFLOW;

		size_t bytes = bytesLeft;
		status = write_file_io_vec_pages(volume->Device(), fileVecs,
			fileVecCount, vecs, count, &vecIndex, &vecOffset, &bytes);
		if (status != B_OK || !bufferOverflow)
			break;

		pos += bytes;
		bytesLeft -= bytes;
	}

	rw_lock_read_unlock(inode->Lock());

	return status;
}