ext4: add ext4_cache_flush for explicit cache flush
authorgkostka <kostka.grzegorz@gmail.com>
Wed, 18 Jan 2017 21:35:36 +0000 (22:35 +0100)
committergkostka <kostka.grzegorz@gmail.com>
Wed, 18 Jan 2017 21:42:04 +0000 (22:42 +0100)
include/ext4.h
src/ext4.c

index b1c7a6162359d78c4c9f49aaec801dc577207417..745d41ed824bb2f9233f8e8340f43dd9b5fc7aad 100644 (file)
@@ -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.
index 94744bbb4b24be97c80f5a09635703b7d4a31320..e97832498af726dd170aab7d4cf36d3d6a2474af 100644 (file)
@@ -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)