run.c (528c9b3d1edf291685151afecd741d176f527ddf) | run.c (195c52bdd5d5ecfdabf5a7c6159efe299e534f84) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * 4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved. 5 * 6 * TODO: try to use extents tree (instead of array) 7 */ 8 --- 240 unchanged lines hidden (view full) --- 249 return; 250 } 251 r = run->runs; 252 memmove(r, r + index, sizeof(*r) * (run->count - index)); 253 254 run->count -= index; 255 256 if (!run->count) { | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * 4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved. 5 * 6 * TODO: try to use extents tree (instead of array) 7 */ 8 --- 240 unchanged lines hidden (view full) --- 249 return; 250 } 251 r = run->runs; 252 memmove(r, r + index, sizeof(*r) * (run->count - index)); 253 254 run->count -= index; 255 256 if (!run->count) { |
257 ntfs_vfree(run->runs); | 257 kvfree(run->runs); |
258 run->runs = NULL; 259 run->allocated = 0; 260 } 261} 262 263/* 264 * run_truncate 265 * --- 22 unchanged lines hidden (view full) --- 288 * At this point 'index' is set to 289 * position that should be thrown away (including index itself) 290 * Simple one - just set the limit. 291 */ 292 run->count = index; 293 294 /* Do not reallocate array 'runs'. Only free if possible */ 295 if (!index) { | 258 run->runs = NULL; 259 run->allocated = 0; 260 } 261} 262 263/* 264 * run_truncate 265 * --- 22 unchanged lines hidden (view full) --- 288 * At this point 'index' is set to 289 * position that should be thrown away (including index itself) 290 * Simple one - just set the limit. 291 */ 292 run->count = index; 293 294 /* Do not reallocate array 'runs'. Only free if possible */ 295 if (!index) { |
296 ntfs_vfree(run->runs); | 296 kvfree(run->runs); |
297 run->runs = NULL; 298 run->allocated = 0; 299 } 300} 301 302/* trim head and tail if necessary*/ 303void run_truncate_around(struct runs_tree *run, CLST vcn) 304{ --- 78 unchanged lines hidden (view full) --- 383 bytes = (size_t)1 384 << (2 + blksize_bits(used)); 385 } else { 386 bytes = run->allocated + (16 * PAGE_SIZE); 387 } 388 389 WARN_ON(!is_mft && bytes > NTFS3_RUN_MAX_BYTES); 390 | 297 run->runs = NULL; 298 run->allocated = 0; 299 } 300} 301 302/* trim head and tail if necessary*/ 303void run_truncate_around(struct runs_tree *run, CLST vcn) 304{ --- 78 unchanged lines hidden (view full) --- 383 bytes = (size_t)1 384 << (2 + blksize_bits(used)); 385 } else { 386 bytes = run->allocated + (16 * PAGE_SIZE); 387 } 388 389 WARN_ON(!is_mft && bytes > NTFS3_RUN_MAX_BYTES); 390 |
391 new_ptr = ntfs_vmalloc(bytes); | 391 new_ptr = kvmalloc(bytes, GFP_KERNEL); |
392 393 if (!new_ptr) 394 return false; 395 396 r = new_ptr + index; 397 memcpy(new_ptr, run->runs, 398 index * sizeof(struct ntfs_run)); 399 memcpy(r + 1, run->runs + index, 400 sizeof(struct ntfs_run) * (run->count - index)); 401 | 392 393 if (!new_ptr) 394 return false; 395 396 r = new_ptr + index; 397 memcpy(new_ptr, run->runs, 398 index * sizeof(struct ntfs_run)); 399 memcpy(r + 1, run->runs + index, 400 sizeof(struct ntfs_run) * (run->count - index)); 401 |
402 ntfs_vfree(run->runs); | 402 kvfree(run->runs); |
403 run->runs = new_ptr; 404 run->allocated = bytes; 405 406 } else { 407 size_t i = run->count - index; 408 409 r = run->runs + index; 410 --- 702 unchanged lines hidden --- | 403 run->runs = new_ptr; 404 run->allocated = bytes; 405 406 } else { 407 size_t i = run->count - index; 408 409 r = run->runs + index; 410 --- 702 unchanged lines hidden --- |