Prechádzať zdrojové kódy

xfs: add DAX truncate support

When we truncate a DAX file, we need to call through the DAX page
truncation path rather than through block_truncate_page() so that
mappings and block zeroing are all handled correctly. Otherwise,
truncate does not need to change.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Dave Chinner 10 rokov pred
rodič
commit
9969441f9f
1 zmenil súbory, kde vykonal 5 pridanie a 1 odobranie
  1. 5 1
      fs/xfs/xfs_iops.c

+ 5 - 1
fs/xfs/xfs_iops.c

@@ -851,7 +851,11 @@ xfs_setattr_size(
 	 * to hope that the caller sees ENOMEM and retries the truncate
 	 * to hope that the caller sees ENOMEM and retries the truncate
 	 * operation.
 	 * operation.
 	 */
 	 */
-	error = block_truncate_page(inode->i_mapping, newsize, xfs_get_blocks);
+	if (IS_DAX(inode))
+		error = dax_truncate_page(inode, newsize, xfs_get_blocks_direct);
+	else
+		error = block_truncate_page(inode->i_mapping, newsize,
+					    xfs_get_blocks);
 	if (error)
 	if (error)
 		return error;
 		return error;
 	truncate_setsize(inode, newsize);
 	truncate_setsize(inode, newsize);