diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c index c58e689fb585..3ebcac4c2864 100644 --- a/fs/ntfs/lcnalloc.c +++ b/fs/ntfs/lcnalloc.c @@ -375,6 +375,16 @@ struct runlist_element *ntfs_cluster_alloc(struct ntfs_volume *vol, const s64 st has_guess = 1; continue; } + /* + * A contiguous request gets a single run. The scan can + * move on without testing the clusters after the run + * (past a bitmap page that is full, to pass 2 or to + * another zone), so return the run when this cluster + * does not follow it. + */ + if (is_contig && rlpos && + lcn + bmp_pos != prev_lcn + prev_run_len) + goto out; /* * Allocate more memory if needed, including space for * the terminator element.