* [PATCH 0/4] Fix sys_sync() and cleanup code (version 3)
@ 2009-04-23 21:35 Jan Kara
2009-04-23 21:35 ` [PATCH 1/4] vfs: Fix sys_sync() and fsync_super() reliability " Jan Kara
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Jan Kara @ 2009-04-23 21:35 UTC (permalink / raw)
To: LKML; +Cc: linux-fsdevel, Andrew Morton, Christoph Hellwig, Trond Myklebust
Hi,
this is a next version of the patches. I've modified comments a bit
and mainly fixed a return value of __fsync_super() (forgot to commit
the fix before). Thanks to Trond and Christoph for useful comments.
Honza
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/4] vfs: Fix sys_sync() and fsync_super() reliability (version 3)
2009-04-23 21:35 [PATCH 0/4] Fix sys_sync() and cleanup code (version 3) Jan Kara
@ 2009-04-23 21:35 ` Jan Kara
2009-04-23 21:35 ` [PATCH 2/4] vfs: Call ->sync_fs() even if s_dirt is 0 " Jan Kara
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Jan Kara @ 2009-04-23 21:35 UTC (permalink / raw)
To: LKML
Cc: linux-fsdevel, Andrew Morton, Christoph Hellwig, Trond Myklebust,
Jan Kara
So far, do_sync() called:
sync_inodes(0);
sync_supers();
sync_filesystems(0);
sync_filesystems(1);
sync_inodes(1);
This ordering makes it kind of hard for filesystems as sync_inodes(0) need not
submit all the IO (for example it skips inodes with I_SYNC set) so e.g. forcing
transaction to disk in ->sync_fs() is not really enough. Therefore sys_sync has
not been completely reliable on some filesystems (ext3, ext4, reiserfs, ocfs2
and others are hit by this) when racing e.g. with background writeback. A
similar problem hits also other filesystems (e.g. ext2) because of
write_supers() being called before the sync_inodes(1).
Change the ordering of calls in do_sync() - this requires a new function
sync_blkdevs() to preserve the property that block devices are always synced
after write_super() / sync_fs() call.
The same issue is fixed in __fsync_super() function used on umount /
remount read-only.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/super.c | 27 ++++++++++++++++++++++++++-
fs/sync.c | 3 ++-
include/linux/fs.h | 2 ++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/fs/super.c b/fs/super.c
index 786fe7d..4826540 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -267,6 +267,7 @@ void __fsync_super(struct super_block *sb)
{
sync_inodes_sb(sb, 0);
vfs_dq_sync(sb);
+ sync_inodes_sb(sb, 1);
lock_super(sb);
if (sb->s_dirt && sb->s_op->write_super)
sb->s_op->write_super(sb);
@@ -274,7 +275,6 @@ void __fsync_super(struct super_block *sb)
if (sb->s_op->sync_fs)
sb->s_op->sync_fs(sb, 1);
sync_blockdev(sb->s_bdev);
- sync_inodes_sb(sb, 1);
}
/*
@@ -502,6 +502,31 @@ restart:
mutex_unlock(&mutex);
}
+/*
+ * Sync all block devices underlying some superblock
+ */
+void sync_blockdevs(void)
+{
+ struct super_block *sb;
+
+ spin_lock(&sb_lock);
+restart:
+ list_for_each_entry(sb, &super_blocks, s_list) {
+ if (!sb->s_bdev)
+ continue;
+ sb->s_count++;
+ spin_unlock(&sb_lock);
+ down_read(&sb->s_umount);
+ if (sb->s_root)
+ sync_blockdev(sb->s_bdev);
+ up_read(&sb->s_umount);
+ spin_lock(&sb_lock);
+ if (__put_super_and_need_restart(sb))
+ goto restart;
+ }
+ spin_unlock(&sb_lock);
+}
+
/**
* get_super - get the superblock of a device
* @bdev: device to get the superblock for
diff --git a/fs/sync.c b/fs/sync.c
index 7abc65f..fa14e42 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -26,10 +26,11 @@ static void do_sync(unsigned long wait)
wakeup_pdflush(0);
sync_inodes(0); /* All mappings, inodes and their blockdevs */
vfs_dq_sync(NULL);
+ sync_inodes(wait); /* Mappings, inodes and blockdevs, again. */
sync_supers(); /* Write the superblocks */
sync_filesystems(0); /* Start syncing the filesystems */
sync_filesystems(wait); /* Waitingly sync the filesystems */
- sync_inodes(wait); /* Mappings, inodes and blockdevs, again. */
+ sync_blockdevs();
if (!wait)
printk("Emergency Sync complete\n");
if (unlikely(laptop_mode))
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5bed436..4bad02e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1942,6 +1942,7 @@ extern void bdput(struct block_device *);
extern struct block_device *open_by_devnum(dev_t, fmode_t);
extern void invalidate_bdev(struct block_device *);
extern int sync_blockdev(struct block_device *bdev);
+extern void sync_blockdevs(void);
extern struct super_block *freeze_bdev(struct block_device *);
extern void emergency_thaw_all(void);
extern int thaw_bdev(struct block_device *bdev, struct super_block *sb);
@@ -1951,6 +1952,7 @@ extern int fsync_no_super(struct block_device *);
#else
static inline void bd_forget(struct inode *inode) {}
static inline int sync_blockdev(struct block_device *bdev) { return 0; }
+static inline void sync_blockdevs(void) { }
static inline void invalidate_bdev(struct block_device *bdev) {}
static inline struct super_block *freeze_bdev(struct block_device *sb)
--
1.6.0.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] vfs: Call ->sync_fs() even if s_dirt is 0 (version 3)
2009-04-23 21:35 [PATCH 0/4] Fix sys_sync() and cleanup code (version 3) Jan Kara
2009-04-23 21:35 ` [PATCH 1/4] vfs: Fix sys_sync() and fsync_super() reliability " Jan Kara
@ 2009-04-23 21:35 ` Jan Kara
2009-04-23 21:35 ` [PATCH 3/4] vfs: Make __fsync_super() a static function " Jan Kara
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Jan Kara @ 2009-04-23 21:35 UTC (permalink / raw)
To: LKML
Cc: linux-fsdevel, Andrew Morton, Christoph Hellwig, Trond Myklebust,
Jan Kara
sync_filesystems() has a condition that if wait == 0 and s_dirt == 0, then
->sync_fs() isn't called. This does not really make much sence since s_dirt is
generally used by a filesystem to mean that ->write_super() needs to be called.
But ->sync_fs() does different things. I even suspect that some filesystems
(btrfs?) sets s_dirt just to fool this logic.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/super.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/super.c b/fs/super.c
index 4826540..d9759e0 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -490,7 +490,7 @@ restart:
spin_unlock(&sb_lock);
down_read(&sb->s_umount);
async_synchronize_full_domain(&sb->s_async_list);
- if (sb->s_root && (wait || sb->s_dirt))
+ if (sb->s_root)
sb->s_op->sync_fs(sb, wait);
up_read(&sb->s_umount);
/* restart only when sb is no longer on the list */
--
1.6.0.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] vfs: Make __fsync_super() a static function (version 3)
2009-04-23 21:35 [PATCH 0/4] Fix sys_sync() and cleanup code (version 3) Jan Kara
2009-04-23 21:35 ` [PATCH 1/4] vfs: Fix sys_sync() and fsync_super() reliability " Jan Kara
2009-04-23 21:35 ` [PATCH 2/4] vfs: Call ->sync_fs() even if s_dirt is 0 " Jan Kara
@ 2009-04-23 21:35 ` Jan Kara
2009-04-23 21:39 ` Trond Myklebust
2009-04-23 21:35 ` [PATCH 4/4] vfs: Make sys_sync() use fsync_super() " Jan Kara
` (2 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Jan Kara @ 2009-04-23 21:35 UTC (permalink / raw)
To: LKML
Cc: linux-fsdevel, Andrew Morton, Christoph Hellwig, Trond Myklebust,
Jan Kara
__fsync_super() does the same thing as fsync_super(). So change the only
caller to use fsync_super() and make __fsync_super() static. This removes
unnecessarily duplicated call to sync_blockdev() and prepares ground
for the changes to __fsync_super() in the following patches.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/block_dev.c | 2 +-
fs/super.c | 5 ++---
include/linux/fs.h | 1 -
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index f45dbc1..48d1290 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -240,7 +240,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
sb->s_frozen = SB_FREEZE_WRITE;
smp_wmb();
- __fsync_super(sb);
+ fsync_super(sb);
sb->s_frozen = SB_FREEZE_TRANS;
smp_wmb();
diff --git a/fs/super.c b/fs/super.c
index d9759e0..4c92068 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -263,7 +263,7 @@ EXPORT_SYMBOL(unlock_super);
* device. Takes the superblock lock. Requires a second blkdev
* flush by the caller to complete the operation.
*/
-void __fsync_super(struct super_block *sb)
+static int __fsync_super(struct super_block *sb)
{
sync_inodes_sb(sb, 0);
vfs_dq_sync(sb);
@@ -284,8 +284,7 @@ void __fsync_super(struct super_block *sb)
*/
int fsync_super(struct super_block *sb)
{
- __fsync_super(sb);
- return sync_blockdev(sb->s_bdev);
+ return __fsync_super(sb);
}
EXPORT_SYMBOL_GPL(fsync_super);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4bad02e..47a67c9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2084,7 +2084,6 @@ extern int filemap_fdatawrite_range(struct address_space *mapping,
extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync);
extern void sync_supers(void);
extern void sync_filesystems(int wait);
-extern void __fsync_super(struct super_block *sb);
extern void emergency_sync(void);
extern void emergency_remount(void);
extern int do_remount_sb(struct super_block *sb, int flags,
--
1.6.0.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] vfs: Make sys_sync() use fsync_super() (version 3)
2009-04-23 21:35 [PATCH 0/4] Fix sys_sync() and cleanup code (version 3) Jan Kara
` (2 preceding siblings ...)
2009-04-23 21:35 ` [PATCH 3/4] vfs: Make __fsync_super() a static function " Jan Kara
@ 2009-04-23 21:35 ` Jan Kara
2009-04-24 18:13 ` [PATCH 0/4] Fix sys_sync() and cleanup code " Christoph Hellwig
2009-04-26 11:54 ` Christoph Hellwig
5 siblings, 0 replies; 10+ messages in thread
From: Jan Kara @ 2009-04-23 21:35 UTC (permalink / raw)
To: LKML
Cc: linux-fsdevel, Andrew Morton, Christoph Hellwig, Trond Myklebust,
Jan Kara
It is unnecessarily fragile to have two places (fsync_super() and do_sync())
doing data integrity sync of the filesystem. Alter __fsync_super() to
accommodate needs of both callers and use it. So after this patch
__fsync_super() is the only place where we gather all the calls needed to
properly send all data on a filesystem to disk.
Nice bonus is that we get a complete livelock avoidance and write_supers()
is now only used for periodic writeback of superblocks.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/block_dev.c | 15 ++++++---
fs/fs-writeback.c | 49 -------------------------------
fs/super.c | 70 +++++++++++++++------------------------------
fs/sync.c | 31 ++++++-------------
include/linux/fs.h | 4 +-
include/linux/writeback.h | 1 -
6 files changed, 45 insertions(+), 125 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 48d1290..2609cce 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -175,17 +175,22 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
iov, offset, nr_segs, blkdev_get_blocks, NULL);
}
+int __sync_blockdev(struct block_device *bdev, int wait)
+{
+ if (!bdev)
+ return 0;
+ if (!wait)
+ return filemap_flush(bdev->bd_inode->i_mapping);
+ return filemap_write_and_wait(bdev->bd_inode->i_mapping);
+}
+
/*
* Write out and wait upon all the dirty data associated with a block
* device via its mapping. Does not take the superblock lock.
*/
int sync_blockdev(struct block_device *bdev)
{
- int ret = 0;
-
- if (bdev)
- ret = filemap_write_and_wait(bdev->bd_inode->i_mapping);
- return ret;
+ return __sync_blockdev(bdev, 1);
}
EXPORT_SYMBOL(sync_blockdev);
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 91013ff..e0fb2e7 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -679,55 +679,6 @@ void sync_inodes_sb(struct super_block *sb, int wait)
}
/**
- * sync_inodes - writes all inodes to disk
- * @wait: wait for completion
- *
- * sync_inodes() goes through each super block's dirty inode list, writes the
- * inodes out, waits on the writeout and puts the inodes back on the normal
- * list.
- *
- * This is for sys_sync(). fsync_dev() uses the same algorithm. The subtle
- * part of the sync functions is that the blockdev "superblock" is processed
- * last. This is because the write_inode() function of a typical fs will
- * perform no I/O, but will mark buffers in the blockdev mapping as dirty.
- * What we want to do is to perform all that dirtying first, and then write
- * back all those inode blocks via the blockdev mapping in one sweep. So the
- * additional (somewhat redundant) sync_blockdev() calls here are to make
- * sure that really happens. Because if we call sync_inodes_sb(wait=1) with
- * outstanding dirty inodes, the writeback goes block-at-a-time within the
- * filesystem's write_inode(). This is extremely slow.
- */
-static void __sync_inodes(int wait)
-{
- struct super_block *sb;
-
- spin_lock(&sb_lock);
-restart:
- list_for_each_entry(sb, &super_blocks, s_list) {
- sb->s_count++;
- spin_unlock(&sb_lock);
- down_read(&sb->s_umount);
- if (sb->s_root) {
- sync_inodes_sb(sb, wait);
- sync_blockdev(sb->s_bdev);
- }
- up_read(&sb->s_umount);
- spin_lock(&sb_lock);
- if (__put_super_and_need_restart(sb))
- goto restart;
- }
- spin_unlock(&sb_lock);
-}
-
-void sync_inodes(int wait)
-{
- __sync_inodes(0);
-
- if (wait)
- __sync_inodes(1);
-}
-
-/**
* write_inode_now - write an inode to disk
* @inode: inode to write to disk
* @sync: whether the write should be synchronous or not
diff --git a/fs/super.c b/fs/super.c
index 4c92068..b5d7dfb 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -258,23 +258,23 @@ EXPORT_SYMBOL(lock_super);
EXPORT_SYMBOL(unlock_super);
/*
- * Write out and wait upon all dirty data associated with this
- * superblock. Filesystem data as well as the underlying block
- * device. Takes the superblock lock. Requires a second blkdev
- * flush by the caller to complete the operation.
+ * Do the filesystem syncing work. For simple filesystems sync_inodes_sb(sb, 0)
+ * just dirties buffers with inodes so we have to submit IO for these buffers
+ * via __sync_blockdev(). This also speeds up the wait == 1 case since in that
+ * case write_inode() functions do sync_dirty_buffer() and thus effectively
+ * write one block at a time.
*/
-static int __fsync_super(struct super_block *sb)
+static int __fsync_super(struct super_block *sb, int wait)
{
- sync_inodes_sb(sb, 0);
vfs_dq_sync(sb);
- sync_inodes_sb(sb, 1);
+ sync_inodes_sb(sb, wait);
lock_super(sb);
if (sb->s_dirt && sb->s_op->write_super)
sb->s_op->write_super(sb);
unlock_super(sb);
if (sb->s_op->sync_fs)
- sb->s_op->sync_fs(sb, 1);
- sync_blockdev(sb->s_bdev);
+ sb->s_op->sync_fs(sb, wait);
+ return __sync_blockdev(sb->s_bdev, wait);
}
/*
@@ -284,7 +284,12 @@ static int __fsync_super(struct super_block *sb)
*/
int fsync_super(struct super_block *sb)
{
- return __fsync_super(sb);
+ int ret;
+
+ ret = __fsync_super(sb, 0);
+ if (ret < 0)
+ return ret;
+ return __fsync_super(sb, 1);
}
EXPORT_SYMBOL_GPL(fsync_super);
@@ -448,20 +453,18 @@ restart:
}
/*
- * Call the ->sync_fs super_op against all filesystems which are r/w and
- * which implement it.
+ * Sync all the data for all the filesystems (called by sys_sync() and
+ * emergency sync)
*
* This operation is careful to avoid the livelock which could easily happen
- * if two or more filesystems are being continuously dirtied. s_need_sync_fs
+ * if two or more filesystems are being continuously dirtied. s_need_sync
* is used only here. We set it against all filesystems and then clear it as
* we sync them. So redirtied filesystems are skipped.
*
* But if process A is currently running sync_filesystems and then process B
- * calls sync_filesystems as well, process B will set all the s_need_sync_fs
+ * calls sync_filesystems as well, process B will set all the s_need_sync
* flags again, which will cause process A to resync everything. Fix that with
* a local mutex.
- *
- * (Fabian) Avoid sync_fs with clean fs & wait mode 0
*/
void sync_filesystems(int wait)
{
@@ -471,18 +474,16 @@ void sync_filesystems(int wait)
mutex_lock(&mutex); /* Could be down_interruptible */
spin_lock(&sb_lock);
list_for_each_entry(sb, &super_blocks, s_list) {
- if (!sb->s_op->sync_fs)
- continue;
if (sb->s_flags & MS_RDONLY)
continue;
- sb->s_need_sync_fs = 1;
+ sb->s_need_sync = 1;
}
restart:
list_for_each_entry(sb, &super_blocks, s_list) {
- if (!sb->s_need_sync_fs)
+ if (!sb->s_need_sync)
continue;
- sb->s_need_sync_fs = 0;
+ sb->s_need_sync = 0;
if (sb->s_flags & MS_RDONLY)
continue; /* hm. Was remounted r/o meanwhile */
sb->s_count++;
@@ -490,7 +491,7 @@ restart:
down_read(&sb->s_umount);
async_synchronize_full_domain(&sb->s_async_list);
if (sb->s_root)
- sb->s_op->sync_fs(sb, wait);
+ __fsync_super(sb, wait);
up_read(&sb->s_umount);
/* restart only when sb is no longer on the list */
spin_lock(&sb_lock);
@@ -501,31 +502,6 @@ restart:
mutex_unlock(&mutex);
}
-/*
- * Sync all block devices underlying some superblock
- */
-void sync_blockdevs(void)
-{
- struct super_block *sb;
-
- spin_lock(&sb_lock);
-restart:
- list_for_each_entry(sb, &super_blocks, s_list) {
- if (!sb->s_bdev)
- continue;
- sb->s_count++;
- spin_unlock(&sb_lock);
- down_read(&sb->s_umount);
- if (sb->s_root)
- sync_blockdev(sb->s_bdev);
- up_read(&sb->s_umount);
- spin_lock(&sb_lock);
- if (__put_super_and_need_restart(sb))
- goto restart;
- }
- spin_unlock(&sb_lock);
-}
-
/**
* get_super - get the superblock of a device
* @bdev: device to get the superblock for
diff --git a/fs/sync.c b/fs/sync.c
index fa14e42..86c6a86 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -17,35 +17,24 @@
#define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \
SYNC_FILE_RANGE_WAIT_AFTER)
-/*
- * sync everything. Start out by waking pdflush, because that writes back
- * all queues in parallel.
- */
-static void do_sync(unsigned long wait)
+SYSCALL_DEFINE0(sync)
{
- wakeup_pdflush(0);
- sync_inodes(0); /* All mappings, inodes and their blockdevs */
- vfs_dq_sync(NULL);
- sync_inodes(wait); /* Mappings, inodes and blockdevs, again. */
- sync_supers(); /* Write the superblocks */
- sync_filesystems(0); /* Start syncing the filesystems */
- sync_filesystems(wait); /* Waitingly sync the filesystems */
- sync_blockdevs();
- if (!wait)
- printk("Emergency Sync complete\n");
+ sync_filesystems(0);
+ sync_filesystems(1);
if (unlikely(laptop_mode))
laptop_sync_completion();
-}
-
-SYSCALL_DEFINE0(sync)
-{
- do_sync(1);
return 0;
}
static void do_sync_work(struct work_struct *work)
{
- do_sync(0);
+ /*
+ * Sync twice to reduce the possibility we skipped some inodes / pages
+ * because they were temporarily locked
+ */
+ sync_filesystems(0);
+ sync_filesystems(0);
+ printk("Emergency Sync complete\n");
kfree(work);
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 47a67c9..be2be8d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1321,7 +1321,7 @@ struct super_block {
struct rw_semaphore s_umount;
struct mutex s_lock;
int s_count;
- int s_need_sync_fs;
+ int s_need_sync;
atomic_t s_active;
#ifdef CONFIG_SECURITY
void *s_security;
@@ -1942,7 +1942,7 @@ extern void bdput(struct block_device *);
extern struct block_device *open_by_devnum(dev_t, fmode_t);
extern void invalidate_bdev(struct block_device *);
extern int sync_blockdev(struct block_device *bdev);
-extern void sync_blockdevs(void);
+extern int __sync_blockdev(struct block_device *bdev, int wait);
extern struct super_block *freeze_bdev(struct block_device *);
extern void emergency_thaw_all(void);
extern int thaw_bdev(struct block_device *bdev, struct super_block *sb);
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index 9c1ed1f..943d1c9 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -79,7 +79,6 @@ struct writeback_control {
void writeback_inodes(struct writeback_control *wbc);
int inode_wait(void *);
void sync_inodes_sb(struct super_block *, int wait);
-void sync_inodes(int wait);
/* writeback.h requires fs.h; it, too, is not included from here. */
static inline void wait_on_inode(struct inode *inode)
--
1.6.0.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] vfs: Make __fsync_super() a static function (version 3)
2009-04-23 21:35 ` [PATCH 3/4] vfs: Make __fsync_super() a static function " Jan Kara
@ 2009-04-23 21:39 ` Trond Myklebust
2009-04-23 21:52 ` Jan Kara
0 siblings, 1 reply; 10+ messages in thread
From: Trond Myklebust @ 2009-04-23 21:39 UTC (permalink / raw)
To: Jan Kara; +Cc: LKML, linux-fsdevel, Andrew Morton, Christoph Hellwig
On Thu, 2009-04-23 at 23:35 +0200, Jan Kara wrote:
> __fsync_super() does the same thing as fsync_super(). So change the only
> caller to use fsync_super() and make __fsync_super() static. This removes
> unnecessarily duplicated call to sync_blockdev() and prepares ground
> for the changes to __fsync_super() in the following patches.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/block_dev.c | 2 +-
> fs/super.c | 5 ++---
> include/linux/fs.h | 1 -
> 3 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index f45dbc1..48d1290 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -240,7 +240,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
> sb->s_frozen = SB_FREEZE_WRITE;
> smp_wmb();
>
> - __fsync_super(sb);
> + fsync_super(sb);
>
> sb->s_frozen = SB_FREEZE_TRANS;
> smp_wmb();
> diff --git a/fs/super.c b/fs/super.c
> index d9759e0..4c92068 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -263,7 +263,7 @@ EXPORT_SYMBOL(unlock_super);
> * device. Takes the superblock lock. Requires a second blkdev
> * flush by the caller to complete the operation.
> */
> -void __fsync_super(struct super_block *sb)
> +static int __fsync_super(struct super_block *sb)
> {
> sync_inodes_sb(sb, 0);
> vfs_dq_sync(sb);
Still missing the return value here :-)
> @@ -284,8 +284,7 @@ void __fsync_super(struct super_block *sb)
> */
> int fsync_super(struct super_block *sb)
> {
> - __fsync_super(sb);
> - return sync_blockdev(sb->s_bdev);
> + return __fsync_super(sb);
> }
> EXPORT_SYMBOL_GPL(fsync_super);
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 4bad02e..47a67c9 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2084,7 +2084,6 @@ extern int filemap_fdatawrite_range(struct address_space *mapping,
> extern int vfs_fsync(struct file *file, struct dentry *dentry, int datasync);
> extern void sync_supers(void);
> extern void sync_filesystems(int wait);
> -extern void __fsync_super(struct super_block *sb);
> extern void emergency_sync(void);
> extern void emergency_remount(void);
> extern int do_remount_sb(struct super_block *sb, int flags,
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] vfs: Make __fsync_super() a static function (version 3)
2009-04-23 21:39 ` Trond Myklebust
@ 2009-04-23 21:52 ` Jan Kara
0 siblings, 0 replies; 10+ messages in thread
From: Jan Kara @ 2009-04-23 21:52 UTC (permalink / raw)
To: Trond Myklebust; +Cc: LKML, linux-fsdevel, Andrew Morton, Christoph Hellwig
On Thu 23-04-09 17:39:50, Trond Myklebust wrote:
> On Thu, 2009-04-23 at 23:35 +0200, Jan Kara wrote:
> > __fsync_super() does the same thing as fsync_super(). So change the only
> > caller to use fsync_super() and make __fsync_super() static. This removes
> > unnecessarily duplicated call to sync_blockdev() and prepares ground
> > for the changes to __fsync_super() in the following patches.
> >
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> > fs/block_dev.c | 2 +-
> > fs/super.c | 5 ++---
> > include/linux/fs.h | 1 -
> > 3 files changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/block_dev.c b/fs/block_dev.c
> > index f45dbc1..48d1290 100644
> > --- a/fs/block_dev.c
> > +++ b/fs/block_dev.c
> > @@ -240,7 +240,7 @@ struct super_block *freeze_bdev(struct block_device *bdev)
> > sb->s_frozen = SB_FREEZE_WRITE;
> > smp_wmb();
> >
> > - __fsync_super(sb);
> > + fsync_super(sb);
> >
> > sb->s_frozen = SB_FREEZE_TRANS;
> > smp_wmb();
> > diff --git a/fs/super.c b/fs/super.c
> > index d9759e0..4c92068 100644
> > --- a/fs/super.c
> > +++ b/fs/super.c
> > @@ -263,7 +263,7 @@ EXPORT_SYMBOL(unlock_super);
> > * device. Takes the superblock lock. Requires a second blkdev
> > * flush by the caller to complete the operation.
> > */
> > -void __fsync_super(struct super_block *sb)
> > +static int __fsync_super(struct super_block *sb)
> > {
> > sync_inodes_sb(sb, 0);
> > vfs_dq_sync(sb);
>
> Still missing the return value here :-)
Ah, OK, but it's fixed in the last patch. I'll fix it in this one as well
for next time. Thanks.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/4] Fix sys_sync() and cleanup code (version 3)
2009-04-23 21:35 [PATCH 0/4] Fix sys_sync() and cleanup code (version 3) Jan Kara
` (3 preceding siblings ...)
2009-04-23 21:35 ` [PATCH 4/4] vfs: Make sys_sync() use fsync_super() " Jan Kara
@ 2009-04-24 18:13 ` Christoph Hellwig
2009-04-26 11:54 ` Christoph Hellwig
5 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2009-04-24 18:13 UTC (permalink / raw)
To: Jan Kara
Cc: LKML, linux-fsdevel, Andrew Morton, Christoph Hellwig, Trond Myklebust
On Thu, Apr 23, 2009 at 11:35:32PM +0200, Jan Kara wrote:
> Hi,
>
> this is a next version of the patches. I've modified comments a bit
> and mainly fixed a return value of __fsync_super() (forgot to commit
> the fix before). Thanks to Trond and Christoph for useful comments.
FYI this (or rather the previous one) seems to do fine running xfsqa.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/4] Fix sys_sync() and cleanup code (version 3)
2009-04-23 21:35 [PATCH 0/4] Fix sys_sync() and cleanup code (version 3) Jan Kara
` (4 preceding siblings ...)
2009-04-24 18:13 ` [PATCH 0/4] Fix sys_sync() and cleanup code " Christoph Hellwig
@ 2009-04-26 11:54 ` Christoph Hellwig
2009-04-27 13:27 ` Jan Kara
5 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2009-04-26 11:54 UTC (permalink / raw)
To: Jan Kara
Cc: LKML, linux-fsdevel, Andrew Morton, Christoph Hellwig, Trond Myklebust
Any chance you could move sync_filesystems to fs/sync.c? It fits in
there much better. Same is probably true for (__)fsync_super, which
could also use a better name..
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/4] Fix sys_sync() and cleanup code (version 3)
2009-04-26 11:54 ` Christoph Hellwig
@ 2009-04-27 13:27 ` Jan Kara
0 siblings, 0 replies; 10+ messages in thread
From: Jan Kara @ 2009-04-27 13:27 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: LKML, linux-fsdevel, Andrew Morton, Trond Myklebust
On Sun 26-04-09 07:54:10, Christoph Hellwig wrote:
> Any chance you could move sync_filesystems to fs/sync.c? It fits in
> there much better. Same is probably true for (__)fsync_super, which
> could also use a better name..
OK, I've moved the syncing code to sync.c and renamed fsync_super() to
sync_filesystem() which better describes what it does I think.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-04-27 13:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-23 21:35 [PATCH 0/4] Fix sys_sync() and cleanup code (version 3) Jan Kara
2009-04-23 21:35 ` [PATCH 1/4] vfs: Fix sys_sync() and fsync_super() reliability " Jan Kara
2009-04-23 21:35 ` [PATCH 2/4] vfs: Call ->sync_fs() even if s_dirt is 0 " Jan Kara
2009-04-23 21:35 ` [PATCH 3/4] vfs: Make __fsync_super() a static function " Jan Kara
2009-04-23 21:39 ` Trond Myklebust
2009-04-23 21:52 ` Jan Kara
2009-04-23 21:35 ` [PATCH 4/4] vfs: Make sys_sync() use fsync_super() " Jan Kara
2009-04-24 18:13 ` [PATCH 0/4] Fix sys_sync() and cleanup code " Christoph Hellwig
2009-04-26 11:54 ` Christoph Hellwig
2009-04-27 13:27 ` Jan Kara
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.