lkml.org 
[lkml]   [2008]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] tmpfs: support aio
    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.



    \
     
     \ /
      Last update: 2008-05-29 02:01    [W:0.025 / U:1.320 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site