Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Jan 2012 12:21:04 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Mikolaj Golub <trociny@freebsd.org>
Cc:        svn-src-head@freebsd.org, Jaakko Heinonen <jh@freebsd.org>, svn-src-all@freebsd.org, src-committers@freebsd.org, Kevin Lo <kevlo@freebsd.org>
Subject:   Re: svn commit: r230252 - head/sys/fs/tmpfs
Message-ID:  <20120124102104.GA17476@deviant.kiev.zoral.com.ua>
In-Reply-To: <86vco2yvrt.fsf@kopusha.home.net>
References:  <201201170125.q0H1PrlJ061058@svn.freebsd.org> <20120117171031.GA2316@a91-153-116-96.elisa-laajakaista.fi> <86obtvvr4v.fsf@kopusha.home.net> <20120122134218.GA2247@a91-153-116-96.elisa-laajakaista.fi> <86lioztzh5.fsf@kopusha.home.net> <20120123153457.GA2246@a91-153-116-96.elisa-laajakaista.fi> <86vco2yvrt.fsf@kopusha.home.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jan 23, 2012 at 11:05:42PM +0200, Mikolaj Golub wrote:
>=20
> On Mon, 23 Jan 2012 17:34:57 +0200 Jaakko Heinonen wrote:
>=20
>  JH> On 2012-01-22, Mikolaj Golub wrote:
>  >> Also, may be we should allow remounting ro (and may be some othe opti=
ons) for
>  >> tmpfs?
>=20
>  JH> Yes, the patch below does that. I suspect that flipping the MNT_RDON=
LY
>  JH> flag may be enough for tmpfs but I am not sure.
>=20
> I see two issues with this patch:
>=20
> 1) 'mount -u -o rw /mnt' does not upgrade to rw, although it returns succ=
ess.
>=20
> 2) if you have a file open for write, after remounting ro you still can w=
rite
> to the file. The expected behaviour: remount fails with EBUSY if force op=
tion
> is not specified; after remounting with force writing to the fail fails w=
ith EIO.
>=20
> I think when remounting ro you should call vflush(), something like below:
>=20
> 	flags =3D WRITECLOSE;
> 	if (mp->mnt_flag & MNT_FORCE)
> 		flags |=3D FORCECLOSE;
> 	error =3D vflush(mp, 0, flags, curthread);
> 	if (error !=3D 0)
> 		return (error);
> 	MNT_ILOCK(mp);
> 	mp->mnt_flag |=3D MNT_RDONLY;
> 	MNT_IUNLOCK(mp);
>=20
> and when upgrading to rw reset MNT_RDONLY flag:
>=20
> 	MNT_ILOCK(mp);
> 	mp->mnt_flag &=3D ~MNT_RDONLY;
> 	MNT_IUNLOCK(mp);
>=20
> I have no idea if something else is needed for tmpfs.
Yes, this is needed but not enough.

Since other writeable opens may happen during the vflush(), you might still
end up with the mount point which is not safe to set MNT_RDONLY flag.

FFS suspends the writes on the mp while doing remount. Other filesystems
like tmpfs and nfs could also perform suspend during remounts and unmounts,
but the complications are the atime and deferred inactivations. See
ufs/ffs/ffs_snapshot.c:process_deferred_inactive(), the handling of
IN_LAZYACCESS and ufs_inactive().

--J2SCkAp4GZ/dPZZf
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk8ehhAACgkQC3+MBN1Mb4gQ/QCgxb9f+y+6TvmcqNbkINgwJdvt
1wUAn0Z4CQXetSlLYMlJHt9lOSrFLruC
=4ICW
-----END PGP SIGNATURE-----

--J2SCkAp4GZ/dPZZf--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120124102104.GA17476>