From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: [RFC][PATCH 01/27] Add vfsmount writer count Date: Wed, 07 Jun 2006 17:10:14 -0700 Message-ID: <20060608001014.5E868168@localhost.localdomain> References: <20060608001013.0D041507@localhost.localdomain> Cc: herbert@13thfloor.at, viro@ftp.linux.org.uk, hch@infradead.org, trond.myklebust@fys.uio.no, Dave Hansen Return-path: Received: from e35.co.us.ibm.com ([32.97.110.153]:731 "EHLO e35.co.us.ibm.com") by vger.kernel.org with ESMTP id S932485AbWFHAK3 (ORCPT ); Wed, 7 Jun 2006 20:10:29 -0400 Received: from westrelay02.boulder.ibm.com (westrelay02.boulder.ibm.com [9.17.195.11]) by e35.co.us.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k580AOuU016648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Jun 2006 20:10:24 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by westrelay02.boulder.ibm.com (8.13.6/NCO/VER7.0) with ESMTP id k580AEqX273654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Jun 2006 18:10:19 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k580AH5T008043 for ; Wed, 7 Jun 2006 18:10:18 -0600 To: linux-fsdevel@vger.kernel.org In-Reply-To: <20060608001013.0D041507@localhost.localdomain> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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); */ 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 _