> >> + clu.size = 0; > >> + old_clu = clu.dir; > >> + ret = exfat_alloc_cluster(root_inode, 1, > >> + &clu, true); > >> + if (ret < 0) { > >> + brelse(bh); > >> + goto end; > >> + } > > > > In exFAT, directory size is limited to 256MB. Please add a check to return -ENOSPC > > instead of allocating a new cluster if the root directory size had reached this limit. > > > Noted. I am switching over to using exfat_find_empty_entry, which > checks for this. I think it is good way to use exfat_find_empty_entry. In exfat_get_volume_label_ptrs, if an empty dentry is found, ei->hint_femp should be set to avoid repeated traversal. > >> + > >> + ret = exfat_ent_set(sb, old_clu, clu.dir); > >> + if (ret < 0) { > >> + exfat_free_cluster(root_inode, &clu); > >> + brelse(bh); > >> + goto end; > >> + } > >> + > >> + ret = exfat_zeroed_cluster(root_inode, clu.dir); > >> + if (ret < 0) { > >> + exfat_free_cluster(root_inode, &clu); > >> + brelse(bh); > >> + goto end; > >> + } > > > > After allocating a new cluster for the root directory, its size needs to be updated. > > > Where would I update the size? I don't think the root directory has a > Stream Extension dentry, would I increment the exfat_inode_info.dir.size > field? The root directory does not have a Stream Extension dentry. We just need to update the new size to root_inode->i_size. If exfat_find_empty_entry is used, root_inode->i_size will be updated by it.