Skip to content

Commit fa3be92

Browse files
NTFS: Add an extra parameter @last_vcn to ntfs_get_size_for_mapping_pairs()
and ntfs_mapping_pairs_build() to allow the runlist encoding to be partial which is desirable when filling holes in sparse attributes. Update all callers. Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
1 parent 1d58b27 commit fa3be92

5 files changed

Lines changed: 132 additions & 60 deletions

File tree

‎fs/ntfs/ChangeLog‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ ToDo/Notes:
135135
- Change the runlist terminator of the newly allocated cluster(s) to
136136
LCN_ENOENT in ntfs_attr_make_non_resident(). Otherwise the runlist
137137
code gets confused.
138+
- Add an extra parameter @last_vcn to ntfs_get_size_for_mapping_pairs()
139+
and ntfs_mapping_pairs_build() to allow the runlist encoding to be
140+
partial which is desirable when filling holes in sparse attributes.
141+
Update all callers.
138142

139143
2.1.22 - Many bug and race fixes and error handling improvements.
140144

‎fs/ntfs/attrib.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni)
13171317
page = NULL;
13181318
}
13191319
/* Determine the size of the mapping pairs array. */
1320-
mp_size = ntfs_get_size_for_mapping_pairs(vol, rl, 0);
1320+
mp_size = ntfs_get_size_for_mapping_pairs(vol, rl, 0, -1);
13211321
if (unlikely(mp_size < 0)) {
13221322
err = mp_size;
13231323
ntfs_debug("Failed to get size for mapping pairs array, error "
@@ -1416,7 +1416,7 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni)
14161416
cpu_to_sle64(attr_size);
14171417
/* Generate the mapping pairs array into the attribute record. */
14181418
err = ntfs_mapping_pairs_build(vol, (u8*)a + mp_ofs,
1419-
arec_size - mp_ofs, rl, 0, NULL);
1419+
arec_size - mp_ofs, rl, 0, -1, NULL);
14201420
if (unlikely(err)) {
14211421
ntfs_debug("Failed to build mapping pairs, error code %i.",
14221422
err);

‎fs/ntfs/mft.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol)
14071407
BUG_ON(ll < rl2->vcn);
14081408
BUG_ON(ll >= rl2->vcn + rl2->length);
14091409
/* Get the size for the new mapping pairs array for this extent. */
1410-
mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll);
1410+
mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll, -1);
14111411
if (unlikely(mp_size <= 0)) {
14121412
ntfs_error(vol->sb, "Get size for mapping pairs failed for "
14131413
"mft bitmap attribute extent.");
@@ -1441,7 +1441,7 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol)
14411441
/* Generate the mapping pairs array directly into the attr record. */
14421442
ret = ntfs_mapping_pairs_build(vol, (u8*)a +
14431443
le16_to_cpu(a->data.non_resident.mapping_pairs_offset),
1444-
mp_size, rl2, ll, NULL);
1444+
mp_size, rl2, ll, -1, NULL);
14451445
if (unlikely(ret)) {
14461446
ntfs_error(vol->sb, "Failed to build mapping pairs array for "
14471447
"mft bitmap attribute.");
@@ -1529,7 +1529,7 @@ static int ntfs_mft_bitmap_extend_allocation_nolock(ntfs_volume *vol)
15291529
a->data.non_resident.mapping_pairs_offset),
15301530
old_alen - le16_to_cpu(
15311531
a->data.non_resident.mapping_pairs_offset),
1532-
rl2, ll, NULL)) {
1532+
rl2, ll, -1, NULL)) {
15331533
ntfs_error(vol->sb, "Failed to restore mapping pairs "
15341534
"array.%s", es);
15351535
NVolSetErrors(vol);
@@ -1838,7 +1838,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
18381838
BUG_ON(ll < rl2->vcn);
18391839
BUG_ON(ll >= rl2->vcn + rl2->length);
18401840
/* Get the size for the new mapping pairs array for this extent. */
1841-
mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll);
1841+
mp_size = ntfs_get_size_for_mapping_pairs(vol, rl2, ll, -1);
18421842
if (unlikely(mp_size <= 0)) {
18431843
ntfs_error(vol->sb, "Get size for mapping pairs failed for "
18441844
"mft data attribute extent.");
@@ -1877,7 +1877,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
18771877
/* Generate the mapping pairs array directly into the attr record. */
18781878
ret = ntfs_mapping_pairs_build(vol, (u8*)a +
18791879
le16_to_cpu(a->data.non_resident.mapping_pairs_offset),
1880-
mp_size, rl2, ll, NULL);
1880+
mp_size, rl2, ll, -1, NULL);
18811881
if (unlikely(ret)) {
18821882
ntfs_error(vol->sb, "Failed to build mapping pairs array of "
18831883
"mft data attribute.");
@@ -1959,7 +1959,7 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
19591959
a->data.non_resident.mapping_pairs_offset),
19601960
old_alen - le16_to_cpu(
19611961
a->data.non_resident.mapping_pairs_offset),
1962-
rl2, ll, NULL)) {
1962+
rl2, ll, -1, NULL)) {
19631963
ntfs_error(vol->sb, "Failed to restore mapping pairs "
19641964
"array.%s", es);
19651965
NVolSetErrors(vol);

0 commit comments

Comments
 (0)