R0.12c patch 2

March 18, 2017

On the exFAT volume, NoFatChain flag of the file fragmented out of the
session is left not set after it gets contiguous again by f_truncate
function. Such a wrong contiguous file causes unreasonable performance
down at read/write operation of the file. (Appeared at R0.12)
This commit is contained in:
Christopher Williams
2017-05-10 19:29:54 -07:00
parent 5440fde242
commit e007772199
+16 -2
View File
@@ -1332,8 +1332,22 @@ FRESULT remove_chain ( /* FR_OK(0):succeeded, !=0:error */
if (pclst == 0) { /* Does the object have no chain? */
obj->stat = 0; /* Change the object status 'initial' */
} else {
if (obj->stat == 3 && pclst >= obj->sclust && pclst <= obj->sclust + obj->n_cont) { /* Did the chain get contiguous? */
obj->stat = 2; /* Change the object status 'contiguous' */
if (obj->stat == 0) { /* Is it a fragmented chain from the beginning of this session? */
clst = obj->sclust; /* Follow the chain to check if it gets contiguous */
while (clst != pclst) {
nxt = get_fat(obj, clst);
if (nxt < 2) return FR_INT_ERR;
if (nxt == 0xFFFFFFFF) return FR_DISK_ERR;
if (nxt != clst + 1) break; /* Not contiguous? */
clst++;
}
if (clst == pclst) { /* Has the chain got contiguous again? */
obj->stat = 2; /* Change the chain status 'contiguous' */
}
} else {
if (obj->stat == 3 && pclst >= obj->sclust && pclst <= obj->sclust + obj->n_cont) { /* Was the chain fragmented in this session and got contiguous again? */
obj->stat = 2; /* Change the chain status 'contiguous' */
}
}
}
}