On Mon, May 07, 2018 at 06:11:32PM +0200, Martin Pieuchot wrote:
> I'm going to protect `f_count' with a global lock soon.  That implies
> that multiple FREF(9)s will be inlined.  So here's a diff moving the
> vfs_stall hack to a proper function.  This will help when looking for
> history and it reduces my upcoming locking diff.
> 
> Better name?  Ok?

OK bluhm@

> Index: kern/vfs_subr.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/vfs_subr.c,v
> retrieving revision 1.269
> diff -u -p -r1.269 vfs_subr.c
> --- kern/vfs_subr.c   2 May 2018 02:24:56 -0000       1.269
> +++ kern/vfs_subr.c   7 May 2018 16:07:11 -0000
> @@ -1627,6 +1627,13 @@ vfs_stall(struct proc *p, int stall)
>       return (allerror);
>  }
>  
> +void
> +vfs_stall_barrier(void)
> +{
> +     rw_enter_read(&vfs_stall_lock);
> +     rw_exit_read(&vfs_stall_lock);
> +}
> +
>  /*
>   * Unmount all file systems.
>   * We traverse the list in reverse order under the assumption that doing so
> Index: sys/file.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/file.h,v
> retrieving revision 1.41
> diff -u -p -r1.41 file.h
> --- sys/file.h        25 Apr 2018 10:29:16 -0000      1.41
> +++ sys/file.h        7 May 2018 16:08:31 -0000
> @@ -37,6 +37,7 @@
>  
>  #else /* _KERNEL */
>  #include <sys/queue.h>
> +#include <sys/mount.h>       /* vfs_stall_barrier() */
>  
>  struct proc;
>  struct uio;
> @@ -91,9 +92,7 @@ struct file {
>  
>  #define FREF(fp) \
>       do { \
> -             extern struct rwlock vfs_stall_lock; \
> -             rw_enter_read(&vfs_stall_lock); \
> -             rw_exit_read(&vfs_stall_lock); \
> +             vfs_stall_barrier(); \
>               (fp)->f_count++; \
>       } while (0)
>  #define FRELE(fp,p)  (--(fp)->f_count == 0 ? fdrop(fp, p) : 0)
> Index: sys/mount.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/mount.h,v
> retrieving revision 1.135
> diff -u -p -r1.135 mount.h
> --- sys/mount.h       10 Feb 2018 05:24:23 -0000      1.135
> +++ sys/mount.h       7 May 2018 16:07:11 -0000
> @@ -575,6 +575,7 @@ int       vfs_rootmountalloc(char *, char *, s
>  void vfs_unbusy(struct mount *);
>  extern       TAILQ_HEAD(mntlist, mount) mountlist;
>  int  vfs_stall(struct proc *, int);
> +void vfs_stall_barrier(void);
>  
>  struct       mount *getvfs(fsid_t *);            /* return vfs given fsid */
>                                           /* process mount export info */

Reply via email to