linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: introduce FS_IOC_SYNCFS to sync a single super
@ 2010-08-09 14:33 Sage Weil
  2010-08-09 18:55 ` Arnd Bergmann
       [not found] ` <Pine.LNX.4.64.1008090711040.17515-vIokxiIdD2AQNTJnQDzGJqxOck334EZe@public.gmane.org>
  0 siblings, 2 replies; 7+ messages in thread
From: Sage Weil @ 2010-08-09 14:33 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linux-fsdevel

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@newdream.net>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-11-28  5:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-09 14:33 [PATCH] vfs: introduce FS_IOC_SYNCFS to sync a single super Sage Weil
2010-08-09 18:55 ` Arnd Bergmann
     [not found]   ` <201008092055.07248.arnd-r2nGTMty4D4@public.gmane.org>
2010-11-27 22:57     ` Jonathan Nieder
     [not found] ` <Pine.LNX.4.64.1008090711040.17515-vIokxiIdD2AQNTJnQDzGJqxOck334EZe@public.gmane.org>
2010-08-27  0:01   ` Andrew Morton
     [not found]     ` <20100826170142.e029cff5.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2010-09-08 21:44       ` Sage Weil
2010-11-27 22:32       ` Jonathan Nieder
2010-11-28  5:04         ` Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).