LUCENE-2615: don't create files w/ bogus permissions; don't hardwire buffer size to 1MB

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@988216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-08-23 17:22:37 +00:00
parent 07df8d5210
commit 4e737ef56e
3 changed files with 20 additions and 14 deletions

View File

@ -32,6 +32,7 @@ API Changes
safety, serialization, and performance problems. If you have
written a custom RegexCapabilities it will need to be updated
to the new API. (Robert Muir, Uwe Schindler)
======================= Lucene 3.x (not yet released) =======================
Changes in backwards compatibility policy
@ -110,6 +111,10 @@ Bug fixes
* LUCENE-2524: FastVectorHighlighter: use mod for getting colored tag.
(Koji Sekiguchi)
* LUCENE-2615: Fix DirectIOLinuxDirectory to not assign bogus
permissions to newly created files, and to not silently hardwire
buffer size to 1 MB. (Mark Miller, Robert Muir, Mike McCandless)
API Changes
* LUCENE-2147: Spatial GeoHashUtils now always decode GeoHash strings

View File

@ -46,37 +46,36 @@ public class DirectIOLinuxDirectory extends FSDirectory {
private final static long ALIGN = 512;
private final static long ALIGN_NOT_MASK = ~(ALIGN-1);
private final int forcedBufferSize;
/** Create a new NIOFSDirectory for the named location.
*
* @param path the path of the directory
* @param lockFactory the lock factory to use, or null for the default
* ({@link NativeFSLockFactory});
* @param forcedBufferSize if this is 0, just use Lucene's
* default buffer size; else, force this buffer size.
* For best performance, force the buffer size to
* something fairly large (eg 1 MB), but note that this
* will eat up the JRE's direct buffer storage space
* @throws IOException
*/
public DirectIOLinuxDirectory(File path, LockFactory lockFactory) throws IOException {
public DirectIOLinuxDirectory(File path, LockFactory lockFactory, int forcedBufferSize) throws IOException {
super(path, lockFactory);
}
/** Create a new NIOFSDirectory for the named location and {@link NativeFSLockFactory}.
*
* @param path the path of the directory
* @throws IOException
*/
public DirectIOLinuxDirectory(File path) throws IOException {
super(path, null);
this.forcedBufferSize = forcedBufferSize;
}
@Override
public IndexInput openInput(String name, int bufferSize) throws IOException {
ensureOpen();
return new DirectIOLinuxIndexInput(new File(getDirectory(), name), bufferSize);
return new DirectIOLinuxIndexInput(new File(getDirectory(), name), forcedBufferSize == 0 ? bufferSize : forcedBufferSize);
}
@Override
public IndexOutput createOutput(String name) throws IOException {
ensureOpen();
ensureCanWrite(name);
return new DirectIOLinuxIndexOutput(new File(getDirectory(), name), 4096);
return new DirectIOLinuxIndexOutput(new File(getDirectory(), name), forcedBufferSize == 0 ? BufferedIndexOutput.BUFFER_SIZE : forcedBufferSize);
}
private final static class DirectIOLinuxIndexOutput extends IndexOutput {

View File

@ -1,9 +1,11 @@
#include <jni.h>
#include <fcntl.h> // posix_fadvise
#include <fcntl.h> // posix_fadvise, constants for open
#include <string.h> // strerror
#include <errno.h> // errno
#include <unistd.h> // pread
#include <sys/mman.h> // posix_madvise, madvise
#include <sys/types.h> // constants for open
#include <sys/stat.h> // constants for open
// java -cp .:lib/junit-4.7.jar:./build/classes/test:./build/classes/java:./build/classes/demo -Dlucene.version=2.9-dev -DtempDir=build -ea org.junit.runner.JUnitCore org.apache.lucene.index.TestDoc
@ -97,7 +99,7 @@ JNIEXPORT jobject JNICALL Java_org_apache_lucene_store_NativePosixUtil_open_1dir
if (readOnly) {
fd = open(fname, O_RDONLY | O_DIRECT);
} else {
fd = open(fname, O_RDWR | O_CREAT | O_DIRECT);
fd = open(fname, O_RDWR | O_CREAT | O_DIRECT, 0666);
}
//printf("open %s -> %d; ro %d\n", fname, fd, readOnly); fflush(stdout);