Currently the only way to sync a single super_block (and not all of them via sync(2)) is via the BLKFLSBUF ioctl on the block device. That also invalidates the bdev mapping, which isn't usually desireable, and it doesn't work for non-block file systems. The ability to sync a single mount can be useful for both applications and administrators (e.g., when other mounts on the system are hung). Introduce a simple ioctl to sync the super associated with an open file. Pass any error returned by sync_filesystem() back to the user. Signed-off-by: Sage Weil <sage@xxxxxxxxxxxx> --- fs/ioctl.c | 9 +++++++++ include/linux/fs.h | 1 + 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index 2d140a7..2aabb19 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -593,6 +593,15 @@ int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, case FS_IOC_FIEMAP: return ioctl_fiemap(filp, arg); + case FS_IOC_SYNCFS: + { + struct super_block *sb = filp->f_dentry->d_sb; + down_read(&sb->s_umount); + error = sync_filesystem(sb); + up_read(&sb->s_umount); + break; + } + case FIGETBSZ: { struct inode *inode = filp->f_path.dentry->d_inode; diff --git a/include/linux/fs.h b/include/linux/fs.h index 68ca1b0..175d77f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -321,6 +321,7 @@ struct inodes_stat_t { #define FS_IOC_GETVERSION _IOR('v', 1, long) #define FS_IOC_SETVERSION _IOW('v', 2, long) #define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap) +#define FS_IOC_SYNCFS _IO('f', 12) #define FS_IOC32_GETFLAGS _IOR('f', 1, int) #define FS_IOC32_SETFLAGS _IOW('f', 2, int) #define FS_IOC32_GETVERSION _IOR('v', 1, int) -- 1.7.0.4 -- 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