From mboxrd@z Thu Jan 1 00:00:00 1970 From: Herbert Poetzl Subject: Re: [RFC][PATCH 01/27] Add vfsmount writer count Date: Thu, 8 Jun 2006 12:33:42 +0200 Message-ID: <20060608103342.GA11996@MAIL.13thfloor.at> References: <20060608001013.0D041507@localhost.localdomain> <20060608001014.5E868168@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, viro@ftp.linux.org.uk, hch@infradead.org, trond.myklebust@fys.uio.no Return-path: Received: from MAIL.13thfloor.at ([212.16.62.50]:16520 "EHLO mail.13thfloor.at") by vger.kernel.org with ESMTP id S932152AbWFHKdn (ORCPT ); Thu, 8 Jun 2006 06:33:43 -0400 To: Dave Hansen Content-Disposition: inline In-Reply-To: <20060608001014.5E868168@localhost.localdomain> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Wed, Jun 07, 2006 at 05:10:14PM -0700, Dave Hansen wrote: > > This allows a vfsmount to keep track of how many instances > of files open for write there are at a given time. This > will be useful if it is ever desired to change a mount > from r/w to r/o at runtime. > > A mount can also potentially refuse to allow writers; this > is why mnt_want_write() has a return value. However, that > functionality will be added later in the series. For now, > always allow new writers. > > Signed-off-by: Dave Hansen > --- > > lxc-dave/fs/namespace.c | 1 + > lxc-dave/include/linux/mount.h | 14 ++++++++++++++ > 2 files changed, 15 insertions(+) > > diff -puN fs/namespace.c~convert-permission-to-file-and-vfs fs/namespace.c > --- lxc/fs/namespace.c~convert-permission-to-file-and-vfs 2006-06-07 16:53:11.000000000 -0700 > +++ lxc-dave/fs/namespace.c 2006-06-07 16:53:11.000000000 -0700 > @@ -66,6 +66,7 @@ struct vfsmount *alloc_vfsmnt(const char > if (mnt) { > memset(mnt, 0, sizeof(struct vfsmount)); > atomic_set(&mnt->mnt_count, 1); > + /* atomic_set(&mnt->writer_count, 0); */ IMHO you should not assume that atomic_set(,0) will not be required after memset(,0,), so doing it here is the right thing (tm) > INIT_LIST_HEAD(&mnt->mnt_hash); > INIT_LIST_HEAD(&mnt->mnt_child); > INIT_LIST_HEAD(&mnt->mnt_mounts); > diff -puN include/linux/mount.h~convert-permission-to-file-and-vfs include/linux/mount.h > --- lxc/include/linux/mount.h~convert-permission-to-file-and-vfs 2006-06-07 16:53:11.000000000 -0700 > +++ lxc-dave/include/linux/mount.h 2006-06-07 16:53:11.000000000 -0700 > @@ -12,6 +12,8 @@ > #define _LINUX_MOUNT_H > #ifdef __KERNEL__ > > +#include > +#include > #include > #include > #include > @@ -38,6 +40,7 @@ struct vfsmount { > struct list_head mnt_mounts; /* list of children, anchored here */ > struct list_head mnt_child; /* and going through their mnt_child */ > atomic_t mnt_count; > + atomic_t mnt_writers; > int mnt_flags; > int mnt_expiry_mark; /* true if marked for expiry */ > char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */ > @@ -58,6 +61,17 @@ static inline struct vfsmount *mntget(st > return mnt; > } > > +static inline int mnt_want_write(struct vfsmount *mnt) > +{ > + atomic_inc(&mnt->mnt_writers); > + return 0; > +} > + > +static inline void mnt_drop_write(struct vfsmount *mnt) > +{ > + atomic_dec(&mnt->mnt_writers); > +} > + > extern void mntput_no_expire(struct vfsmount *mnt); > extern void mnt_pin(struct vfsmount *mnt); > extern void mnt_unpin(struct vfsmount *mnt); > diff -L convert-permission-to-file-and-vfs -puN /dev/null /dev/null > diff -L convert-permission-to-file-and-vfs.patch -puN /dev/null /dev/null > _ best, Herbert