Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Sep 2022 23:26:56 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mateusz Guzik <mjg@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: 9e4f35ac2553 - main - vfs: deperl msleep flag calculation in vn_start_*write
Message-ID:  <YyYtkMhKoLdxSwJg@kib.kiev.ua>
In-Reply-To: <202209171542.28HFgcWG076519@gitrepo.freebsd.org>
References:  <202209171542.28HFgcWG076519@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Sep 17, 2022 at 03:42:38PM +0000, Mateusz Guzik wrote:
> The branch main has been updated by mjg:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=9e4f35ac25538fb426c459400f0c36e085546ffa
> 
> commit 9e4f35ac25538fb426c459400f0c36e085546ffa
> Author:     Mateusz Guzik <mjg@FreeBSD.org>
> AuthorDate: 2022-09-17 15:17:20 +0000
> Commit:     Mateusz Guzik <mjg@FreeBSD.org>
> CommitDate: 2022-09-17 15:17:20 +0000
> 
>     vfs: deperl msleep flag calculation in vn_start_*write
> ---
>  sys/kern/vfs_vnops.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
> index 2e39d8a9e4d2..a7ca547f571f 100644
> --- a/sys/kern/vfs_vnops.c
> +++ b/sys/kern/vfs_vnops.c
> @@ -1875,8 +1875,12 @@ vn_start_write_refed(struct mount *mp, int flags, bool mplocked)
>  	 */
>  	if ((curthread->td_pflags & TDP_IGNSUSP) == 0 ||
>  	    mp->mnt_susp_owner != curthread) {
> -		mflags = ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0 ?
> -		    (flags & PCATCH) : 0) | (PUSER - 1);
Original expression is much more concise and in fact easier to read.

> +		mflags = 0;
> +		if ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) {
> +			if (flags & PCATCH)
			if ((flags & PCATCH) != 0)
> +				mflags |= PCATCH;
> +		}
> +		mflags |= (PUSER - 1);
Extra ()

>  		while ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) {
>  			if (flags & V_NOWAIT) {
>  				error = EWOULDBLOCK;
> @@ -1944,7 +1948,7 @@ int
>  vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags)
>  {
>  	struct mount *mp;
> -	int error;
> +	int error, mflags;
>  
>   retry:
>  	if (vp != NULL) {
> @@ -1986,9 +1990,13 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags)
>  	/*
>  	 * Wait for the suspension to finish.
>  	 */
> -	error = msleep(&mp->mnt_flag, MNT_MTX(mp), (PUSER - 1) | PDROP |
> -	    ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0 ? (flags & PCATCH) : 0),
> -	    "suspfs", 0);
> +	mflags = 0;
> +	if ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) {
> +		if (flags & PCATCH)
!= 0

> +			mflags |= PCATCH;
> +	}
> +	mflags |= (PUSER - 1) | PDROP;
> +	error = msleep(&mp->mnt_flag, MNT_MTX(mp), mflags, "suspfs", 0);
>  	vfs_rel(mp);
>  	if (error == 0)
>  		goto retry;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YyYtkMhKoLdxSwJg>