Skip to content

Commit

Permalink
8265231: (fc) ReadDirect and WriteDirect tests fail after fix for JDK…
Browse files Browse the repository at this point in the history
…-8264821

Reviewed-by: alanb, dcubed, darcy, chegar
  • Loading branch information
Brian Burkhalter committed Apr 14, 2021
1 parent 57f86a0 commit d1b28e7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 26 deletions.
Expand Up @@ -47,9 +47,8 @@
public class DirectIOTest {

private static final int BASE_SIZE = 4096;
private static long blockSize;

private static int testWrite(Path p) throws Exception {
private static int testWrite(Path p, long blockSize) throws Exception {
try (FileChannel fc = FileChannel.open(p, StandardOpenOption.WRITE,
ExtendedOpenOption.DIRECT)) {
int bs = (int)blockSize;
Expand All @@ -67,7 +66,7 @@ private static int testWrite(Path p) throws Exception {
}
}

private static int testRead(Path p) throws Exception {
private static int testRead(Path p, long blockSize) throws Exception {
try (FileChannel fc = FileChannel.open(p, ExtendedOpenOption.DIRECT)) {
int bs = (int)blockSize;
int size = Math.max(BASE_SIZE, bs);
Expand All @@ -94,17 +93,17 @@ private static boolean isFileInCache(int size, Path p) {

public static void main(String[] args) throws Exception {
Path p = createTempFile();
blockSize = Files.getFileStore(p).getBlockSize();
long blockSize = Files.getFileStore(p).getBlockSize();

System.loadLibrary("DirectIO");

try {
int size = testWrite(p);
int size = testWrite(p, blockSize);
if (isFileInCache(size, p)) {
throw new RuntimeException("DirectIO is not working properly with "
+ "write. File still exists in cache!");
}
size = testRead(p);
size = testRead(p, blockSize);
if (isFileInCache(size, p)) {
throw new RuntimeException("DirectIO is not working properly with "
+ "read. File still exists in cache!");
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -70,10 +70,6 @@ public static void main(String[] args) throws Exception {

private static boolean initTests() throws Exception {
Path p = DirectIOTest.createTempFile();
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
Files.delete(p);
return false;
}
try {
FileStore fs = Files.getFileStore(p);
alignment = (int)fs.getBlockSize();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -59,10 +59,6 @@ public class PwriteDirect {

private static boolean initTests() throws Exception {
Path p = DirectIOTest.createTempFile();
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
Files.delete(p);
return false;
}
try {
FileStore fs = Files.getFileStore(p);
alignment = (int)fs.getBlockSize();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -58,10 +58,6 @@ public class ReadDirect {

private static boolean initTests() throws Exception {
Path p = DirectIOTest.createTempFile();
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
Files.delete(p);
return false;
}
try {
FileStore fs = Files.getFileStore(p);
alignment = (int)fs.getBlockSize();
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -48,10 +48,6 @@ public class WriteDirect {

private static boolean initTests() throws Exception {
Path p = DirectIOTest.createTempFile();
if (!DirectIOTest.isDirectIOSupportedByFS(p)) {
Files.delete(p);
return false;
}
try {
FileStore fs = Files.getFileStore(p);
alignment = (int)fs.getBlockSize();
Expand Down

1 comment on commit d1b28e7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.