From owner-svn-src-all@freebsd.org Mon Mar 16 23:53:09 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8ADF0273F01; Mon, 16 Mar 2020 23:53:09 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48hCmM14Mwz4Cv8; Mon, 16 Mar 2020 23:53:06 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pl1-x634.google.com with SMTP id t3so8739879plz.9; Mon, 16 Mar 2020 16:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0QYYQGsqMuWwhLQ0extNaqPVADTADANUnNtIlY2ctBk=; b=Uy4aCySA4i8R39PEatI3BHhL0gpmObLUZZQ18ezA/8yAuWdGPWSDxzo3NLT4aODwCk qsQXPUVGo6aCxUYhbTS5x/KtIduCRug//Mz2A9/1JGcgWpj9VcevY7Em/VczlBZXYWL1 9ECF2LSoSQBYfHMmViNdZk0lQhwa7dy7JBLF5baRVuq5lkU8v/QHxWTg+l7LlkvwEBIi llnMHENDDwfq7eK3X0UoN5JZ9tQ+hF7ARDpdVkGjikai25XZCbwctg+Br+1qi7Ue9W/z N8tE1v0s3nX6alZ2ds4whFu1zavInddmeVc2HtIk3Dg40EVQBnSEnV17wsAC/T1KGSxt lsUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=0QYYQGsqMuWwhLQ0extNaqPVADTADANUnNtIlY2ctBk=; b=NZQM78MN4gcTUzDGjKi4ipZfKf3deK925fTu3QqM9sKXV++qyB8390Mmtlf+bJTMdb /xxN/uZLYPTSzqemWkT87RPzOvGS1GyN95D61mHv2lK4whWPR1ZoF9SYspRGiBq2m2Eb WXhYINg8Me8eai/Zw8fzxaMhhiQHu4JOOcaeQvkwu0SV0FOkvo/f9kwpVbLX89V1kUx5 YQyq3pZWxGfbJiYyydMWvJGG9COBx4w9Gw8Q+BRMLWAeSz/A1yYCmanzrgIULT9CjUPV ftFWpdCXU0rdOQhD+QqJ5mhBtuvLNiREox4rqAtYOQzs5uNsqICAQ8uy/MP7yrjfRGN1 iJUw== X-Gm-Message-State: ANhLgQ2R4x8HfwNnSJbPBfrSCDdHAHb/OAUELv2nthaOUbO/zULGyVwB +TY2L6vSHVwf7byTx+Wgm0RQVV+Z X-Google-Smtp-Source: ADFU+vszROCw0fJPhBx19wmaQWrR5aPOr5oDwjwpitxbTfVsBDOmIcCA2uEJflTKuodtTv3+rTIzWw== X-Received: by 2002:a17:902:d705:: with SMTP id w5mr1657716ply.68.1584402785257; Mon, 16 Mar 2020 16:53:05 -0700 (PDT) Received: from spy (d23-16-86-169.bchsia.telus.net. [23.16.86.169]) by smtp.gmail.com with ESMTPSA id 67sm891030pfe.168.2020.03.16.16.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 16:53:04 -0700 (PDT) Sender: Mark Johnston Date: Mon, 16 Mar 2020 19:52:59 -0400 From: Mark Johnston To: Chuck Silvers Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, glebius@freebsd.org Subject: Re: svn commit: r358597 - head/sys/kern Message-ID: <20200316235259.GA7120@spy> References: <202003040022.0240Mpm6074186@repo.freebsd.org> <20200313234817.GA10027@spy> <20200316051329.GA4598@spathi.chuq.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200316051329.GA4598@spathi.chuq.com> X-Rspamd-Queue-Id: 48hCmM14Mwz4Cv8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=Uy4aCySA; dmarc=none; spf=pass (mx1.freebsd.org: domain of markjdb@gmail.com designates 2607:f8b0:4864:20::634 as permitted sender) smtp.mailfrom=markjdb@gmail.com X-Spamd-Result: default: False [-4.15 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[freebsd.org]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCVD_IN_DNSWL_NONE(0.00)[4.3.6.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; IP_SCORE(-2.45)[ip: (-8.71), ipnet: 2607:f8b0::/32(-1.85), asn: 15169(-1.65), country: US(-0.05)]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[169.86.16.23.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; RCVD_TLS_ALL(0.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2020 23:53:09 -0000 On Sun, Mar 15, 2020 at 10:13:29PM -0700, Chuck Silvers wrote: > On Fri, Mar 13, 2020 at 07:48:17PM -0400, Mark Johnston wrote: > > On Wed, Mar 04, 2020 at 12:22:51AM +0000, Chuck Silvers wrote: > > > Author: chs > > > Date: Wed Mar 4 00:22:50 2020 > > > New Revision: 358597 > > > URL: https://svnweb.freebsd.org/changeset/base/358597 > > > > > > Log: > > > if vm_pager_get_pages_async() returns an error, release the sfio->nios > > > refcount that we took earlier that represents the I/O that ended up > > > not being started. > > > > I think a larger bug is that getpages_async is not consistent about > > whether it invokes the completion callback in synchronous error cases. > > For instance, vop_stdgetpages_async() always calls it, as does > > ffs_getpages_async() when the filesystem fragment size is larger than > > the page size. But vnode_pager_generic_getpages() does not. So if one > > is using sendfile on a filesystem that does not implement > > getpages_async, an error will cause sendfile_swapin() to unbusy the > > input pages multiple times, and release the sfio refcount twice when it > > should be done just once. > > > ah yes, you're right. I was only looking at the path we actually hit. > > I think the simplest way to resolve this would be to change > vnode_pager_generic_getpages() in the async case to always > call the iodone callback and always return 0. (in the sync case > vnode_pager_generic_getpages() would continue to return an error code > if an error is encountered.) vm_pager_get_pages_async() could then > be changed to return void since after the avoid changes it would > always return 0. swap_pager_getpages_async() already always calls > the iodone callback but it would return void too after the above changes. Looking at the existing error handling in sendfile, I think there is a complication: in the case of a synchronous error, vn_sendfile() has to unwire the input pages; in the case of an asynchronous error, vn_sendfile() will have bound the pages to mbufs in the socket's send buffer, and the unwiring will happen in sendfile_free_mext() when the buffer is drained as a result of a connection abort. In other words, sendfile_iodone() has to be able to distinguish between synchronous and asynchronous error cases in order to correctly release resources, so the proposed solution doesn't seem quite sufficient. > If that is agreeable to you and Gleb then I'll make the changes. > > -Chuck