Re: [PATCH v7 11/11] ext4: introduce direct I/O write using iomap infrastructure

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

 



On Tue 05-11-19 23:02:39, Matthew Bobrowski wrote:
> +	if (ret >= 0 && iov_iter_count(from)) {
> +		ssize_t err;
> +		loff_t endbyte;
> +
> +		offset = iocb->ki_pos;
> +		err = ext4_buffered_write_iter(iocb, from);
> +		if (err < 0)
> +			return err;
> +
> +		/*
> +		 * We need to ensure that the pages within the page cache for
> +		 * the range covered by this I/O are written to disk and
> +		 * invalidated. This is in attempt to preserve the expected
> +		 * direct I/O semantics in the case we fallback to buffered I/O
> +		 * to complete off the I/O request.
> +		 */
> +		ret += err;
> +		endbyte = offset + ret - 1;
				   ^^ err here?

Otherwise you would write out and invalidate too much AFAICT - the 'offset'
is position just before we fall back to buffered IO. Otherwise this hunk
looks good to me.

> +		err = filemap_write_and_wait_range(iocb->ki_filp->f_mapping,
> +						   offset, endbyte);
> +		if (!err)
> +			invalidate_mapping_pages(iocb->ki_filp->f_mapping,
> +						 offset >> PAGE_SHIFT,
> +						 endbyte >> PAGE_SHIFT);
> +	}
> +
> +	return ret;
> +}
> +

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux