mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
block: simplify the block device syncing code
Get rid of the indirections and just provide a sync_bdevs helper for the generic sync code. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20211019062530.2174626-8-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
680e667bc2
commit
1e03a36bdf
23
fs/sync.c
23
fs/sync.c
@@ -78,21 +78,6 @@ static void sync_fs_one_sb(struct super_block *sb, void *arg)
|
||||
sb->s_op->sync_fs(sb, *(int *)arg);
|
||||
}
|
||||
|
||||
static void fdatawrite_one_bdev(struct block_device *bdev, void *arg)
|
||||
{
|
||||
filemap_fdatawrite(bdev->bd_inode->i_mapping);
|
||||
}
|
||||
|
||||
static void fdatawait_one_bdev(struct block_device *bdev, void *arg)
|
||||
{
|
||||
/*
|
||||
* We keep the error status of individual mapping so that
|
||||
* applications can catch the writeback error using fsync(2).
|
||||
* See filemap_fdatawait_keep_errors() for details.
|
||||
*/
|
||||
filemap_fdatawait_keep_errors(bdev->bd_inode->i_mapping);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sync everything. We start by waking flusher threads so that most of
|
||||
* writeback runs on all devices in parallel. Then we sync all inodes reliably
|
||||
@@ -111,8 +96,8 @@ void ksys_sync(void)
|
||||
iterate_supers(sync_inodes_one_sb, NULL);
|
||||
iterate_supers(sync_fs_one_sb, &nowait);
|
||||
iterate_supers(sync_fs_one_sb, &wait);
|
||||
iterate_bdevs(fdatawrite_one_bdev, NULL);
|
||||
iterate_bdevs(fdatawait_one_bdev, NULL);
|
||||
sync_bdevs(false);
|
||||
sync_bdevs(true);
|
||||
if (unlikely(laptop_mode))
|
||||
laptop_sync_completion();
|
||||
}
|
||||
@@ -133,10 +118,10 @@ static void do_sync_work(struct work_struct *work)
|
||||
*/
|
||||
iterate_supers(sync_inodes_one_sb, &nowait);
|
||||
iterate_supers(sync_fs_one_sb, &nowait);
|
||||
iterate_bdevs(fdatawrite_one_bdev, NULL);
|
||||
sync_bdevs(false);
|
||||
iterate_supers(sync_inodes_one_sb, &nowait);
|
||||
iterate_supers(sync_fs_one_sb, &nowait);
|
||||
iterate_bdevs(fdatawrite_one_bdev, NULL);
|
||||
sync_bdevs(false);
|
||||
printk("Emergency Sync complete\n");
|
||||
kfree(work);
|
||||
}
|
||||
|
Reference in New Issue
Block a user