From: Andrew Morton <akpm@linux-foundation.org>
To: Hugh Dickins <hugh@veritas.com>
Cc: hans-christoph.rohland@sap.com, leg@google.com,
pbadari@us.ibm.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tmpfs: support aio
Date: Wed, 28 May 2008 16:58:15 -0700 [thread overview]
Message-ID: <20080528165815.f4e4982c.akpm@linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0805290007320.7969@blonde.site>
On Thu, 29 May 2008 00:13:35 +0100 (BST)
Hugh Dickins <hugh@veritas.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.
next prev parent reply other threads:[~2008-05-28 23:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-28 23:13 [PATCH] tmpfs: support aio Hugh Dickins
2008-05-28 23:58 ` Andrew Morton [this message]
2008-05-29 0:06 ` Harvey Harrison
2008-05-29 18:24 ` Hugh Dickins
2008-05-29 18:20 ` Hugh Dickins
2008-05-29 20:54 ` [PATCH] generic_file_aio_read cleanups Hugh Dickins
2008-05-29 20:57 ` [PATCH v2] tmpfs: support aio Hugh Dickins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080528165815.f4e4982c.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hans-christoph.rohland@sap.com \
--cc=hugh@veritas.com \
--cc=leg@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pbadari@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox