Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Dec 2021 17:38:59 +0300
From:      Gleb Popov <arrowd@freebsd.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: nmount(2) returns undocumented EDEADLK
Message-ID:  <CALH631kC2ZP_AXL9QyKD%2BgYaDOfqMRdH-3NBuVMyvcQctfkzeQ@mail.gmail.com>
In-Reply-To: <Ya3dsAJWKKctVXZs@kib.kiev.ua>
References:  <CALH631mzdOFtOqwnBgQgGfOiX-CNfME%2Boa=-XT_JK0ws8A1t3Q@mail.gmail.com> <Ya3dsAJWKKctVXZs@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000002c8f4405d27b39f1
Content-Type: text/plain; charset="UTF-8"

On Mon, Dec 6, 2021 at 12:54 PM Konstantin Belousov <kostikbel@gmail.com>
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<><invalid>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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALH631kC2ZP_AXL9QyKD%2BgYaDOfqMRdH-3NBuVMyvcQctfkzeQ>