From owner-svn-src-head@freebsd.org Thu Jul 30 22:13:32 2020 Return-Path: Delivered-To: svn-src-head@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 9B27C3684B3; Thu, 30 Jul 2020 22:13:32 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4BHl6g64T1z41TH; Thu, 30 Jul 2020 22:13:31 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-ot1-f68.google.com with SMTP id q9so5619483oth.5; Thu, 30 Jul 2020 15:13:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=KNd8UhbNyp+BadnkEJlAptn2TkUaasQPbQVL74ntPhQ=; b=es110Lw6VjpMuaUZ1/3c2Si2N53gIG8uE3Gyb+veaczIkQL/U+os5WJ1G8ib3lZH7E n0EzPeCXkwHbsT6DegLMvE4yFpYF5w5ue27v9roBqg1pOSRH0oaOstyByi+VUwGYQQPG lsq/HZzSfWGod6cnBuwaDqLhsamIyMxfnhVPXYKNQiI4bGbEK5Zr87Ge2dfNZ419zzmo gLLQU8tKd7KnEhBkdbI4X/vxvqcVdKYJojqwKrq7R+QrNmbUx4YgPYdW3I7xltHDXHqp Y/mrZ5Vuh0lZnJ4WtaqZ4CWZThyJnvCqDOIhqQDd69NefGI3Ezi8Dvf9ywVbVQMhcWP0 S3ag== X-Gm-Message-State: AOAM531aO+4WsxTymHawF95mr1ALFpiaH7cvTkCnaqLMhUMk5/jVm9HB gFmL76vRl40YVZERHcUarJnNW2t6 X-Google-Smtp-Source: ABdhPJz5lLszaVrPt0+Ykj+C90x/jgMHfFhoaKwg8dBheWdFZUF8sApe3wuuudel6Oc4nTbfBf7vgg== X-Received: by 2002:a9d:355:: with SMTP id 79mr567526otv.330.1596147210499; Thu, 30 Jul 2020 15:13:30 -0700 (PDT) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com. [209.85.210.51]) by smtp.gmail.com with ESMTPSA id m13sm1041349otf.43.2020.07.30.15.13.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jul 2020 15:13:30 -0700 (PDT) Received: by mail-ot1-f51.google.com with SMTP id a65so12113535otc.8; Thu, 30 Jul 2020 15:13:30 -0700 (PDT) X-Received: by 2002:a9d:3b61:: with SMTP id z88mr641237otb.135.1596147209962; Thu, 30 Jul 2020 15:13:29 -0700 (PDT) MIME-Version: 1.0 References: <202007241734.06OHY53J080448@repo.freebsd.org> <20200728184152.GH2551@kib.kiev.ua> In-Reply-To: <20200728184152.GH2551@kib.kiev.ua> Reply-To: cem@freebsd.org From: Conrad Meyer Date: Thu, 30 Jul 2020 15:13:19 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r363482 - in head/sys: kern sys To: Konstantin Belousov Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4BHl6g64T1z41TH X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of csecem@gmail.com designates 209.85.210.68 as permitted sender) smtp.mailfrom=csecem@gmail.com X-Spamd-Result: default: False [-1.55 / 15.00]; HAS_REPLYTO(0.00)[cem@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[209.85.210.68:from]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; REPLYTO_ADDR_EQ_FROM(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.13)[-0.131]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[cem@freebsd.org,csecem@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.47)[-0.468]; FROM_NEQ_ENVFROM(0.00)[cem@freebsd.org,csecem@gmail.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-0.95)[-0.955]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.210.68:from]; RCVD_TLS_ALL(0.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jul 2020 22:13:32 -0000 Hi Konstantin, On Tue, Jul 28, 2020 at 11:42 AM Konstantin Belousov wrote: > > On Fri, Jul 24, 2020 at 05:34:05PM +0000, Conrad Meyer wrote: > > ... > > --- head/sys/kern/vfs_bio.c Fri Jul 24 17:32:10 2020 (r363481) > > +++ head/sys/kern/vfs_bio.c Fri Jul 24 17:34:04 2020 (r363482) > > @@ -3849,7 +3849,7 @@ getblkx(struct vnode *vp, daddr_t blkno, daddr_t dblkn > > ... > > + /* Attempt lockless lookup first. */ > > + bp = gbincore_unlocked(bo, blkno); > > + if (bp == NULL) > > + goto newbuf_unlocked; > > + > > + lockflags = LK_EXCLUSIVE | LK_SLEEPFAIL | > > + ((flags & GB_LOCK_NOWAIT) ? LK_NOWAIT : 0); > > + > > + error = BUF_TIMELOCK(bp, lockflags, NULL, "getblku", slpflag, > > + slptimeo); > I realized that this is not safe. There is an ordering between buffer > types that defines which order buffer locks should obey. For instance, > on UFS the critical order is inode buffer -> snaplk -> cg buffer, or > data block -> indirect data block. Since buffer identity can change under > us, we might end up waiting for a lock of type that is incompatible with > the currently owned lock. > > I think the easiest fix is to use LK_NOWAIT always, after all it is lockless > path. ERESTART/EINTR checks below than can be removed. Thanks, that makes sense to me. Please see https://reviews.freebsd.org/D25898 . (For the UFS scenario, I think this requires an on-disk sector changing identity from one kind to another? I believe lblknos are mostly statically typed in UFS, but it could happen with data blocks and indirect blocks? Of course, UFS is not the only filesystem.) Best regards, Conrad