|
|
|
[PATCH 6/8] fsfreeze: add vfs ioctl to check freeze state | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
The FIISFROZEN ioctl can be use by HA and monitoring software to check
the freeze state of a mounted filesystem.
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 vfs-orig/fs/compat_ioctl.c vfs/fs/compat_ioctl.c
--- vfs-orig/fs/compat_ioctl.c 2012-07-04 18:57:54.000000000 +0900
+++ vfs/fs/compat_ioctl.c 2012-07-12 17:25:37.592626439 +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 vfs-orig/fs/ioctl.c vfs/fs/ioctl.c
--- vfs-orig/fs/ioctl.c 2012-07-04 18:57:54.000000000 +0900
+++ vfs/fs/ioctl.c 2012-07-12 17:25:37.592626439 +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 vfs-orig/fs/super.c vfs/fs/super.c
--- vfs-orig/fs/super.c 2012-07-12 17:24:40.096620156 +0900
+++ vfs/fs/super.c 2012-07-12 17:25:37.600627115 +0900
@@ -1336,3 +1336,8 @@ void emergency_thaw_all(void)
schedule_work(work);
}
}
+
+int isfrozen_super(struct super_block *sb)
+{
+ return sb->s_frozen > SB_UNFROZEN ? 1 : 0;
+}
diff -urNp vfs-orig/include/linux/fs.h vfs/include/linux/fs.h
--- vfs-orig/include/linux/fs.h 2012-07-12 17:24:40.116622271 +0900
+++ vfs/include/linux/fs.h 2012-07-12 17:25:37.600627115 +0900
@@ -340,6 +340,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)
@@ -1947,6 +1948,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);
--
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
[Linux Ext4 Filesystem] [Ecryptfs] [AutoFS] [Kernel Newbies] [Share Photos] [Security] [Netfilter] [Bugtraq] [Photo] [Yosemite] [Yosemite News] [MIPS Linux] [ARM Linux] [Linux Security] [Linux Cachefs] [Reiser Filesystem] [Linux RAID] [Samba] [Video 4 Linux] [Device Mapper] [CEPH Filesystem]
![]() |