diff --git a/core/common/src/main/java/alluxio/conf/PropertyKey.java b/core/common/src/main/java/alluxio/conf/PropertyKey.java index 1b1949ddf1c6..55b31590e97a 100755 --- a/core/common/src/main/java/alluxio/conf/PropertyKey.java +++ b/core/common/src/main/java/alluxio/conf/PropertyKey.java @@ -3927,6 +3927,14 @@ public String toString() { .setDescription("Preferred media type while storing file's blocks.") .setScope(Scope.CLIENT) .build(); + + public static final PropertyKey USER_BLOCK_SIZE_OVERRIDE_UFS_ENABLED = + new Builder(Name.USER_BLOCK_SIZE_ENABLED) + .setDefaultValue(false) + .setDescription("When reading a file from UFS, whether Alluxio should ignore the UFS block size and rely on the Alluxio configuration.") + .setConsistencyCheckLevel(ConsistencyCheckLevel.WARN) + .setScope(Scope.ALL) + .build(); public static final PropertyKey USER_BLOCK_SIZE_BYTES_DEFAULT = new Builder(Name.USER_BLOCK_SIZE_BYTES_DEFAULT) .setDefaultValue("64MB") @@ -6281,6 +6289,8 @@ public static final class Name { "alluxio.user.block.read.metrics.enabled"; public static final String USER_BLOCK_REMOTE_READ_BUFFER_SIZE_BYTES = "alluxio.user.block.remote.read.buffer.size.bytes"; + public static final String USER_BLOCK_SIZE_ENABLED = + "alluxio.user.block.size.enabled"; public static final String USER_BLOCK_SIZE_BYTES_DEFAULT = "alluxio.user.block.size.bytes.default"; public static final String USER_BLOCK_READ_RETRY_SLEEP_MIN = diff --git a/core/server/master/src/main/java/alluxio/master/file/InodeSyncStream.java b/core/server/master/src/main/java/alluxio/master/file/InodeSyncStream.java index ba7a34178f96..9cf7e00cc282 100644 --- a/core/server/master/src/main/java/alluxio/master/file/InodeSyncStream.java +++ b/core/server/master/src/main/java/alluxio/master/file/InodeSyncStream.java @@ -880,6 +880,9 @@ static void loadFileMetadataInternal(RpcContext rpcContext, LockedInodePath inod } ufsLength = ((UfsFileStatus) context.getUfsStatus()).getContentLength(); long blockSize = ((UfsFileStatus) context.getUfsStatus()).getBlockSize(); + if (ServerConfiguration.getBoolean(PropertyKey.USER_BLOCK_SIZE_ENABLED)) { + blockSize = ServerConfiguration.getBytes(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT); + } ufsBlockSizeByte = blockSize != UfsFileStatus.UNKNOWN_BLOCK_SIZE ? blockSize : ufs.getBlockSizeByte(ufsUri.toString());