From: TaeJun Kwon Date: Thu, 11 May 2017 10:53:26 +0000 (+0900) Subject: Fix journaling issue X-Git-Tag: 1.1_Public_Release~588^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a4b9bfa50ba14f54d0ea364ffef7367ab42e75ea;p=rtos%2Ftinyara.git Fix journaling issue If buffer size is bigger than remained area + next area, calculating failed --- diff --git a/os/fs/smartfs/smartfs_utils.c b/os/fs/smartfs/smartfs_utils.c index 371605f..0ffe000 100644 --- a/os/fs/smartfs/smartfs_utils.c +++ b/os/fs/smartfs/smartfs_utils.c @@ -2924,19 +2924,22 @@ static int get_next_sector_info(struct journal_transaction_manager_s *j_mgr) ret = NO_CHANGE; newsector = j_mgr->sector; + newoffset = j_mgr->offset; entry = (struct smartfs_logging_entry_s *)(j_mgr->buffer); startsector = SMARTFS_LOGGING_SECTOR + j_mgr->jarea * CONFIG_SMARTFS_NLOGGING_SECTORS; if ((j_mgr->offset + sizeof(struct smartfs_logging_entry_s)) > j_mgr->availbytes) { + newsector++; + newoffset = 0; ret = NEXT_SECTOR; } - if (j_mgr->sector >= startsector + CONFIG_SMARTFS_NLOGGING_SECTORS) { + if (newsector >= startsector + CONFIG_SMARTFS_NLOGGING_SECTORS) { return MOVE_AREA; } - newoffset = j_mgr->offset + sizeof(struct smartfs_logging_entry_s) - + (GET_TRANS_TYPE(entry->trans_info) != T_DELETE ? entry->datalen : 0); + + newoffset += sizeof(struct smartfs_logging_entry_s) + (GET_TRANS_TYPE(entry->trans_info) != T_DELETE ? entry->datalen : 0); + if (newoffset > j_mgr->availbytes) { newsector++; - newoffset -= j_mgr->availbytes; } if (newsector >= startsector + CONFIG_SMARTFS_NLOGGING_SECTORS) { ret = MOVE_AREA;