|
@@ -104,6 +104,7 @@ class BlockReceiver implements Closeable {
|
|
|
private boolean dropCacheBehindWrites;
|
|
|
private long lastCacheManagementOffset = 0;
|
|
|
private boolean syncBehindWrites;
|
|
|
+ private boolean syncBehindWritesInBackground;
|
|
|
|
|
|
/** The client name. It is empty if a datanode is the client */
|
|
|
private final String clientname;
|
|
@@ -207,6 +208,8 @@ class BlockReceiver implements Closeable {
|
|
|
datanode.getDnConf().dropCacheBehindWrites :
|
|
|
cachingStrategy.getDropBehind();
|
|
|
this.syncBehindWrites = datanode.getDnConf().syncBehindWrites;
|
|
|
+ this.syncBehindWritesInBackground = datanode.getDnConf().
|
|
|
+ syncBehindWritesInBackground;
|
|
|
|
|
|
final boolean isCreate = isDatanode || isTransfer
|
|
|
|| stage == BlockConstructionStage.PIPELINE_SETUP_CREATE;
|
|
@@ -668,10 +671,17 @@ class BlockReceiver implements Closeable {
|
|
|
// of file
|
|
|
//
|
|
|
if (syncBehindWrites) {
|
|
|
- NativeIO.POSIX.syncFileRangeIfPossible(outFd,
|
|
|
- lastCacheManagementOffset,
|
|
|
- offsetInBlock - lastCacheManagementOffset,
|
|
|
- NativeIO.POSIX.SYNC_FILE_RANGE_WRITE);
|
|
|
+ if (syncBehindWritesInBackground) {
|
|
|
+ this.datanode.getFSDataset().submitBackgroundSyncFileRangeRequest(
|
|
|
+ block, outFd, lastCacheManagementOffset,
|
|
|
+ offsetInBlock - lastCacheManagementOffset,
|
|
|
+ NativeIO.POSIX.SYNC_FILE_RANGE_WRITE);
|
|
|
+ } else {
|
|
|
+ NativeIO.POSIX.syncFileRangeIfPossible(outFd,
|
|
|
+ lastCacheManagementOffset, offsetInBlock
|
|
|
+ - lastCacheManagementOffset,
|
|
|
+ NativeIO.POSIX.SYNC_FILE_RANGE_WRITE);
|
|
|
+ }
|
|
|
}
|
|
|
//
|
|
|
// For POSIX_FADV_DONTNEED, we want to drop from the beginning
|