2023-02-27 13:07 GMT+09:00, Yuezhang.Mo@xxxxxxxx <Yuezhang.Mo@xxxxxxxx>: > Hi Namjae, > >> > >> >> > + if (hint_clu == sbi->num_clusters) { >> >> > hint_clu = EXFAT_FIRST_CLUSTER; >> >> > p_chain->flags = ALLOC_FAT_CHAIN; >> >> > } >> > This is normal case, so let exfat rewind to the first cluster. >> > >> >> > + /* check cluster validation */ >> >> > + if (!is_valid_cluster(sbi, hint_clu)) { >> >> > + exfat_err(sb, "hint_cluster is invalid (%u)", hint_clu); >> >> > + ret = -EIO; >> >> There is no problem with allocation when invalid hint clu. >> >> It is right to handle it as before instead returning -EIO. >> > We think all other case are real error case, so, error print and >> > return EIO. >> Why ? >> >> > May I confirm is there any normal case in here? >> Could you please explain more ? I can't understand what you are saying. >> > > > `hint_clu` has the following cases. > > 1. Create a new cluster chain: `hint_clu == EXFAT_EOF_CLUSTER` > 2. Append a new cluster to a cluster chain: `hint_clu = last_clu + 1` > 2.1 ` hint_clu == sbi-> num_clusters` > 2.2 `EXFAT_FIRST_CLUTER <= hint_clu < sbi-> num_clusters` > > This commit splits case 2 to 2.1 and 2.2, and handles case 2.1 before > calling is_valid_cluster(). > So is_valid_cluster() is always true, even removing the check of > is_valid_cluster() is fine. > > But considering that this check can find bugs in future code updates, we > keep this check and return -EIO. > If not returned EIO and continue, bug may not be revealed. As I said on previous mail, We print warning message for this before rewinding. There is absolutely no reason to return an error... >