From nobody Mon Dec 6 14:38:59 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 93FE018B27DA for ; Mon, 6 Dec 2021 14:39:33 +0000 (UTC) (envelope-from 6yearold@gmail.com) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J75fs3Xqwz3rGs for ; Mon, 6 Dec 2021 14:39:33 +0000 (UTC) (envelope-from 6yearold@gmail.com) Received: by mail-lf1-f45.google.com with SMTP id z21so3752398lfu.8 for ; Mon, 06 Dec 2021 06:39:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bfVDd/iLIq1s0DcmTLBKLwrQRw6t1A2YyOzUlTMfPvQ=; b=P84ogxfXvT/sKHKKl/HSenqK/GFXXiq1tOHZ3/+flaE9brIeMYcnX0aPoBHPBoHfvP hYO8duZ1LOKRsnBqN1X6kavjGZWi9SBJ0jqH6LctRwTjqpgj+2753pzSoqFrXlGzz+uU mg26CvpF63/AXkP5zDRTtB1Q0CcpcTFgQBMKetZltXuf2p2F4kxsArXC5GdkRN8Ggyif gdT5gp4flOCt7a2TnQwQ1/cJAanCq5gcSAhAkn5GKoIu4vQsmNg1YK0DSsDY9Av8z+hk U+jnXruGCM9QFJ4xo4ugGWLCuyU7nBlpuF5lyeCagWNtwaND4XTjFtHuBfYXfL2ADPiH lSjw== X-Gm-Message-State: AOAM533YM3fIWWPriEicYDhzPEF/dJxq8F3InUISlGtxbpNeNtnNtKNb IBwQDDReBEMjPKDUr7JLS+rx7LybeDkt+A== X-Google-Smtp-Source: ABdhPJxxrGQvJ7pfWd83cIXML7peFcWSxKyp0kEEguePFKgisMeVqDzTosaZPcHJ/9gEd9AnbKZG7g== X-Received: by 2002:a05:6512:344d:: with SMTP id j13mr37697534lfr.347.1638801566072; Mon, 06 Dec 2021 06:39:26 -0800 (PST) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com. [209.85.208.171]) by smtp.gmail.com with ESMTPSA id z19sm1368790lfd.68.2021.12.06.06.39.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Dec 2021 06:39:25 -0800 (PST) Received: by mail-lj1-f171.google.com with SMTP id k2so21417423lji.4 for ; Mon, 06 Dec 2021 06:39:25 -0800 (PST) X-Received: by 2002:a2e:a365:: with SMTP id i5mr35876522ljn.335.1638801565583; Mon, 06 Dec 2021 06:39:25 -0800 (PST) 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 References: In-Reply-To: From: Gleb Popov Date: Mon, 6 Dec 2021 17:38:59 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: nmount(2) returns undocumented EDEADLK To: Konstantin Belousov Cc: freebsd-hackers Content-Type: multipart/alternative; boundary="0000000000002c8f4405d27b39f1" X-Rspamd-Queue-Id: 4J75fs3Xqwz3rGs X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: Y --0000000000002c8f4405d27b39f1 Content-Type: text/plain; charset="UTF-8" On Mon, Dec 6, 2021 at 12:54 PM Konstantin Belousov wrote: > 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. > Indeed, I made a mistake in the code so the flags parameter was always 0. After fixing it I'm now getting EOPNOTSUPP. If remounting as ro is not supported, what are my options? Is there any semantic difference between remounting with ro and unmounting/mounting again? --0000000000002c8f4405d27b39f1--