fs/ntfs3: Fix work with fragmented xattr
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Fri, 13 May 2022 16:54:23 +0000 (19:54 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Wed, 3 Aug 2022 15:25:05 +0000 (18:25 +0300)
In some cases xattr is too fragmented,
so we need to load it before writing.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/xattr.c

index ddd9fc9129edda0d286c60f36d9dda287cb65c34..02f6a933ee79777f364e484b7459282c3dcad897 100644 (file)
@@ -118,7 +118,7 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
 
                run_init(&run);
 
-               err = attr_load_runs(attr_ea, ni, &run, NULL);
+               err = attr_load_runs_range(ni, ATTR_EA, NULL, 0, &run, 0, size);
                if (!err)
                        err = ntfs_read_run_nb(sbi, &run, 0, ea_p, size, NULL);
                run_close(&run);
@@ -444,6 +444,11 @@ update_ea:
                /* Delete xattr, ATTR_EA */
                ni_remove_attr_le(ni, attr, mi, le);
        } else if (attr->non_res) {
+               err = attr_load_runs_range(ni, ATTR_EA, NULL, 0, &ea_run, 0,
+                                          size);
+               if (err)
+                       goto out;
+
                err = ntfs_sb_write_run(sbi, &ea_run, 0, ea_all, size, 0);
                if (err)
                        goto out;