From f97b8436b37fdf22541bf073078562b72771a8ec Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Mon, 13 Jul 2020 19:40:07 +0800 Subject: [PATCH] drivers/bch: flush the dirty sector to keep the sector sequence flush the dirty sector to keep the sector sequence before ftl write Change-Id: I1096cce39965806d5c877c2929b5a2ecdab27ac9 Signed-off-by: chao.an --- drivers/bch/bchlib_write.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/bch/bchlib_write.c b/drivers/bch/bchlib_write.c index 59209972a4..13ba4698c6 100644 --- a/drivers/bch/bchlib_write.c +++ b/drivers/bch/bchlib_write.c @@ -141,6 +141,15 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, nsectors = bch->nsectors - sector; } + /* Flush the dirty sector to keep the sector sequence */ + + ret = bchlib_flushsector(bch); + if (ret < 0) + { + ferr("ERROR: Flush failed: %d\n", ret); + return ret; + } + /* Write the contiguous sectors */ ret = bch->inode->u.i_bops->write(bch->inode, (FAR uint8_t *)buffer,