From nobody Mon Dec 6 09:53:52 2021 X-Original-To: freebsd-hackers@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 318B418D61E8 for ; Mon, 6 Dec 2021 09:54:00 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4J6zKM6T0pz4fH8; Mon, 6 Dec 2021 09:53:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 1B69rqVE041383 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 6 Dec 2021 11:53:55 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 1B69rqVE041383 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 1B69rque041382; Mon, 6 Dec 2021 11:53:52 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 6 Dec 2021 11:53:52 +0200 From: Konstantin Belousov To: Gleb Popov Cc: freebsd-hackers Subject: Re: nmount(2) returns undocumented EDEADLK Message-ID: References: List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4J6zKM6T0pz4fH8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Mon, Dec 06, 2021 at 10:13:59AM +0300, Gleb Popov wrote: > Hey hackers. > > I have a little program that calls the nmount(2) function in the following > way: > > - First it mounts nullfs with fstype="nullfs", from="/src" and > fspath="/dst". This works fine. > - Next it tries to remount it as readonly by adding MNT_UPDATE and > MNT_RDONLY to the nmount(2) call. This call fails with errno=11 (EDEADLK) > for some reason. > > The relevant part of kdump: > > 19909 coolmount CALL nmount(0x801610380,0x6,0<>0) > 19909 coolmount NAMI > "/var/db/collaboraonline/child-roots/hQN4KQVIpWNA7Pic" > 19909 coolmount NAMI > "/var/db/collaboraonline/child-roots/hQN4KQVIpWNA7Pic" > 19909 coolmount NAMI "/var/db/collaboraonline/systemplate" > 19909 coolmount RET nmount -1 errno 11 Resource deadlock avoided > > Does anyone have an idea what's wrong with this? I can try coming up with > minimal repro if needed. First, nullfs does not support remounting to ro/rw. But this is not likely an issue with your code, because you do get EDEADLK. EDEADLK means that you are trying to mount nullfs on itself, see the check at line 150 of the file sys/fs/nullfs/null_vfsops.c. Most likely you did not properly pass MNT_UPDATE, but then even if you did, it would not help because, as noted, nullfs does not support remount to ro.