aio patch for review.

From: Alfred Perlstein (alfred_at_freebsd.org)
Date: 09/30/04

  • Next message: Rostislav Krasny: "default resolver(5) configuration and behavior of functions like gethostbyname(3)"
    Date: Thu, 30 Sep 2004 02:18:14 -0700
    To: alc@freebsd.org
    
    

    properly cover the socket buffer for operations that need locking.

    please review.

    Index: vfs_aio.c
    ===================================================================
    RCS file: /home/ncvs/src/sys/kern/vfs_aio.c,v
    retrieving revision 1.176
    diff -u -r1.176 vfs_aio.c
    --- vfs_aio.c 23 Sep 2004 14:45:04 -0000 1.176
    +++ vfs_aio.c 30 Sep 2004 09:15:10 -0000
    @@ -1297,6 +1297,7 @@
             struct kevent kev;
             struct kqueue *kq;
             struct file *kq_fp;
    + struct sockbuf *sb;
     
             aiocbe = uma_zalloc(aiocb_zone, M_WAITOK);
             aiocbe->inputcharge = 0;
    @@ -1451,29 +1452,28 @@
                      * If it is not ready for io, then queue the aiocbe on the
                      * socket, and set the flags so we get a call when sbnotify()
                      * happens.
    + *
    + * Note if opcode is neither LIO_WRITE nor LIO_READ we lock
    + * and unlock the snd sockbuf for no reason.
                      */
                     so = fp->f_data;
    + sb = (opcode == LIO_READ) ? &so->so_rcv : &so->so_snd;
    + SOCKBUF_LOCK(sb);
                     s = splnet();
                     if (((opcode == LIO_READ) && (!soreadable(so))) || ((opcode ==
                         LIO_WRITE) && (!sowriteable(so)))) {
                             TAILQ_INSERT_TAIL(&so->so_aiojobq, aiocbe, list);
                             TAILQ_INSERT_TAIL(&ki->kaio_sockqueue, aiocbe, plist);
    - if (opcode == LIO_READ) {
    - SOCKBUF_LOCK(&so->so_rcv);
    - so->so_rcv.sb_flags |= SB_AIO;
    - SOCKBUF_UNLOCK(&so->so_rcv);
    - } else {
    - SOCKBUF_LOCK(&so->so_snd);
    - so->so_snd.sb_flags |= SB_AIO;
    - SOCKBUF_UNLOCK(&so->so_snd);
    - }
    + sb->sb_flags |= SB_AIO;
                             aiocbe->jobstate = JOBST_JOBQGLOBAL; /* XXX */
                             ki->kaio_queue_count++;
                             num_queue_count++;
    + SOCKBUF_UNLOCK(sb);
                             splx(s);
                             error = 0;
                             goto done;
                     }
    + SOCKBUF_UNLOCK(sb);
                     splx(s);
             }
     

    -- 
    - Alfred Perlstein
    - Research Engineering Development Inc.
    - email: bright@mu.org cell: 408-480-4684
    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
    

  • Next message: Rostislav Krasny: "default resolver(5) configuration and behavior of functions like gethostbyname(3)"

    Relevant Pages