summaryrefslogtreecommitdiff
path: root/fs/ntfs3/attrib.c
diff options
context:
space:
mode:
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2021-08-31 18:52:39 +0300
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2021-08-31 19:07:11 +0300
commit78ab59fee07f22464f32eafebab2bd97ba94ff2d (patch)
tree8c906238a8ffbc639ce1911295f6e961e6212f6e /fs/ntfs3/attrib.c
parenta97131c29c997e81b6fa1d1adf8f3ca07b63a2e1 (diff)
fs/ntfs3: Rework file operations
Rename now works "Add new name and remove old name". "Remove old name and add new name" may result in bad inode if we can't add new name and then can't restore (add) old name. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs/ntfs3/attrib.c')
-rw-r--r--fs/ntfs3/attrib.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 4b285f704e62..ffc323bacc9f 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -218,9 +218,11 @@ int attr_allocate_clusters(struct ntfs_sb_info *sbi, struct runs_tree *run,
}
out:
- /* Undo. */
- run_deallocate_ex(sbi, run, vcn0, vcn - vcn0, NULL, false);
- run_truncate(run, vcn0);
+ /* Undo 'ntfs_look_for_free_space' */
+ if (vcn - vcn0) {
+ run_deallocate_ex(sbi, run, vcn0, vcn - vcn0, NULL, false);
+ run_truncate(run, vcn0);
+ }
return err;
}
@@ -701,7 +703,7 @@ pack_runs:
* (list entry for std attribute always first).
* So it is safe to step back.
*/
- mi_remove_attr(mi, attr);
+ mi_remove_attr(NULL, mi, attr);
if (!al_remove_le(ni, le)) {
err = -EINVAL;
@@ -1004,7 +1006,7 @@ repack:
end = next_svcn;
while (end > evcn) {
/* Remove segment [svcn : evcn). */
- mi_remove_attr(mi, attr);
+ mi_remove_attr(NULL, mi, attr);
if (!al_remove_le(ni, le)) {
err = -EINVAL;
@@ -1600,7 +1602,7 @@ repack:
end = next_svcn;
while (end > evcn) {
/* Remove segment [svcn : evcn). */
- mi_remove_attr(mi, attr);
+ mi_remove_attr(NULL, mi, attr);
if (!al_remove_le(ni, le)) {
err = -EINVAL;
@@ -1836,13 +1838,12 @@ int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes)
u16 le_sz;
u16 roff = le16_to_cpu(attr->nres.run_off);
- /* run==1 means unpack and deallocate. */
run_unpack_ex(RUN_DEALLOCATE, sbi, ni->mi.rno, svcn,
evcn1 - 1, svcn, Add2Ptr(attr, roff),
le32_to_cpu(attr->size) - roff);
/* Delete this attribute segment. */
- mi_remove_attr(mi, attr);
+ mi_remove_attr(NULL, mi, attr);
if (!le)
break;