diff options
author | relan <relan@users.noreply.github.com> | 2015-11-07 11:06:34 +0300 |
---|---|---|
committer | relan <relan@users.noreply.github.com> | 2015-11-07 11:24:05 +0300 |
commit | 01be539e4d2855dca34e1734501115e880eb905e (patch) | |
tree | 3d40bce86616e8083e91d2e688b23433d7f8024e | |
parent | 77a236ce4cd8ba5493e3dd0350e8a1ef54df6dae (diff) | |
download | android_external_exfat-01be539e4d2855dca34e1734501115e880eb905e.tar.gz android_external_exfat-01be539e4d2855dca34e1734501115e880eb905e.tar.bz2 android_external_exfat-01be539e4d2855dca34e1734501115e880eb905e.zip |
Move nodes flush from exfat_flush() into a separate function.
Make exfat_flush() execution time more predictable.
-rw-r--r-- | fuse/main.c | 3 | ||||
-rw-r--r-- | libexfat/cluster.c | 9 | ||||
-rw-r--r-- | libexfat/exfat.h | 1 | ||||
-rw-r--r-- | libexfat/mount.c | 3 |
4 files changed, 12 insertions, 4 deletions
diff --git a/fuse/main.c b/fuse/main.c index 030362e..aad082b 100644 --- a/fuse/main.c +++ b/fuse/main.c @@ -206,6 +206,9 @@ static int fuse_exfat_fsync(const char* path, int datasync, int rc; exfat_debug("[%s] %s", __func__, path); + rc = exfat_flush_nodes(&ef); + if (rc != 0) + return rc; rc = exfat_flush(&ef); if (rc != 0) return rc; diff --git a/libexfat/cluster.c b/libexfat/cluster.c index 523e9fb..fc3657b 100644 --- a/libexfat/cluster.c +++ b/libexfat/cluster.c @@ -149,10 +149,13 @@ static int flush_nodes(struct exfat* ef, struct exfat_node* node) return exfat_flush_node(ef, node); } -int exfat_flush(struct exfat* ef) +int exfat_flush_nodes(struct exfat* ef) { - int rc = flush_nodes(ef, ef->root); + return flush_nodes(ef, ef->root); +} +int exfat_flush(struct exfat* ef) +{ if (ef->cmap.dirty) { if (exfat_pwrite(ef->dev, ef->cmap.chunk, @@ -165,7 +168,7 @@ int exfat_flush(struct exfat* ef) ef->cmap.dirty = false; } - return rc; + return 0; } static bool set_next_cluster(const struct exfat* ef, bool contiguous, diff --git a/libexfat/exfat.h b/libexfat/exfat.h index 122ac5b..97d3692 100644 --- a/libexfat/exfat.h +++ b/libexfat/exfat.h @@ -169,6 +169,7 @@ cluster_t exfat_next_cluster(const struct exfat* ef, const struct exfat_node* node, cluster_t cluster); cluster_t exfat_advance_cluster(const struct exfat* ef, struct exfat_node* node, uint32_t count); +int exfat_flush_nodes(struct exfat* ef); int exfat_flush(struct exfat* ef); int exfat_truncate(struct exfat* ef, struct exfat_node* node, uint64_t size, bool erase); diff --git a/libexfat/mount.c b/libexfat/mount.c index f1fb01a..0d6ce9e 100644 --- a/libexfat/mount.c +++ b/libexfat/mount.c @@ -359,7 +359,8 @@ static void finalize_super_block(struct exfat* ef) void exfat_unmount(struct exfat* ef) { - exfat_flush(ef); /* ignore return code */ + exfat_flush_nodes(ef); /* ignore return code */ + exfat_flush(ef); /* ignore return code */ exfat_put_node(ef, ef->root); exfat_reset_cache(ef); free(ef->root); |