Re: [PATCH] tmpfs: support aio

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andrew Morton
Date: Wednesday, May 28, 2008 - 4:58 pm

On Thu, 29 May 2008 00:13:35 +0100 (BST)
Hugh Dickins <hugh@veritas.com> wrote:


hm.  This version:

static ssize_t shmem_file_aio_read(struct kiocb *iocb,
		const struct iovec *iov, unsigned long nr_segs, loff_t pos)
{
	struct file *filp = iocb->ki_filp;
	ssize_t retval;
	unsigned long seg;
	size_t count;
	loff_t *ppos = &iocb->ki_pos;

	count = 0;
	retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE);
	if (retval)
		return retval;
	if (count == 0)
		return 0;

	retval = 0;
	for (seg = 0; seg < nr_segs; seg++) {
		if (iov[seg].iov_len) {
			read_descriptor_t desc = {
				.arg.buf = iov[seg].iov_base,
				.count = iov[seg].iov_len;
			};

			do_shmem_file_read(filp, ppos, &desc, file_read_actor);
			retval += desc.written;
			if (desc.error) {
				retval = retval ?: desc.error;
				break;
			}
			if (desc.count > 0)
				break;
		}
	}
	return retval;
}

is neater but generates 21 bytes more code.  Stupid gcc.

I don't believe we needed to check for count == 0?  We'd just loop around
N times doing nothing.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] tmpfs: support aio, Hugh Dickins, (Wed May 28, 4:13 pm)
Re: [PATCH] tmpfs: support aio, Andrew Morton, (Wed May 28, 4:58 pm)
Re: [PATCH] tmpfs: support aio, Harvey Harrison, (Wed May 28, 5:06 pm)
Re: [PATCH] tmpfs: support aio, Hugh Dickins, (Thu May 29, 11:20 am)
Re: [PATCH] tmpfs: support aio, Hugh Dickins, (Thu May 29, 11:24 am)
[PATCH] generic_file_aio_read cleanups, Hugh Dickins, (Thu May 29, 1:54 pm)
[PATCH v2] tmpfs: support aio, Hugh Dickins, (Thu May 29, 1:57 pm)