On Fri, Sep 26, 2014 at 08:05:29PM +0000, Mateusz Guzik wrote:
> Author: mjg
> Date: Fri Sep 26 20:05:28 2014
> New Revision: 272187
> URL: http://svnweb.freebsd.org/changeset/base/272187
> 
> Log:
>   MFC r270993:
>   
>   Fix up proc_realparent to always return correct process.
>   
>   Prior to the change it would always return initproc for non-traced 
> processes.
>   
>   This fixes a regression in inferior().
>   
>   Approved by:        re (marius)
> 

Oops.. this is r270648. Still approvied by re (marius).

> Modified:
>   stable/10/sys/kern/kern_descrip.c
>   stable/10/sys/kern/vfs_vnops.c
>   stable/10/sys/sys/file.h
> Directory Properties:
>   stable/10/   (props changed)
> 
> Modified: stable/10/sys/kern/kern_descrip.c
> ==============================================================================
> --- stable/10/sys/kern/kern_descrip.c Fri Sep 26 19:56:52 2014        
> (r272186)
> +++ stable/10/sys/kern/kern_descrip.c Fri Sep 26 20:05:28 2014        
> (r272187)
> @@ -477,7 +477,6 @@ kern_fcntl(struct thread *td, int fd, in
>       struct vnode *vp;
>       cap_rights_t rights;
>       int error, flg, tmp;
> -     u_int old, new;
>       uint64_t bsize;
>       off_t foffset;
>  
> @@ -761,26 +760,24 @@ kern_fcntl(struct thread *td, int fd, in
>                       error = EBADF;
>                       break;
>               }
> +             vp = fp->f_vnode;
> +             /*
> +              * Exclusive lock synchronizes against f_seqcount reads and
> +              * writes in sequential_heuristic().
> +              */
> +             error = vn_lock(vp, LK_EXCLUSIVE);
> +             if (error != 0) {
> +                     fdrop(fp, td);
> +                     break;
> +             }
>               if (arg >= 0) {
> -                     vp = fp->f_vnode;
> -                     error = vn_lock(vp, LK_SHARED);
> -                     if (error != 0) {
> -                             fdrop(fp, td);
> -                             break;
> -                     }
>                       bsize = fp->f_vnode->v_mount->mnt_stat.f_iosize;
> -                     VOP_UNLOCK(vp, 0);
>                       fp->f_seqcount = (arg + bsize - 1) / bsize;
> -                     do {
> -                             new = old = fp->f_flag;
> -                             new |= FRDAHEAD;
> -                     } while (!atomic_cmpset_rel_int(&fp->f_flag, old, new));
> +                     atomic_set_int(&fp->f_flag, FRDAHEAD);
>               } else {
> -                     do {
> -                             new = old = fp->f_flag;
> -                             new &= ~FRDAHEAD;
> -                     } while (!atomic_cmpset_rel_int(&fp->f_flag, old, new));
> +                     atomic_clear_int(&fp->f_flag, FRDAHEAD);
>               }
> +             VOP_UNLOCK(vp, 0);
>               fdrop(fp, td);
>               break;
>  
> 
> Modified: stable/10/sys/kern/vfs_vnops.c
> ==============================================================================
> --- stable/10/sys/kern/vfs_vnops.c    Fri Sep 26 19:56:52 2014        
> (r272186)
> +++ stable/10/sys/kern/vfs_vnops.c    Fri Sep 26 20:05:28 2014        
> (r272187)
> @@ -438,7 +438,8 @@ static int
>  sequential_heuristic(struct uio *uio, struct file *fp)
>  {
>  
> -     if (atomic_load_acq_int(&(fp->f_flag)) & FRDAHEAD)
> +     ASSERT_VOP_LOCKED(fp->f_vnode, __func__);
> +     if (fp->f_flag & FRDAHEAD)
>               return (fp->f_seqcount << IO_SEQSHIFT);
>  
>       /*
> 
> Modified: stable/10/sys/sys/file.h
> ==============================================================================
> --- stable/10/sys/sys/file.h  Fri Sep 26 19:56:52 2014        (r272186)
> +++ stable/10/sys/sys/file.h  Fri Sep 26 20:05:28 2014        (r272187)
> @@ -139,6 +139,7 @@ struct fileops {
>   *
>   * Below is the list of locks that protects members in struct file.
>   *
> + * (a) f_vnode lock required (shared allows both reads and writes)
>   * (f) protected with mtx_lock(mtx_pool_find(fp))
>   * (d) cdevpriv_mtx
>   * none      not locked
> @@ -164,7 +165,7 @@ struct file {
>       /*
>        *  DTYPE_VNODE specific fields.
>        */
> -     int             f_seqcount;     /* Count of sequential accesses. */
> +     int             f_seqcount;     /* (a) Count of sequential accesses. */
>       off_t           f_nextoff;      /* next expected read/write offset. */
>       union {
>               struct cdev_privdata *fvn_cdevpriv;
> 

-- 
Mateusz Guzik <mjguzik gmail.com>
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to