Re: [PATCH] Btrfs: stop using vfs_read in send

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry for the latency.  I was away last week.

On Fri, Oct 25, 2013 at 11:37:53AM -0400, Josef Bacik wrote:
> Apparently we don't actually close the files until we return to userspace, so
> stop using vfs_read in send.  This is actually better for us since we can avoid
> all the extra logic of holding the file we're sending open and making sure to
> clean it up.

Good stuff.

A few things:

> +	pgoff_t index = offset >> PAGE_CACHE_SHIFT;
> +	pgoff_t last_index;
> +	unsigned pg_offset = offset & (PAGE_CACHE_SIZE - 1);

	unsigned pg_offset = offset & ~PAGE_CACHE_MASK;

> +	if (offset + len > i_size_read(inode)) {

I worry about offset + len wrapping but I didn't check the caller to see
if that's possible.

> +	while (index <= last_index) {
> +		unsigned cur_len = min_t(unsigned, len, PAGE_CACHE_SIZE);

Careful, this'd insert some random kernel memory after the first partial
page.

		unsigned cur_len = min_t(unsigned, len, PAGE_CACHE_SIZE - pg_off);

> +		addr = kmap(page);
> +		memcpy(sctx->read_buf + ret, addr + pg_offset, cur_len);
> +		kunmap(page);
> +		unlock_page(page);

I think you need flush_dcache_page() before reading from user mappable
page cache pages.  (Need to make sure that potential cached stores at
other user virtual addreses are flushed before we read from the kernel
mapping.)

- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux