aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/attrib.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ntfs/attrib.c')
-rw-r--r--fs/ntfs/attrib.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 9480a0526cd3..1663f5c3c6aa 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -1,7 +1,7 @@
1/** 1/**
2 * attrib.c - NTFS attribute operations. Part of the Linux-NTFS project. 2 * attrib.c - NTFS attribute operations. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2001-2005 Anton Altaparmakov 4 * Copyright (c) 2001-2006 Anton Altaparmakov
5 * Copyright (c) 2002 Richard Russon 5 * Copyright (c) 2002 Richard Russon
6 * 6 *
7 * This program/include file is free software; you can redistribute it and/or 7 * This program/include file is free software; you can redistribute it and/or
@@ -1048,7 +1048,7 @@ do_next_attr_loop:
1048 le32_to_cpu(ctx->mrec->bytes_allocated)) 1048 le32_to_cpu(ctx->mrec->bytes_allocated))
1049 break; 1049 break;
1050 if (a->type == AT_END) 1050 if (a->type == AT_END)
1051 continue; 1051 break;
1052 if (!a->length) 1052 if (!a->length)
1053 break; 1053 break;
1054 if (al_entry->instance != a->instance) 1054 if (al_entry->instance != a->instance)
@@ -1695,7 +1695,9 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
1695 a->data.non_resident.initialized_size = 1695 a->data.non_resident.initialized_size =
1696 cpu_to_sle64(attr_size); 1696 cpu_to_sle64(attr_size);
1697 if (NInoSparse(ni) || NInoCompressed(ni)) { 1697 if (NInoSparse(ni) || NInoCompressed(ni)) {
1698 a->data.non_resident.compression_unit = 4; 1698 a->data.non_resident.compression_unit = 0;
1699 if (NInoCompressed(ni) || vol->major_ver < 3)
1700 a->data.non_resident.compression_unit = 4;
1699 a->data.non_resident.compressed_size = 1701 a->data.non_resident.compressed_size =
1700 a->data.non_resident.allocated_size; 1702 a->data.non_resident.allocated_size;
1701 } else 1703 } else
@@ -1714,13 +1716,20 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
1714 ni->allocated_size = new_size; 1716 ni->allocated_size = new_size;
1715 if (NInoSparse(ni) || NInoCompressed(ni)) { 1717 if (NInoSparse(ni) || NInoCompressed(ni)) {
1716 ni->itype.compressed.size = ni->allocated_size; 1718 ni->itype.compressed.size = ni->allocated_size;
1717 ni->itype.compressed.block_size = 1U << 1719 if (a->data.non_resident.compression_unit) {
1718 (a->data.non_resident.compression_unit + 1720 ni->itype.compressed.block_size = 1U << (a->data.
1719 vol->cluster_size_bits); 1721 non_resident.compression_unit +
1720 ni->itype.compressed.block_size_bits = 1722 vol->cluster_size_bits);
1721 ffs(ni->itype.compressed.block_size) - 1; 1723 ni->itype.compressed.block_size_bits =
1722 ni->itype.compressed.block_clusters = 1U << 1724 ffs(ni->itype.compressed.block_size) -
1723 a->data.non_resident.compression_unit; 1725 1;
1726 ni->itype.compressed.block_clusters = 1U <<
1727 a->data.non_resident.compression_unit;
1728 } else {
1729 ni->itype.compressed.block_size = 0;
1730 ni->itype.compressed.block_size_bits = 0;
1731 ni->itype.compressed.block_clusters = 0;
1732 }
1724 vi->i_blocks = ni->itype.compressed.size >> 9; 1733 vi->i_blocks = ni->itype.compressed.size >> 9;
1725 } else 1734 } else
1726 vi->i_blocks = ni->allocated_size >> 9; 1735 vi->i_blocks = ni->allocated_size >> 9;
@@ -2429,16 +2438,12 @@ undo_alloc:
2429 "chkdsk to recover.", IS_ERR(m) ? 2438 "chkdsk to recover.", IS_ERR(m) ?
2430 "restore attribute search context" : 2439 "restore attribute search context" :
2431 "truncate attribute runlist"); 2440 "truncate attribute runlist");
2432 make_bad_inode(vi);
2433 make_bad_inode(VFS_I(base_ni));
2434 NVolSetErrors(vol); 2441 NVolSetErrors(vol);
2435 } else if (mp_rebuilt) { 2442 } else if (mp_rebuilt) {
2436 if (ntfs_attr_record_resize(m, a, attr_len)) { 2443 if (ntfs_attr_record_resize(m, a, attr_len)) {
2437 ntfs_error(vol->sb, "Failed to restore attribute " 2444 ntfs_error(vol->sb, "Failed to restore attribute "
2438 "record in error code path. Run " 2445 "record in error code path. Run "
2439 "chkdsk to recover."); 2446 "chkdsk to recover.");
2440 make_bad_inode(vi);
2441 make_bad_inode(VFS_I(base_ni));
2442 NVolSetErrors(vol); 2447 NVolSetErrors(vol);
2443 } else /* if (success) */ { 2448 } else /* if (success) */ {
2444 if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu( 2449 if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu(
@@ -2451,8 +2456,6 @@ undo_alloc:
2451 "mapping pairs array in error " 2456 "mapping pairs array in error "
2452 "code path. Run chkdsk to " 2457 "code path. Run chkdsk to "
2453 "recover."); 2458 "recover.");
2454 make_bad_inode(vi);
2455 make_bad_inode(VFS_I(base_ni));
2456 NVolSetErrors(vol); 2459 NVolSetErrors(vol);
2457 } 2460 }
2458 flush_dcache_mft_record_page(ctx->ntfs_ino); 2461 flush_dcache_mft_record_page(ctx->ntfs_ino);