+allocate_cluster:
+ exfat_de_iter_get_dirty(de_iter, 1, &stream_de);
+ err = exfat_find_free_cluster(exfat, exfat->start_clu, &new_clus);
+ if (err) {
+ exfat->start_clu = EXFAT_FIRST_CLUSTER;
+ exfat_err("failed to find a free cluster\n");
+ return -ENOSPC;
+ }
+ exfat->start_clu = new_clus;
+
+ if (exfat_set_fat(exfat, new_clus, EXFAT_EOF_CLUSTER))
+ return -EIO;
+
+ /* zero out the new cluster */
+ if (exfat_write(exfat->blk_dev->dev_fd, exfat->zero_cluster,
+ exfat->clus_size, exfat_c2o(exfat, new_clus)) !=
+ (ssize_t)exfat->clus_size) {
+ exfat_err("failed to fill new cluster with zeroes\n");
+ return -EIO;
+ }
+
+ /* modify the number of cluster form 0 to 1 */
+ count = 1;
+ stream_de->stream_start_clu = cpu_to_le32(new_clus);
+ stream_de->stream_size = cpu_to_le64(count * exfat->clus_size);
+ stream_de->stream_valid_size = cpu_to_le64(count * exfat->clus_size);
+ stream_de->dentry.stream.flags |= EXFAT_SF_CONTIGUOUS;
+ node->first_clus = new_clus;
+ node->size = count * exfat->clus_size;
+ node->is_contiguous = true;
+ exfat_bitmap_set(exfat->alloc_bitmap, new_clus);
+ return 1;