From nobody Thu Nov 25 19:35:10 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 487C018A4D66; Thu, 25 Nov 2021 19:35:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J0Sl2433cz3CGb; Thu, 25 Nov 2021 19:35:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 44A972339A; Thu, 25 Nov 2021 19:35:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1APJZAsK094732; Thu, 25 Nov 2021 19:35:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1APJZA1e094731; Thu, 25 Nov 2021 19:35:10 GMT (envelope-from git) Date: Thu, 25 Nov 2021 19:35:10 GMT Message-Id: <202111251935.1APJZA1e094731@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: b19740f4ce7a - main - swap_pager: lock vnode in swapdev_strategy() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b19740f4ce7a542783f87de2fee48476a7801d86 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637868910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=preGt6uDiiBfBmsJlH93L343Rj3ybds5elpLMuTEh10=; b=LO1kTfIS2xuio8jSUxCpMpaTEYTSergIvOh7qVv9ZurvZrUFLntfhS/pG+NA5h7if0miqA 1ibKMDJB0V33OsW7OHGFeQ7uFy9BYxRuy2rOtK8JIsCXw8lRZ+VpjeQ6Rqif7c6Lsq5aXN dJzDZnryy+M9446iTDa97QIDUFahaDoIz6A4BkqnwbetMDXPZ4d/VveNMQHGyg+i3L9mcr dLaq+5eANUPxazBs96QQPEGQ11F1bUmEtiwmWQ3IHYD/76rSfnv89aBbRG9vFgvh1x72uo VlmvkRcvFcqx6GohakpPk+FZ1c+Q3XMxvqzScUPRU5A5+sDq6RLopWFrnRl32w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637868910; a=rsa-sha256; cv=none; b=eLER3KtzhtHMzxeppe6OnPAU3YRB3WYDQpSYJBbHKRpQlgT+illzxxwPMBifDYwPhE9jm8 sUGEkASXabyS3htK+UBrRJGpsb0TdBxNHJgF1xu203MEsj+GYSsf1sPoNUeEiv4FpxGKPO cr8hpfEhHNjZ3eR9GbAD0/my45Ky9QpoCS520KodfSrgtLRWp2inZjYDphCAimUqTDV3M5 xy9WZsYhdS0utq3lSCjayh1tNpZm7hsTZFUyyMYYnWgfrR7JJ56aI/WM7Ctf58SACdmT9R 5XAbCoMqFYH3K/gosZgJB1ffYmOeqGaeFFB5sAQY7QHv78D7Mml3vU9EVVB70A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b19740f4ce7a542783f87de2fee48476a7801d86 commit b19740f4ce7a542783f87de2fee48476a7801d86 Author: Konstantin Belousov AuthorDate: 2021-11-24 11:26:46 +0000 Commit: Konstantin Belousov CommitDate: 2021-11-25 19:34:50 +0000 swap_pager: lock vnode in swapdev_strategy() VOP_STRATEGY() requires locked vnode. Note that we lock the swap vnode while pages are busy, but this would only cause real LoR if pages belong to the swap vnode, which must not be the case for correct use. Reported and tested by: peterj Reviewed by: markj MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33119 --- sys/vm/swap_pager.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 880e2a1894df..6daedd02649d 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -3043,16 +3043,19 @@ swapdev_strategy(struct buf *bp, struct swdevt *sp) vp2 = sp->sw_id; vhold(vp2); if (bp->b_iocmd == BIO_WRITE) { + vn_lock(vp2, LK_EXCLUSIVE | LK_RETRY); if (bp->b_bufobj) bufobj_wdrop(bp->b_bufobj); bufobj_wref(&vp2->v_bufobj); + } else { + vn_lock(vp2, LK_SHARED | LK_RETRY); } if (bp->b_bufobj != &vp2->v_bufobj) bp->b_bufobj = &vp2->v_bufobj; bp->b_vp = vp2; bp->b_iooffset = dbtob(bp->b_blkno); bstrategy(bp); - return; + VOP_UNLOCK(vp2); } static void