[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080528165815.f4e4982c.akpm@linux-foundation.org>
Date: Wed, 28 May 2008 16:58:15 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Hugh Dickins <hugh@...itas.com>
Cc: hans-christoph.rohland@....com, leg@...gle.com, pbadari@...ibm.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tmpfs: support aio
On Thu, 29 May 2008 00:13:35 +0100 (BST)
Hugh Dickins <hugh@...itas.com> wrote:
> + 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;
> +
> + retval = 0;
> + if (count) {
> + for (seg = 0; seg < nr_segs; seg++) {
> + read_descriptor_t desc;
> +
> + desc.written = 0;
> + desc.arg.buf = iov[seg].iov_base;
> + desc.count = iov[seg].iov_len;
> + if (desc.count == 0)
> + continue;
> + desc.error = 0;
> + 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;
> }
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists