From: gkostka Date: Wed, 18 Jan 2017 21:35:36 +0000 (+0100) Subject: ext4: add ext4_cache_flush for explicit cache flush X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=c1185991fa175c25b4ba47160784e64bc5deb4ce;hp=4c155036f9ce3a74bc3eb3bb79725616d3b6c125;p=lwext4.git ext4: add ext4_cache_flush for explicit cache flush --- diff --git a/include/ext4.h b/include/ext4.h index b1c7a61..745d41e 100644 --- a/include/ext4.h +++ b/include/ext4.h @@ -234,6 +234,14 @@ int ext4_get_sblock(const char *mount_point, struct ext4_sblock **sb); * @return standard error code */ int ext4_cache_write_back(const char *path, bool on); + +/**@brief Force cache flush. + * + * @param path mount point path + * + * @return standard error code */ +int ext4_cache_flush(const char *path); + /********************************FILE OPERATIONS*****************************/ /**@brief Remove file by path. diff --git a/src/ext4.c b/src/ext4.c index 94744bb..e978324 100644 --- a/src/ext4.c +++ b/src/ext4.c @@ -1387,14 +1387,29 @@ int ext4_get_sblock(const char *mount_point, struct ext4_sblock **sb) int ext4_cache_write_back(const char *path, bool on) { struct ext4_mountpoint *mp = ext4_get_mount(path); + int ret; if (!mp) return ENOENT; EXT4_MP_LOCK(mp); - ext4_block_cache_write_back(mp->fs.bdev, on); + ret = ext4_block_cache_write_back(mp->fs.bdev, on); EXT4_MP_UNLOCK(mp); - return EOK; + return ret; +} + +int ext4_cache_flush(const char *path) +{ + struct ext4_mountpoint *mp = ext4_get_mount(path); + int ret; + + if (!mp) + return ENOENT; + + EXT4_MP_LOCK(mp); + ret = ext4_block_cache_flush(mp->fs.bdev); + EXT4_MP_UNLOCK(mp); + return ret; } int ext4_fremove(const char *path)