From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Waychison Subject: Re: [PATCH 13/28] VFS: Introduce soft reference counts Date: Mon, 25 Oct 2004 13:25:33 -0400 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <417D370D.3090700@sun.com> References: <10987154731896@sun.com> <10987155032816@sun.com> <417D35F0.1070501@kolumbus.fi> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, raven@themaw.net Return-path: Received: from nwkea-mail-1.sun.com ([192.18.42.13]:62419 "EHLO nwkea-mail-1.sun.com") by vger.kernel.org with ESMTP id S261153AbUJYRZy (ORCPT ); Mon, 25 Oct 2004 13:25:54 -0400 Received: from phys-mpk-2 ([129.146.11.82]) by nwkea-mail-1.sun.com (8.12.10/8.12.9) with ESMTP id i9PHPfsL003774 for ; Mon, 25 Oct 2004 10:25:44 -0700 (PDT) Received: from conversion-daemon.mpk-mail1.sfbay.sun.com by mpk-mail1.sfbay.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0I6500201HJKSF@mpk-mail1.sfbay.sun.com> (original mail from Michael.Waychison@Sun.COM) for linux-fsdevel@vger.kernel.org; Mon, 25 Oct 2004 10:25:39 -0700 (PDT) In-reply-to: <417D35F0.1070501@kolumbus.fi> To: =?ISO-8859-1?Q?Mika_Penttil=E4?= List-Id: linux-fsdevel.vger.kernel.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mika Penttil=E4 wrote: > Mike Waychison wrote: >=20 >> This patch introduces the concept of a 'soft' reference count for a >> vfsmount. >> This type of reference count allows for references to be held on >> mountpoints >> that do not affect their busy states for userland unmounting. Some = might >> argue that this is wrong because 'when I unmount a filesystem, I wan= t the >> resources associated with it to go away too', but this way of thinki= ng >> was >> deprecated with the addition of namespaces and --bind back in the 2.= 4 >> series. >> >> A future addition may see a callback mechanism so that in kernel use= rs >> can >> use a given mountpoint and have it deregistered some way (quota and >> accounting come to mind). >> >> These soft reference counts are used by a later patch that adds an >> interface >> for holding and manipulating mountpoints using filedescriptors. >> >> Signed-off-by: Mike Waychison >> >> +static inline struct vfsmount *mntsoftget(struct vfsmount *mnt) >> +{ >> + if (mnt) { >> + read_lock(&vfsmountref_lock); >> + atomic_inc(&mnt->mnt_softcount); >> + mntgroupget(mnt); >> + read_unlock(&vfsmountref_lock); >> + } >> + return mnt; >> +} >> + >> +static inline void mntsoftput(struct vfsmount *mnt) >> +{ >> + struct vfsmount *cleanup; >> + might_sleep(); >> + if (mnt) { >> + if (atomic_dec_and_test(&mnt->mnt_count)) >> + __mntput(mnt); >> + read_lock(&vfsmountref_lock); >> + cleanup =3D mntgroupput(mnt); >> + atomic_dec(&mnt->mnt_softcount); >> + read_unlock(&vfsmountref_lock); >> + if (cleanup) >> + __mntgroupput(cleanup); >> + } >> +} >> + >> extern void free_vfsmnt(struct vfsmount *mnt); >> =20 >> > What is this against? What are mntgroupput and mntgroupget?=20 This is against patch [PATCH 11/28] VFS: Allow detachable subtrees. In that patch, mntgroup(get|put) handles the count of all non-glue references for a given tree of vfsmounts. > Why does soft put decrement mnt_count which isn't increment by soft g= et?=20 Ah, thanks for pointing that out. It got messed up when I created the patchset from the bk tree. Will fix. > How do > soft references allow userland umount? I don't see soft references us= ed > anywhere... Soft references are used by the mountpoint file descriptor patch [14/28]. They allow references to be had on a vfsmount such that the mountpoint itself is not kept busy in the namespace. This allows a program to 'grab a mountpoint' by a magic file (gotten by sys_mountfd), and perform ops on it. The mountfd holds a reference to the vfsmount, but it doesn't keep userspace from trying to umount(2) the path. Does that help? - -- Mike Waychison Sun Microsystems, Inc. 1 (650) 352-5299 voice 1 (416) 202-8336 voice ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NOTICE: The opinions expressed in this email are held by me, and may not represent the views of Sun Microsystems, Inc. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBfTcNdQs4kOxk3/MRAnZwAKCTv7SMsT/+o4WLMJGapFVKURsbNwCeI+iF sZCOzRRNcnesK8rFN2haEww=3D =3DeFwD -----END PGP SIGNATURE----- - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html