From 34249a43aa5ab4f94105f0d1c49a5bc11387f974 Mon Sep 17 00:00:00 2001 From: TaeJun Kwon Date: Thu, 13 Apr 2017 17:59:50 +0900 Subject: [PATCH] Add transaction logging for chaining There no Transaction Logging when chaining --- os/fs/smartfs/smartfs_smart.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/os/fs/smartfs/smartfs_smart.c b/os/fs/smartfs/smartfs_smart.c index 35cc9ff..e125cde 100644 --- a/os/fs/smartfs/smartfs_smart.c +++ b/os/fs/smartfs/smartfs_smart.c @@ -970,7 +970,23 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer, size_t readwrite.offset = offsetof(struct smartfs_chain_header_s, nextsector); readwrite.buffer = (uint8_t *)header->nextsector; readwrite.count = sizeof(uint16_t); - ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long)&readwrite); +#ifdef CONFIG_SMARTFS_JOURNALING + ret = smartfs_create_journalentry(fs, T_WRITE, readwrite.logsector, + readwrite.offset, readwrite.count, 0, 0, readwrite.buffer, &t_sector, &t_offset); + if (ret != OK) { + fdbg("Journal entry creation failed.\n"); + goto errout_with_semaphore; + } +#endif + ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long ) &readwrite); +#ifdef CONFIG_SMARTFS_JOURNALING + retj = smartfs_finish_journalentry(fs, 0, t_sector, t_offset, T_WRITE); + if (retj != OK) { + fdbg("Error finishing transaction\n"); + ret = retj; + goto errout_with_semaphore; + } +#endif if (ret < 0) { fdbg("Error %d writing next sector\n", ret); goto errout_with_semaphore; -- 2.7.4