Commit 3aec97e0 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'exfat-for-6.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat

Pull exfat fix from Namjae Jeon:

 - Fix ftruncate failure when allocating non-contiguous clusters

* tag 'exfat-for-6.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/exfat:
  exfat: fix appending discontinuous clusters to empty file
parents 1678f8d8 3a784504
...@@ -35,13 +35,18 @@ static int exfat_cont_expand(struct inode *inode, loff_t size) ...@@ -35,13 +35,18 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
if (new_num_clusters == num_clusters) if (new_num_clusters == num_clusters)
goto out; goto out;
exfat_chain_set(&clu, ei->start_clu, num_clusters, ei->flags); if (num_clusters) {
ret = exfat_find_last_cluster(sb, &clu, &last_clu); exfat_chain_set(&clu, ei->start_clu, num_clusters, ei->flags);
if (ret) ret = exfat_find_last_cluster(sb, &clu, &last_clu);
return ret; if (ret)
return ret;
clu.dir = last_clu + 1;
} else {
last_clu = EXFAT_EOF_CLUSTER;
clu.dir = EXFAT_EOF_CLUSTER;
}
clu.dir = (last_clu == EXFAT_EOF_CLUSTER) ?
EXFAT_EOF_CLUSTER : last_clu + 1;
clu.size = 0; clu.size = 0;
clu.flags = ei->flags; clu.flags = ei->flags;
...@@ -51,17 +56,19 @@ static int exfat_cont_expand(struct inode *inode, loff_t size) ...@@ -51,17 +56,19 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)
return ret; return ret;
/* Append new clusters to chain */ /* Append new clusters to chain */
if (clu.flags != ei->flags) { if (num_clusters) {
exfat_chain_cont_cluster(sb, ei->start_clu, num_clusters); if (clu.flags != ei->flags)
ei->flags = ALLOC_FAT_CHAIN; if (exfat_chain_cont_cluster(sb, ei->start_clu, num_clusters))
} goto free_clu;
if (clu.flags == ALLOC_FAT_CHAIN)
if (exfat_ent_set(sb, last_clu, clu.dir)) if (clu.flags == ALLOC_FAT_CHAIN)
goto free_clu; if (exfat_ent_set(sb, last_clu, clu.dir))
goto free_clu;
if (num_clusters == 0) } else
ei->start_clu = clu.dir; ei->start_clu = clu.dir;
ei->flags = clu.flags;
out: out:
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
/* Expanded range not zeroed, do not update valid_size */ /* Expanded range not zeroed, do not update valid_size */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment