Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb926005 authored by Paul Lawrence's avatar Paul Lawrence
Browse files

Revert "ANDROID: Incremental fs: Fix incfs to work on virtio-9p"



This reverts commit abe35abb.

Set incfs back to rvc shipping incfs

Bug: 178509184
Test: incfs_test passes
Signed-off-by: default avatarPaul Lawrence <paullawrence@google.com>
Change-Id: Id03aeccb6676d51ee5f27d78541ca4c19510f595
parent ccb94354
Loading
Loading
Loading
Loading
+12 −35
Original line number Diff line number Diff line
@@ -89,42 +89,11 @@ static int truncate_backing_file(struct backing_file_context *bfc,
	return result;
}

static int write_to_bf(struct backing_file_context *bfc, const void *buf,
			size_t count, loff_t pos)
{
	ssize_t res = incfs_kwrite(bfc->bc_file, buf, count, pos);

	if (res < 0)
		return res;
	if (res != count)
		return -EIO;
	return 0;
}

static int append_zeros_no_fallocate(struct backing_file_context *bfc,
				     size_t file_size, size_t len)
{
	u8 buffer[256] = {};
	size_t i;

	for (i = 0; i < len; i += sizeof(buffer)) {
		int to_write = len - i > sizeof(buffer)
			? sizeof(buffer) : len - i;
		int err = write_to_bf(bfc, buffer, to_write, file_size + i);

		if (err)
			return err;
	}

	return 0;
}

/* Append a given number of zero bytes to the end of the backing file. */
static int append_zeros(struct backing_file_context *bfc, size_t len)
{
	loff_t file_size = 0;
	loff_t new_last_byte_offset = 0;
	int result;

	if (!bfc)
		return -EFAULT;
@@ -141,11 +110,19 @@ static int append_zeros(struct backing_file_context *bfc, size_t len)
	 */
	file_size = incfs_get_end_offset(bfc->bc_file);
	new_last_byte_offset = file_size + len - 1;
	result = vfs_fallocate(bfc->bc_file, 0, new_last_byte_offset, 1);
	if (result != -EOPNOTSUPP)
		return result;
	return vfs_fallocate(bfc->bc_file, 0, new_last_byte_offset, 1);
}

static int write_to_bf(struct backing_file_context *bfc, const void *buf,
			size_t count, loff_t pos)
{
	ssize_t res = incfs_kwrite(bfc->bc_file, buf, count, pos);

	return append_zeros_no_fallocate(bfc, file_size, len);
	if (res < 0)
		return res;
	if (res != count)
		return -EIO;
	return 0;
}

static u32 calc_md_crc(struct incfs_md_header *record)
+3 −3
Original line number Diff line number Diff line
@@ -1930,17 +1930,17 @@ static int file_open(struct inode *inode, struct file *file)
	struct file *backing_file = NULL;
	struct path backing_path = {};
	int err = 0;
	int flags = O_NOATIME | O_LARGEFILE |
		(S_ISDIR(inode->i_mode) ? O_RDONLY : O_RDWR);

	if (!mi)
		return -EBADF;

	get_incfs_backing_path(file->f_path.dentry, &backing_path);

	if (!backing_path.dentry)
		return -EBADF;

	backing_file = dentry_open(&backing_path, flags, mi->mi_owner);
	backing_file = dentry_open(
		&backing_path, O_RDWR | O_NOATIME | O_LARGEFILE, mi->mi_owner);
	path_put(&backing_path);

	if (IS_ERR(backing_file)) {