Skip to contentSkip to conversation

ntfs: accept standard sparse compression unit

PATCH Applied Hyunchul Lee 3 participants 3 messages Sep 28 – Sep 29 NTFS filesystem

lore
Share & tools
lore

Hyunchul Lee

author maintainer
#0 lore raw

PATCH 1/1 ntfs: accept standard sparse compression unit

Windows native sparse-file inspection shows that a non-resident $DATA attribute can be marked sparse and record the standard compression unit
(4) even when the file is not compressed.

---
 fs/ntfs/inode.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
fs/ntfs/inode.c +10 -3
index 9583b2c6c7a2..de848180749d 100644
@@ -1148,14 +1148,21 @@ static int ntfs_read_locked_inode(struct inode *vi)
 					goto unm_err_out;
 				}
 
+				/*
+				 * Windows stores the standard compression unit in
+				 * sparse attributes even when the data is not compressed.
+				 */
 				if (NInoSparse(ni) &&
 				    a->data.non_resident.compression_unit &&
 				    a->data.non_resident.compression_unit !=
-				     vol->sparse_compression_unit) {
+				     vol->sparse_compression_unit &&
+				    a->data.non_resident.compression_unit !=
+				     STANDARD_COMPRESSION_UNIT) {
 					ntfs_error(vi->i_sb,
-						   "Found non-standard compression unit (%u instead of 0 or %d).  Cannot handle this.",
+						   "Found non-standard compression unit (%u instead of 0, %d, or %d).  Cannot handle this.",
 						   a->data.non_resident.compression_unit,
-						   vol->sparse_compression_unit);
+						   vol->sparse_compression_unit,
+						   STANDARD_COMPRESSION_UNIT);
 					err = -EOPNOTSUPP;
 					goto unm_err_out;
 				}
Signature · 1 line
2.43.0
Reviewed-by Baolin Liu on v1 1/1
#1 lore raw
Quoted 28 lines · Hyunchul Lee

Windows native sparse-file inspection shows that a non-resident $DATA attribute can be marked sparse and record the standard compression unit
(4) even when the file is not compressed.

---
  fs/ntfs/inode.c | 13 ++++++++++---
  1 file changed, 10 insertions(+), 3 deletions(-)
fs/ntfs/inode.c +7 -1
index 9583b2c6c7a2..de848180749d 100644
@@ -1148,14 +1148,21 @@ static int ntfs_read_locked_inode(struct inode *vi)
  					goto unm_err_out;
  				}
 
+				/*
+				 * Windows stores the standard compression unit in
+				 * sparse attributes even when the data is not compressed.
+				 */
  				if (NInoSparse(ni) &&
  				    a->data.non_resident.compression_unit &&
  				    a->data.non_resident.compression_unit !=
-				     vol->sparse_compression_unit) {
+				     vol->sparse_compression_unit &&
+				    a->data.non_resident.compression_unit !=
+				     STANDARD_COMPRESSION_UNIT) {

fs/ntfs/inode.c static int ntfs_read_locked_inode(struct inode *vi) · line 1168

Quoted 10 lines
fs/ntfs/inode.c +3 -2
  					ntfs_error(vi->i_sb,
-						   "Found non-standard compression unit (%u instead of 0 or %d).  Cannot handle this.",
+						   "Found non-standard compression unit (%u instead of 0, %d, or %d).  Cannot handle this.",
  						   a->data.non_resident.compression_unit,
-						   vol->sparse_compression_unit);
+						   vol->sparse_compression_unit,
+						   STANDARD_COMPRESSION_UNIT);
  					err = -EOPNOTSUPP;
  					goto unm_err_out;
  				}

Looks good to me.