Commit 0c325668 authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: Fix fs/ntfs/lcnalloc.c::ntfs_cluster_alloc() to use LCN_RL_NOT_MAPPED

rather than LCN_ENOENT as runlist terminator.  Also, make it not create a
LCN_RL_NOT_MAPPED element at the beginning.
Signed-off-by: default avatarAnton Altaparmakov <aia21@cantab.net>
parent 450c93ed
...@@ -167,16 +167,9 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn, ...@@ -167,16 +167,9 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
rl = ntfs_malloc_nofs(PAGE_SIZE); rl = ntfs_malloc_nofs(PAGE_SIZE);
if (!rl) if (!rl)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
rlpos = 0; rl[0].vcn = start_vcn;
if (start_vcn) { rl[0].lcn = LCN_RL_NOT_MAPPED;
rl[0].vcn = 0; rl[0].length = 0;
rl[0].lcn = LCN_RL_NOT_MAPPED;
rl[0].length = start_vcn;
rlpos++;
}
rl[rlpos].vcn = start_vcn;
rl[rlpos].lcn = LCN_ENOENT;
rl[rlpos].length = 0;
return rl; return rl;
} }
/* Take the lcnbmp lock for writing. */ /* Take the lcnbmp lock for writing. */
...@@ -405,14 +398,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn, ...@@ -405,14 +398,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
} else { } else {
ntfs_debug("Adding new run, is first " ntfs_debug("Adding new run, is first "
"run."); "run.");
rl[rlpos].vcn = 0; rl[rlpos].vcn = start_vcn;
if (start_vcn) {
rl[rlpos].lcn =
LCN_RL_NOT_MAPPED;
rl[rlpos].length = start_vcn;
rlpos++;
rl[rlpos].vcn = start_vcn;
}
} }
rl[rlpos].lcn = prev_lcn = lcn + bmp_pos; rl[rlpos].lcn = prev_lcn = lcn + bmp_pos;
rl[rlpos].length = prev_run_len = 1; rl[rlpos].length = prev_run_len = 1;
...@@ -746,7 +732,7 @@ switch_to_data1_zone: search_zone = 2; ...@@ -746,7 +732,7 @@ switch_to_data1_zone: search_zone = 2;
/* Add runlist terminator element. */ /* Add runlist terminator element. */
if (likely(rl)) { if (likely(rl)) {
rl[rlpos].vcn = rl[rlpos - 1].vcn + rl[rlpos - 1].length; rl[rlpos].vcn = rl[rlpos - 1].vcn + rl[rlpos - 1].length;
rl[rlpos].lcn = LCN_ENOENT; rl[rlpos].lcn = LCN_RL_NOT_MAPPED;
rl[rlpos].length = 0; rl[rlpos].length = 0;
} }
if (likely(page && !IS_ERR(page))) { if (likely(page && !IS_ERR(page))) {
......
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