Re: [PATCH 8/9] fsfreeze: add vfs ioctl to check freeze state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri 05-10-12 14:43:29, Fernando Luis Vázquez Cao wrote:
> The FIISFROZEN ioctl can be use by HA and monitoring software to check
> 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 would
"umount -l" your filesystem, you would hit the same problem as in presence
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 we
shouldn't add an interface just to accomodate one use case and later find
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 attached
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 <jbacik@xxxxxxxxxxxx>
> Cc: Eric Sandeen <sandeen@xxxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx>
> Cc: Jan Kara <jack@xxxxxxx>
> Cc: Dave Chinner <dchinner@xxxxxxxxxx>
> Signed-off-by: Fernando Luis Vazquez Cao <fernando@xxxxxxxxxxxxx>
> ---
> 
> diff -urNp linux-3.6-orig/fs/compat_ioctl.c linux-3.6/fs/compat_ioctl.c
> --- linux-3.6-orig/fs/compat_ioctl.c	2012-10-01 08:47:46.000000000 +0900
> +++ 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);
>  }
>  
> +static int ioctl_fs_isfrozen(struct file *filp)
> +{
> +	struct super_block *sb = 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 below
>   * please update compat_sys_ioctl() too.
> @@ -585,6 +595,12 @@ int do_vfs_ioctl(struct file *filp, unsi
>  		error = ioctl_fsthaw(filp);
>  		break;
>  
> +	case FIISFROZEN:
> +		error = ioctl_fs_isfrozen(filp);
> +		if (error >= 0)
> +			return put_user(error, (int __user *)arg);
> +		break;
> +
>  	case FS_IOC_FIEMAP:
>  		return ioctl_fiemap(filp, arg);
>  
> 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 */
>  
>  #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);
>  
>  extern int current_umask(void);
> 
> 
-- 
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux