From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [PATCH 8/9] fsfreeze: add vfs ioctl to check freeze state Date: Mon, 8 Oct 2012 17:05:16 +0200 Message-ID: <20121008150516.GE9243@quack.suse.cz> References: <1349414653.7347.2.camel@nexus.lab.ntt.co.jp> <1349415809.7347.15.camel@nexus.lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Al Viro , Josef Bacik , Eric Sandeen , Dave Chinner , Christoph Hellwig , Jan Kara , linux-fsdevel@vger.kernel.org To: Fernando Luis =?iso-8859-1?Q?V=E1zquez?= Cao Return-path: Received: from cantor2.suse.de ([195.135.220.15]:59899 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752079Ab2JHPFW (ORCPT ); Mon, 8 Oct 2012 11:05:22 -0400 Content-Disposition: inline In-Reply-To: <1349415809.7347.15.camel@nexus.lab.ntt.co.jp> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri 05-10-12 14:43:29, Fernando Luis V=E1zquez Cao wrote: > The FIISFROZEN ioctl can be use by HA and monitoring software to chec= k > the freeze state of a mounted filesystem. I was thinking about this and your use case and I thing this is just = a wrong way to fix a problem with your HA application. E.g. in case you w= ould "umount -l" your filesystem, you would hit the same problem as in prese= nce of freezing and the ioctl won't help you. Now I understand that in your specific use case you likely don't need to deal with lazy umounts but w= e shouldn't add an interface just to accomodate one use case and later fi= nd out we need another interface for slightly different one. So what you rather seem to need is some interface which allows you to investigate filesystems that are mounted on a block device but not atta= ched anywhere in the namespace. Would that be enough for you? If yes, some extension to /proc/self/mountinfo to do this should be possible... Honza > Cc: Josef Bacik > Cc: Eric Sandeen > Cc: Christoph Hellwig > Cc: Jan Kara > Cc: Dave Chinner > Signed-off-by: Fernando Luis Vazquez Cao > --- >=20 > diff -urNp linux-3.6-orig/fs/compat_ioctl.c linux-3.6/fs/compat_ioctl= =2Ec > --- linux-3.6-orig/fs/compat_ioctl.c 2012-10-01 08:47:46.000000000 +0= 900 > +++ linux-3.6/fs/compat_ioctl.c 2012-10-04 17:29:50.060102922 +0900 > @@ -885,6 +885,7 @@ COMPATIBLE_IOCTL(FIGETBSZ) > /* 'X' - originally XFS but some now in the VFS */ > COMPATIBLE_IOCTL(FIFREEZE) > COMPATIBLE_IOCTL(FITHAW) > +COMPATIBLE_IOCTL(FIISFROZEN) > COMPATIBLE_IOCTL(KDGETKEYCODE) > COMPATIBLE_IOCTL(KDSETKEYCODE) > COMPATIBLE_IOCTL(KDGKBTYPE) > diff -urNp linux-3.6-orig/fs/ioctl.c linux-3.6/fs/ioctl.c > --- linux-3.6-orig/fs/ioctl.c 2012-10-01 08:47:46.000000000 +0900 > +++ linux-3.6/fs/ioctl.c 2012-10-04 17:29:50.060102922 +0900 > @@ -536,6 +536,16 @@ static int ioctl_fsthaw(struct file *fil > return thaw_super(sb); > } > =20 > +static int ioctl_fs_isfrozen(struct file *filp) > +{ > + struct super_block *sb =3D filp->f_path.dentry->d_inode->i_sb; > + > + if (!capable(CAP_SYS_ADMIN)) > + return -EPERM; > + > + return isfrozen_super(sb); > +} > + > /* > * When you add any new common ioctls to the switches above and belo= w > * please update compat_sys_ioctl() too. > @@ -585,6 +595,12 @@ int do_vfs_ioctl(struct file *filp, unsi > error =3D ioctl_fsthaw(filp); > break; > =20 > + case FIISFROZEN: > + error =3D ioctl_fs_isfrozen(filp); > + if (error >=3D 0) > + return put_user(error, (int __user *)arg); > + break; > + > case FS_IOC_FIEMAP: > return ioctl_fiemap(filp, arg); > =20 > diff -urNp linux-3.6-orig/fs/super.c linux-3.6/fs/super.c > --- linux-3.6-orig/fs/super.c 2012-10-04 17:28:45.440102318 +0900 > +++ linux-3.6/fs/super.c 2012-10-04 17:29:50.060102922 +0900 > @@ -1553,3 +1553,8 @@ void emergency_thaw_all(void) > schedule_work(work); > } > } > + > +int isfrozen_super(struct super_block *sb) > +{ > + return sb->s_writers.frozen > SB_UNFROZEN ? 1 : 0; > +} > diff -urNp linux-3.6-orig/include/linux/fs.h linux-3.6/include/linux/= fs.h > --- linux-3.6-orig/include/linux/fs.h 2012-10-04 17:28:45.440102318 += 0900 > +++ linux-3.6/include/linux/fs.h 2012-10-04 17:29:50.060102922 +0900 > @@ -342,6 +342,7 @@ struct inodes_stat_t { > #define FIFREEZE _IOWR('X', 119, int) /* Freeze */ > #define FITHAW _IOWR('X', 120, int) /* Thaw */ > #define FITRIM _IOWR('X', 121, struct fstrim_range) /* Trim */ > +#define FIISFROZEN _IOR('X', 122, int) /* get sb freeze state */ > =20 > #define FS_IOC_GETFLAGS _IOR('f', 1, long) > #define FS_IOC_SETFLAGS _IOW('f', 2, long) > @@ -2086,6 +2087,7 @@ extern int fd_statfs(int, struct kstatfs > extern int vfs_ustat(dev_t, struct kstatfs *); > extern int freeze_super(struct super_block *super); > extern int thaw_super(struct super_block *super); > +extern int isfrozen_super(struct super_block *sb); > extern bool our_mnt(struct vfsmount *mnt); > =20 > extern int current_umask(void); >=20 >=20 --=20 Jan Kara SUSE Labs, CR -- 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