Index: lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java
===================================================================
--- lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java	(revision 1138188)
+++ lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java	(working copy)
@@ -105,7 +105,7 @@
               state.segmentInfo.name,
               state.termsIndexDivisor,
               BytesRef.getUTF8SortedAsUnicodeComparator(),
-              state.codecId);
+              state.codecId, state.context);
       success = true;
     } finally {
       if (!success) {
@@ -155,6 +155,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
   }
 }
Index: lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsIndexReader.java
===================================================================
--- lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsIndexReader.java	(revision 1138188)
+++ lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsIndexReader.java	(working copy)
@@ -31,9 +31,9 @@
 public class AppendingTermsIndexReader extends FixedGapTermsIndexReader {
 
   public AppendingTermsIndexReader(Directory dir, FieldInfos fieldInfos,
-          String segment, int indexDivisor, Comparator<BytesRef> termComp, int codecId)
+          String segment, int indexDivisor, Comparator<BytesRef> termComp, int codecId, IOContext context)
           throws IOException {
-    super(dir, fieldInfos, segment, indexDivisor, termComp, codecId, IOContext.DEFAULT);
+    super(dir, fieldInfos, segment, indexDivisor, termComp, codecId, context);
   }
   
   @Override
Index: lucene/src/test/org/apache/lucene/index/values/TestDocValues.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/values/TestDocValues.java	(revision 1138188)
+++ lucene/src/test/org/apache/lucene/index/values/TestDocValues.java	(working copy)
@@ -21,6 +21,7 @@
 import java.util.Comparator;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.values.IndexDocValues.SortedSource;
 import org.apache.lucene.index.values.IndexDocValues.Source;
 import org.apache.lucene.store.Directory;
@@ -61,7 +62,7 @@
 
     Directory dir = newDirectory();
     final AtomicLong trackBytes = new AtomicLong(0);
-    Writer w = Bytes.getWriter(dir, "test", mode, comp, fixedSize, trackBytes);
+    Writer w = Bytes.getWriter(dir, "test", mode, comp, fixedSize, trackBytes, IOContext.DEFAULT);
     int maxDoc = 220;
     final String[] values = new String[maxDoc];
     final int fixedLength = 3 + random.nextInt(7);
@@ -81,7 +82,7 @@
     w.finish(maxDoc);
     assertEquals(0, trackBytes.get());
 
-    IndexDocValues r = Bytes.getValues(dir, "test", mode, fixedSize, maxDoc);
+    IndexDocValues r = Bytes.getValues(dir, "test", mode, fixedSize, maxDoc, IOContext.DEFAULT);
     for (int iter = 0; iter < 2; iter++) {
       ValuesEnum bytesEnum = getEnum(r);
       assertNotNull("enum is null", bytesEnum);
@@ -185,7 +186,7 @@
       for (int rx = 1; rx < 63; rx++, maxV *= 2) {
         Directory dir = newDirectory();
         final AtomicLong trackBytes = new AtomicLong(0);
-        Writer w = Ints.getWriter(dir, "test", false, trackBytes);
+        Writer w = Ints.getWriter(dir, "test", false, trackBytes, IOContext.DEFAULT);
         values[0] = maxMin[j];
         w.add(0, values[0]);
         values[1] = maxMin[j+1];
@@ -199,7 +200,7 @@
         w.finish(NUM_VALUES + additionalDocs);
         assertEquals(0, trackBytes.get());
 
-        IndexDocValues r = Ints.getValues(dir, "test", false);
+        IndexDocValues r = Ints.getValues(dir, "test", false, IOContext.DEFAULT);
         for (int iter = 0; iter < 2; iter++) {
           Source s = getSource(r);
           for (int i = 0; i < NUM_VALUES; i++) {
@@ -250,7 +251,7 @@
   private void runTestFloats(int precision, double delta) throws IOException {
     Directory dir = newDirectory();
     final AtomicLong trackBytes = new AtomicLong(0);
-    Writer w = Floats.getWriter(dir, "test", precision, trackBytes);
+    Writer w = Floats.getWriter(dir, "test", precision, trackBytes, IOContext.DEFAULT);
     final int NUM_VALUES = 777 + random.nextInt(777);;
     final double[] values = new double[NUM_VALUES];
     for (int i = 0; i < NUM_VALUES; i++) {
@@ -263,7 +264,7 @@
     w.finish(NUM_VALUES + additionalValues);
     assertEquals(0, trackBytes.get());
 
-    IndexDocValues r = Floats.getValues(dir, "test", NUM_VALUES + additionalValues);
+    IndexDocValues r = Floats.getValues(dir, "test", NUM_VALUES + additionalValues, IOContext.DEFAULT);
     for (int iter = 0; iter < 2; iter++) {
       Source s = getSource(r);
       for (int i = 0; i < NUM_VALUES; i++) {
Index: lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java	(revision 1138188)
+++ lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java	(working copy)
@@ -223,7 +223,7 @@
 
     @Override
     public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-      return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+      return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
     }
   }
 
Index: lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java	(revision 1138188)
+++ lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java	(working copy)
@@ -30,7 +30,7 @@
 
     IntStreamFactory f = new MockFixedIntBlockCodec(128).getIntFactory();
 
-    IntIndexOutput out = f.createOutput(dir, "test");
+    IntIndexOutput out = f.createOutput(dir, "test", IOContext.DEFAULT);
     for(int i=0;i<11777;i++) {
       out.write(i);
     }
@@ -51,7 +51,7 @@
     Directory dir = newDirectory();
 
     IntStreamFactory f = new MockFixedIntBlockCodec(128).getIntFactory();
-    IntIndexOutput out = f.createOutput(dir, "test");
+    IntIndexOutput out = f.createOutput(dir, "test", IOContext.DEFAULT);
 
     // write no ints
     out.close();
Index: lucene/src/java/org/apache/lucene/index/SegmentNorms.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/SegmentNorms.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/SegmentNorms.java	(working copy)
@@ -221,7 +221,7 @@
     // NOTE: norms are re-written in regular directory, not cfs
     si.advanceNormGen(this.number);
     final String normFileName = si.getNormFileName(this.number);
-    IndexOutput out = owner.directory().createOutput(normFileName, IOContext.DEFAULT);
+    IndexOutput out = owner.directory().createOutput(normFileName, new IOContext(Context.FLUSH));
     boolean success = false;
     try {
       try {
Index: lucene/src/java/org/apache/lucene/index/values/VarSortedBytesImpl.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/VarSortedBytesImpl.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/VarSortedBytesImpl.java	(working copy)
@@ -62,16 +62,15 @@
             BytesRefHash.DEFAULT_CAPACITY, bytesUsed));
 
     public Writer(Directory dir, String id, Comparator<BytesRef> comp,
-        AtomicLong bytesUsed) throws IOException {
-      //nocommit this needs an IOContext too
+        AtomicLong bytesUsed, IOContext context) throws IOException {
       this(dir, id, comp, new DirectTrackingAllocator(ByteBlockPool.BYTE_BLOCK_SIZE, bytesUsed),
-          bytesUsed);
+          bytesUsed, context);
     }
 
     public Writer(Directory dir, String id, Comparator<BytesRef> comp,
-        Allocator allocator, AtomicLong bytesUsed) throws IOException {
+        Allocator allocator, AtomicLong bytesUsed, IOContext context) throws IOException {
       super(dir, id, CODEC_NAME, VERSION_CURRENT, true,
-          new ByteBlockPool(allocator), bytesUsed, IOContext.DEFAULT);
+          new ByteBlockPool(allocator), bytesUsed, context);
       this.comp = comp;
       docToEntry = new int[1];
       docToEntry[0] = -1;
@@ -158,8 +157,8 @@
 
   public static class Reader extends BytesReaderBase {
 
-    Reader(Directory dir, String id, int maxDoc) throws IOException {
-      super(dir, id, CODEC_NAME, VERSION_START, true, IOContext.DEFAULT);
+    Reader(Directory dir, String id, int maxDoc, IOContext context) throws IOException {
+      super(dir, id, CODEC_NAME, VERSION_START, true, context);
     }
 
     @Override
Index: lucene/src/java/org/apache/lucene/index/values/FixedSortedBytesImpl.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/FixedSortedBytesImpl.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/FixedSortedBytesImpl.java	(working copy)
@@ -63,16 +63,15 @@
             BytesRefHash.DEFAULT_CAPACITY, bytesUsed));
 
     public Writer(Directory dir, String id, Comparator<BytesRef> comp,
-        AtomicLong bytesUsed) throws IOException {
-      //nocommit this needs an IOContext too
+        AtomicLong bytesUsed, IOContext context) throws IOException {
       this(dir, id, comp, new DirectTrackingAllocator(ByteBlockPool.BYTE_BLOCK_SIZE, bytesUsed),
-          bytesUsed);
+          bytesUsed, context);
     }
 
     public Writer(Directory dir, String id, Comparator<BytesRef> comp,
-        Allocator allocator, AtomicLong bytesUsed) throws IOException {
+        Allocator allocator, AtomicLong bytesUsed, IOContext context) throws IOException {
       super(dir, id, CODEC_NAME, VERSION_CURRENT, true,
-          new ByteBlockPool(allocator), bytesUsed, IOContext.DEFAULT);
+          new ByteBlockPool(allocator), bytesUsed, context);
       docToEntry = new int[1];
       // docToEntry[0] = -1;
       bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_INT);
@@ -162,8 +161,8 @@
   public static class Reader extends BytesReaderBase {
     private final int size;
 
-    public Reader(Directory dir, String id, int maxDoc) throws IOException {
-      super(dir, id, CODEC_NAME, VERSION_START, true, IOContext.DEFAULT);
+    public Reader(Directory dir, String id, int maxDoc, IOContext context) throws IOException {
+      super(dir, id, CODEC_NAME, VERSION_START, true, context);
       size = datIn.readInt();
     }
 
Index: lucene/src/java/org/apache/lucene/index/values/Writer.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/Writer.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/Writer.java	(working copy)
@@ -20,6 +20,7 @@
 import java.util.Comparator;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.codecs.DocValuesConsumer;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.Bits;
@@ -192,35 +193,35 @@
    * @throws IOException
    */
   public static Writer create(ValueType type, String id, Directory directory,
-      Comparator<BytesRef> comp, AtomicLong bytesUsed) throws IOException {
+      Comparator<BytesRef> comp, AtomicLong bytesUsed, IOContext context) throws IOException {
     if (comp == null) {
       comp = BytesRef.getUTF8SortedAsUnicodeComparator();
     }
     switch (type) {
     case INTS:
-      return Ints.getWriter(directory, id, true, bytesUsed);
+      return Ints.getWriter(directory, id, true, bytesUsed, context);
     case FLOAT_32:
-      return Floats.getWriter(directory, id, 4, bytesUsed);
+      return Floats.getWriter(directory, id, 4, bytesUsed, context);
     case FLOAT_64:
-      return Floats.getWriter(directory, id, 8, bytesUsed);
+      return Floats.getWriter(directory, id, 8, bytesUsed, context);
     case BYTES_FIXED_STRAIGHT:
       return Bytes.getWriter(directory, id, Bytes.Mode.STRAIGHT, comp, true,
-          bytesUsed);
+          bytesUsed, context);
     case BYTES_FIXED_DEREF:
       return Bytes.getWriter(directory, id, Bytes.Mode.DEREF, comp, true,
-          bytesUsed);
+          bytesUsed, context);
     case BYTES_FIXED_SORTED:
       return Bytes.getWriter(directory, id, Bytes.Mode.SORTED, comp, true,
-          bytesUsed);
+          bytesUsed, context);
     case BYTES_VAR_STRAIGHT:
       return Bytes.getWriter(directory, id, Bytes.Mode.STRAIGHT, comp, false,
-          bytesUsed);
+          bytesUsed, context);
     case BYTES_VAR_DEREF:
       return Bytes.getWriter(directory, id, Bytes.Mode.DEREF, comp, false,
-          bytesUsed);
+          bytesUsed, context);
     case BYTES_VAR_SORTED:
       return Bytes.getWriter(directory, id, Bytes.Mode.SORTED, comp, false,
-          bytesUsed);
+          bytesUsed, context);
     default:
       throw new IllegalArgumentException("Unknown Values: " + type);
     }
Index: lucene/src/java/org/apache/lucene/index/values/Ints.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/Ints.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/Ints.java	(working copy)
@@ -35,14 +35,13 @@
   }
 
   public static Writer getWriter(Directory dir, String id,
-      boolean useFixedArray, AtomicLong bytesUsed) throws IOException {
+      boolean useFixedArray, AtomicLong bytesUsed, IOContext context) throws IOException {
     // TODO - implement fixed?!
-    return new IntsWriter(dir, id, bytesUsed, IOContext.DEFAULT);
+    return new IntsWriter(dir, id, bytesUsed, context);
   }
 
   public static IndexDocValues getValues(Directory dir, String id,
-      boolean useFixedArray) throws IOException {
-    //nocommit this needs an IOContext too
-    return new IntsReader(dir, id, IOContext.DEFAULT);
+      boolean useFixedArray, IOContext context) throws IOException {
+    return new IntsReader(dir, id, context);
   }
 }
Index: lucene/src/java/org/apache/lucene/index/values/Bytes.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/Bytes.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/Bytes.java	(working copy)
@@ -107,7 +107,7 @@
    *           if the files for the writer can not be created.
    */
   public static Writer getWriter(Directory dir, String id, Mode mode,
-      Comparator<BytesRef> comp, boolean fixedSize, AtomicLong bytesUsed)
+      Comparator<BytesRef> comp, boolean fixedSize, AtomicLong bytesUsed, IOContext context)
       throws IOException {
     //nocommit this and all the blow need an IOContext too
 
@@ -119,19 +119,19 @@
 
     if (fixedSize) {
       if (mode == Mode.STRAIGHT) {
-        return new FixedStraightBytesImpl.Writer(dir, id);
+        return new FixedStraightBytesImpl.Writer(dir, id, context);
       } else if (mode == Mode.DEREF) {
-        return new FixedDerefBytesImpl.Writer(dir, id, bytesUsed);
+        return new FixedDerefBytesImpl.Writer(dir, id, bytesUsed, context);
       } else if (mode == Mode.SORTED) {
-        return new FixedSortedBytesImpl.Writer(dir, id, comp, bytesUsed);
+        return new FixedSortedBytesImpl.Writer(dir, id, comp, bytesUsed, context);
       }
     } else {
       if (mode == Mode.STRAIGHT) {
-        return new VarStraightBytesImpl.Writer(dir, id, bytesUsed);
+        return new VarStraightBytesImpl.Writer(dir, id, bytesUsed, context);
       } else if (mode == Mode.DEREF) {
-        return new VarDerefBytesImpl.Writer(dir, id, bytesUsed);
+        return new VarDerefBytesImpl.Writer(dir, id, bytesUsed, context);
       } else if (mode == Mode.SORTED) {
-        return new VarSortedBytesImpl.Writer(dir, id, comp, bytesUsed);
+        return new VarSortedBytesImpl.Writer(dir, id, comp, bytesUsed, context);
       }
     }
 
@@ -160,25 +160,25 @@
    *           if an {@link IOException} occurs
    */
   public static IndexDocValues getValues(Directory dir, String id, Mode mode,
-      boolean fixedSize, int maxDoc) throws IOException {
+      boolean fixedSize, int maxDoc, IOContext context) throws IOException {
     //nocommit this and all the readers below need an IOContext too
 
     // TODO -- I can peek @ header to determing fixed/mode?
     if (fixedSize) {
       if (mode == Mode.STRAIGHT) {
-        return new FixedStraightBytesImpl.Reader(dir, id, maxDoc);
+        return new FixedStraightBytesImpl.Reader(dir, id, maxDoc, context);
       } else if (mode == Mode.DEREF) {
-        return new FixedDerefBytesImpl.Reader(dir, id, maxDoc);
+        return new FixedDerefBytesImpl.Reader(dir, id, maxDoc, context);
       } else if (mode == Mode.SORTED) {
-        return new FixedSortedBytesImpl.Reader(dir, id, maxDoc);
+        return new FixedSortedBytesImpl.Reader(dir, id, maxDoc, context);
       }
     } else {
       if (mode == Mode.STRAIGHT) {
-        return new VarStraightBytesImpl.Reader(dir, id, maxDoc);
+        return new VarStraightBytesImpl.Reader(dir, id, maxDoc, context);
       } else if (mode == Mode.DEREF) {
-        return new VarDerefBytesImpl.Reader(dir, id, maxDoc);
+        return new VarDerefBytesImpl.Reader(dir, id, maxDoc, context);
       } else if (mode == Mode.SORTED) {
-        return new VarSortedBytesImpl.Reader(dir, id, maxDoc);
+        return new VarSortedBytesImpl.Reader(dir, id, maxDoc, context);
       }
     }
 
Index: lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java	(working copy)
@@ -50,16 +50,16 @@
     private int lastDocID = -1;
     private long[] docToAddress;
 
-    public Writer(Directory dir, String id, AtomicLong bytesUsed)
+    public Writer(Directory dir, String id, AtomicLong bytesUsed, IOContext context)
         throws IOException {
       //nocommit this needs an IOContext too
-      super(dir, id, CODEC_NAME, VERSION_CURRENT, true, null, bytesUsed, IOContext.DEFAULT);
+      super(dir, id, CODEC_NAME, VERSION_CURRENT, true, null, bytesUsed, context);
       docToAddress = new long[1];
       bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_INT);
     }
 
-    public Writer(Directory dir, String id) throws IOException {
-      this(dir, id, new AtomicLong());
+    public Writer(Directory dir, String id, IOContext context) throws IOException {
+      this(dir, id, new AtomicLong(), context);
     }
 
     // Fills up to but not including this docID
@@ -123,8 +123,8 @@
   public static class Reader extends BytesReaderBase {
     private final int maxDoc;
 
-    Reader(Directory dir, String id, int maxDoc) throws IOException {
-      super(dir, id, CODEC_NAME, VERSION_START, true, IOContext.DEFAULT);
+    Reader(Directory dir, String id, int maxDoc, IOContext context) throws IOException {
+      super(dir, id, CODEC_NAME, VERSION_START, true, context);
       this.maxDoc = maxDoc;
     }
 
Index: lucene/src/java/org/apache/lucene/index/values/VarDerefBytesImpl.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/VarDerefBytesImpl.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/VarDerefBytesImpl.java	(working copy)
@@ -116,17 +116,16 @@
         bytesUsed);
     private final BytesRefHash hash = new BytesRefHash(pool, 16, array);
 
-    public Writer(Directory dir, String id, AtomicLong bytesUsed)
+    public Writer(Directory dir, String id, AtomicLong bytesUsed, IOContext context)
         throws IOException {
-      //nocommit this needs an IOContext too
       this(dir, id, new DirectTrackingAllocator(ByteBlockPool.BYTE_BLOCK_SIZE, bytesUsed),
-          bytesUsed);
+          bytesUsed, context);
     }
 
     public Writer(Directory dir, String id, Allocator allocator,
-        AtomicLong bytesUsed) throws IOException {
+        AtomicLong bytesUsed, IOContext context) throws IOException {
       super(dir, id, CODEC_NAME, VERSION_CURRENT, true,
-          new ByteBlockPool(allocator), bytesUsed, IOContext.DEFAULT);
+          new ByteBlockPool(allocator), bytesUsed, context);
       docToAddress = new int[1];
       bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_INT);
     }
@@ -203,8 +202,8 @@
 
   public static class Reader extends BytesReaderBase {
 
-    Reader(Directory dir, String id, int maxDoc) throws IOException {
-      super(dir, id, CODEC_NAME, VERSION_START, true, IOContext.DEFAULT);
+    Reader(Directory dir, String id, int maxDoc, IOContext context) throws IOException {
+      super(dir, id, CODEC_NAME, VERSION_START, true, context);
     }
 
     @Override
Index: lucene/src/java/org/apache/lucene/index/values/Floats.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/Floats.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/Floats.java	(working copy)
@@ -53,22 +53,21 @@
 
   
   public static Writer getWriter(Directory dir, String id, int precisionBytes,
-      AtomicLong bytesUsed) throws IOException {
+      AtomicLong bytesUsed, IOContext context) throws IOException {
     if (precisionBytes != 4 && precisionBytes != 8) {
       throw new IllegalArgumentException("precisionBytes must be 4 or 8; got "
           + precisionBytes);
     }
     if (precisionBytes == 4) {
-      return new Float4Writer(dir, id, bytesUsed);
+      return new Float4Writer(dir, id, bytesUsed, context);
     } else {
-      return new Float8Writer(dir, id, bytesUsed);
+      return new Float8Writer(dir, id, bytesUsed, context);
     }
   }
 
-  public static IndexDocValues getValues(Directory dir, String id, int maxDoc)
+  public static IndexDocValues getValues(Directory dir, String id, int maxDoc, IOContext context)
       throws IOException {
-    //nocommit this needs an IOContext too
-    return new FloatsReader(dir, id, maxDoc, IOContext.READ);
+    return new FloatsReader(dir, id, maxDoc, context);
   }
 
   abstract static class FloatsWriter extends Writer {
@@ -147,9 +146,9 @@
   // Writes 4 bytes (float) per value
   static class Float4Writer extends FloatsWriter {
 
-    protected Float4Writer(Directory dir, String id, AtomicLong bytesUsed)
+    protected Float4Writer(Directory dir, String id, AtomicLong bytesUsed, IOContext context)
         throws IOException {
-      super(dir, id, 4, bytesUsed, new IOContext(Context.FLUSH));
+      super(dir, id, 4, bytesUsed, context);
     }
 
     @Override
@@ -190,9 +189,9 @@
   // Writes 8 bytes (double) per value
   static class Float8Writer extends FloatsWriter {
 
-    protected Float8Writer(Directory dir, String id, AtomicLong bytesUsed)
+    protected Float8Writer(Directory dir, String id, AtomicLong bytesUsed, IOContext context)
         throws IOException {
-      super(dir, id, 8, bytesUsed, new IOContext(Context.FLUSH));
+      super(dir, id, 8, bytesUsed, context);
     }
 
     @Override
Index: lucene/src/java/org/apache/lucene/index/values/FixedStraightBytesImpl.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/FixedStraightBytesImpl.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/FixedStraightBytesImpl.java	(working copy)
@@ -47,9 +47,9 @@
     private int lastDocID = -1;
     private byte[] oneRecord;
 
-    public Writer(Directory dir, String id) throws IOException {
+    public Writer(Directory dir, String id, IOContext context) throws IOException {
       //nocommit this needs an IOContext too
-      super(dir, id, CODEC_NAME, VERSION_CURRENT, false, null, null, IOContext.DEFAULT);
+      super(dir, id, CODEC_NAME, VERSION_CURRENT, false, null, null, context);
     }
 
 
@@ -127,8 +127,8 @@
     private final int size;
     private final int maxDoc;
 
-    Reader(Directory dir, String id, int maxDoc) throws IOException {
-      super(dir, id, CODEC_NAME, VERSION_START, false, IOContext.DEFAULT);
+    Reader(Directory dir, String id, int maxDoc, IOContext context) throws IOException {
+      super(dir, id, CODEC_NAME, VERSION_START, false, context);
       size = datIn.readInt();
       this.maxDoc = maxDoc;
     }
Index: lucene/src/java/org/apache/lucene/index/values/FixedDerefBytesImpl.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/values/FixedDerefBytesImpl.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/values/FixedDerefBytesImpl.java	(working copy)
@@ -55,17 +55,16 @@
     private final BytesRefHash hash = new BytesRefHash(pool,
         BytesRefHash.DEFAULT_CAPACITY, new TrackingDirectBytesStartArray(
             BytesRefHash.DEFAULT_CAPACITY, bytesUsed));
-    public Writer(Directory dir, String id, AtomicLong bytesUsed)
+    public Writer(Directory dir, String id, AtomicLong bytesUsed, IOContext context)
         throws IOException {
-      //nocommit this needs an IOContext too
       this(dir, id, new DirectTrackingAllocator(ByteBlockPool.BYTE_BLOCK_SIZE, bytesUsed),
-          bytesUsed);
+          bytesUsed, context);
     }
 
     public Writer(Directory dir, String id, Allocator allocator,
-        AtomicLong bytesUsed) throws IOException {
+        AtomicLong bytesUsed, IOContext context) throws IOException {
       super(dir, id, CODEC_NAME, VERSION_CURRENT, true,
-          new ByteBlockPool(allocator), bytesUsed, IOContext.DEFAULT);
+          new ByteBlockPool(allocator), bytesUsed, context);
       docToID = new int[1];
       bytesUsed.addAndGet(RamUsageEstimator.NUM_BYTES_INT); // TODO BytesRefHash
                                                             // uses bytes too!
@@ -135,8 +134,8 @@
   public static class Reader extends BytesReaderBase {
     private final int size;
 
-    Reader(Directory dir, String id, int maxDoc) throws IOException {
-      super(dir, id, CODEC_NAME, VERSION_START, true, IOContext.DEFAULT);
+    Reader(Directory dir, String id, int maxDoc, IOContext context) throws IOException {
+      super(dir, id, CODEC_NAME, VERSION_START, true, context);
       size = datIn.readInt();
     }
 
Index: lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java	(working copy)
@@ -27,6 +27,7 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.index.IndexReader.AtomicReaderContext;
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
@@ -225,7 +226,7 @@
         // Lock order: IW -> BD -> RP
         assert readerPool.infoIsLive(info);
         //nocommit is IOContext.DEFAULT the right thing to do here?
-        final SegmentReader reader = readerPool.get(info, false, IOContext.DEFAULT);
+        final SegmentReader reader = readerPool.get(info, false, new IOContext(Context.READ));
         int delCount = 0;
         final boolean segAllDeletes;
         try {
Index: lucene/src/java/org/apache/lucene/index/SegmentMerger.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/SegmentMerger.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/SegmentMerger.java	(working copy)
@@ -234,8 +234,8 @@
 
     setMatchingSegmentReaders();
     // nocommit - should we rather use IOContext.MERGE here?
-    final FieldsWriter fieldsWriter = new FieldsWriter(directory, segment, IOContext.DEFAULT);
-
+    IOContext context = new IOContext(new MergeInfo(MAX_RAW_MERGE_DOCS, 1024, true, false));
+    final FieldsWriter fieldsWriter = new FieldsWriter(directory, segment, context);
     try {
       int idx = 0;
       for (IndexReader reader : readers) {
@@ -270,7 +270,7 @@
       // details.
       throw new RuntimeException("mergeFields produced an invalid result: docCount is " + docCount + " but fdx file size is " + fdxFileLength + " file=" + fileName + " file exists?=" + directory.fileExists(fileName) + "; now aborting this merge to prevent index corruption");
     //nocommit if Merge then what to initialize OneMerge with ?
-    segmentWriteState = new SegmentWriteState(null, directory, segment, fieldInfos, docCount, termIndexInterval, codecInfo, null, IOContext.DEFAULT);
+    segmentWriteState = new SegmentWriteState(null, directory, segment, fieldInfos, docCount, termIndexInterval, codecInfo, null, new IOContext(new MergeInfo(docCount, 1024, true, false)));
 
     return docCount;
   }
Index: lucene/src/java/org/apache/lucene/index/IndexWriter.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/IndexWriter.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/IndexWriter.java	(working copy)
@@ -41,7 +41,6 @@
 import org.apache.lucene.index.FieldInfos.FieldNumberBiMap;
 import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.index.MergePolicy.OneMerge;
 import org.apache.lucene.index.PayloadProcessorProvider.DirPayloadProcessor;
 import org.apache.lucene.index.SegmentCodecs.SegmentCodecsBuilder;
 import org.apache.lucene.index.codecs.CodecProvider;
Index: lucene/src/java/org/apache/lucene/index/MergeInfo.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/MergeInfo.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/MergeInfo.java	(working copy)
@@ -15,7 +15,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-//nocommit javadoc
+
+/**
+ * <p>A MergeInfo provides information required for a merge and optimization operations.
+ *  It is used as part of a <code>IOContext</code> in case of merges.</p>
+ */
+
 public class MergeInfo {
   
   public int totalDocCount;
@@ -25,7 +30,18 @@
   boolean isExternal;               // used by IndexWriter
   
   boolean optimize;                 // used by IndexWriter
+  
 
+  /**
+   * <p>Creates a new <code>MergeInfo</code> instance from
+   * the values required for a merge <code>IOContext</code> context.
+   * 
+   * @param int totalDocCount
+   * @param long estimatedMergeBytes
+   * @param boolean isExternal
+   * @param boolean optimize
+   */
+
   public MergeInfo(int totalDocCount, long estimatedMergeBytes, boolean isExternal, boolean optimize) {
     this.totalDocCount = totalDocCount;
     this.estimatedMergeBytes = estimatedMergeBytes;
Index: lucene/src/java/org/apache/lucene/index/codecs/pulsing/PulsingCodec.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/pulsing/PulsingCodec.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/pulsing/PulsingCodec.java	(working copy)
@@ -173,6 +173,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
   }
 }
Index: lucene/src/java/org/apache/lucene/index/codecs/DefaultSegmentInfosWriter.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/DefaultSegmentInfosWriter.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/DefaultSegmentInfosWriter.java	(working copy)
@@ -59,7 +59,7 @@
   public IndexOutput writeInfos(Directory dir, String segmentFileName, SegmentInfos infos, IOContext context)
           throws IOException {
     //nocommit should this context always be flush?
-    IndexOutput out = createOutput(dir, segmentFileName, context);
+    IndexOutput out = createOutput(dir, segmentFileName, new IOContext(Context.FLUSH));
     boolean success = false;
     try {
       out.writeInt(FORMAT_CURRENT); // write FORMAT
Index: lucene/src/java/org/apache/lucene/index/codecs/DefaultDocValuesConsumer.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/DefaultDocValuesConsumer.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/DefaultDocValuesConsumer.java	(working copy)
@@ -24,6 +24,7 @@
 
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.PerDocWriteState;
 import org.apache.lucene.index.SegmentInfo;
@@ -55,7 +56,7 @@
         docValuesId(segmentName, codecId, field.number),
         // TODO can we have a compound file per segment and codec for
         // docvalues?
-        directory, comparator, bytesUsed);
+        directory, comparator, bytesUsed, IOContext.DEFAULT);
   }
   
   @SuppressWarnings("fallthrough")
Index: lucene/src/java/org/apache/lucene/index/codecs/simpletext/SimpleTextCodec.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/simpletext/SimpleTextCodec.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/simpletext/SimpleTextCodec.java	(working copy)
@@ -86,6 +86,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
   }
 }
Index: lucene/src/java/org/apache/lucene/index/codecs/standard/StandardCodec.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/standard/StandardCodec.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/standard/StandardCodec.java	(working copy)
@@ -163,6 +163,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
   }
 }
Index: lucene/src/java/org/apache/lucene/index/codecs/memory/MemoryCodec.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/memory/MemoryCodec.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/memory/MemoryCodec.java	(working copy)
@@ -29,6 +29,7 @@
 import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.FieldInfos;
 import org.apache.lucene.index.FieldsEnum;
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.PerDocWriteState;
 import org.apache.lucene.index.SegmentInfo;
@@ -699,7 +700,7 @@
   public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException {
     //nocommit its seems due to the nature of this codec that we should use IOContext.READONCE here where applicable. 
     final String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.codecId, EXTENSION);
-    final IndexInput in = state.dir.openInput(fileName, state.context);
+    final IndexInput in = state.dir.openInput(fileName, IOContext.READONCE);
 
     final SortedMap<String,TermsReader> fields = new TreeMap<String,TermsReader>();
 
@@ -776,6 +777,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, IOContext.READONCE);
   }
 }
Index: lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java	(working copy)
@@ -118,16 +118,16 @@
       this.skipInterval = skipInterval;
       this.skipMinimum = skipInterval; /* set to the same for now */
       final String docFileName = IndexFileNames.segmentFileName(state.segmentName, state.codecId, DOC_EXTENSION);
-      docOut = factory.createOutput(state.directory, docFileName);
+      docOut = factory.createOutput(state.directory, docFileName, state.context);
       docIndex = docOut.index();
       
       if (state.fieldInfos.hasProx()) {
         final String frqFileName = IndexFileNames.segmentFileName(state.segmentName, state.codecId, FREQ_EXTENSION);
-        freqOut = factory.createOutput(state.directory, frqFileName);
+        freqOut = factory.createOutput(state.directory, frqFileName, state.context);
         freqIndex = freqOut.index();
         
         final String posFileName = IndexFileNames.segmentFileName(state.segmentName, state.codecId, POS_EXTENSION);
-        posOut = factory.createOutput(state.directory, posFileName);
+        posOut = factory.createOutput(state.directory, posFileName, state.context);
         posIndex = posOut.index();
         
         // TODO: -- only if at least one field stores payloads?
Index: lucene/src/java/org/apache/lucene/index/codecs/sep/IntStreamFactory.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/sep/IntStreamFactory.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/sep/IntStreamFactory.java	(working copy)
@@ -19,7 +19,6 @@
 
 import org.apache.lucene.index.IOContext;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.BufferedIndexInput;
 
 import java.io.IOException;
 
@@ -30,5 +29,5 @@
   }
 
 //  public abstract IntIndexInput openInput(Directory dir, String fileName, IOContext context) throws IOException;
-  public abstract IntIndexOutput createOutput(Directory dir, String fileName) throws IOException;
+  public abstract IntIndexOutput createOutput(Directory dir, String fileName, IOContext context) throws IOException;
 }
Index: lucene/src/java/org/apache/lucene/index/codecs/DefaultSegmentInfosReader.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/DefaultSegmentInfosReader.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/DefaultSegmentInfosReader.java	(working copy)
@@ -28,7 +28,6 @@
 import org.apache.lucene.index.IndexFormatTooNewException;
 import org.apache.lucene.index.SegmentInfo;
 import org.apache.lucene.index.SegmentInfos;
-import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.store.ChecksumIndexInput;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
Index: lucene/src/java/org/apache/lucene/index/codecs/DefaultDocValuesProducer.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/codecs/DefaultDocValuesProducer.java	(revision 1138188)
+++ lucene/src/java/org/apache/lucene/index/codecs/DefaultDocValuesProducer.java	(working copy)
@@ -57,9 +57,9 @@
    *           if an {@link IOException} occurs
    */
   public DefaultDocValuesProducer(SegmentInfo si, Directory dir,
-      FieldInfos fieldInfo, int codecId) throws IOException {
+      FieldInfos fieldInfo, int codecId, IOContext context) throws IOException {
     //nocommit this needs an IOContext
-    docValues = load(fieldInfo, si.name, si.docCount, dir, codecId);
+    docValues = load(fieldInfo, si.name, si.docCount, dir, codecId, context);
   }
 
   /**
@@ -73,7 +73,7 @@
 
   // Only opens files... doesn't actually load any values
   protected TreeMap<String, IndexDocValues> load(FieldInfos fieldInfos,
-      String segment, int docCount, Directory dir, int codecId)
+      String segment, int docCount, Directory dir, int codecId, IOContext context)
       throws IOException {
     TreeMap<String, IndexDocValues> values = new TreeMap<String, IndexDocValues>();
     boolean success = false;
@@ -87,7 +87,7 @@
           final String id = DefaultDocValuesConsumer.docValuesId(segment,
               codecId, fieldInfo.number);
           values.put(field,
-              loadDocValues(docCount, dir, id, fieldInfo.getDocValues()));
+              loadDocValues(docCount, dir, id, fieldInfo.getDocValues(), context));
         }
       }
       success = true;
@@ -121,27 +121,27 @@
    *           if the given {@link ValueType} is not supported
    */
   protected IndexDocValues loadDocValues(int docCount, Directory dir, String id,
-      ValueType type) throws IOException {
+      ValueType type, IOContext context) throws IOException {
     // nocommit this needs an IOContext too
     switch (type) {
     case INTS:
-      return Ints.getValues(dir, id, false);
+      return Ints.getValues(dir, id, false, context);
     case FLOAT_32:
-      return Floats.getValues(dir, id, docCount);
+      return Floats.getValues(dir, id, docCount, context);
     case FLOAT_64:
-      return Floats.getValues(dir, id, docCount);
+      return Floats.getValues(dir, id, docCount, context);
     case BYTES_FIXED_STRAIGHT:
-      return Bytes.getValues(dir, id, Bytes.Mode.STRAIGHT, true, docCount);
+      return Bytes.getValues(dir, id, Bytes.Mode.STRAIGHT, true, docCount, context);
     case BYTES_FIXED_DEREF:
-      return Bytes.getValues(dir, id, Bytes.Mode.DEREF, true, docCount);
+      return Bytes.getValues(dir, id, Bytes.Mode.DEREF, true, docCount, context);
     case BYTES_FIXED_SORTED:
-      return Bytes.getValues(dir, id, Bytes.Mode.SORTED, true, docCount);
+      return Bytes.getValues(dir, id, Bytes.Mode.SORTED, true, docCount, context);
     case BYTES_VAR_STRAIGHT:
-      return Bytes.getValues(dir, id, Bytes.Mode.STRAIGHT, false, docCount);
+      return Bytes.getValues(dir, id, Bytes.Mode.STRAIGHT, false, docCount, context);
     case BYTES_VAR_DEREF:
-      return Bytes.getValues(dir, id, Bytes.Mode.DEREF, false, docCount);
+      return Bytes.getValues(dir, id, Bytes.Mode.DEREF, false, docCount, context);
     case BYTES_VAR_SORTED:
-      return Bytes.getValues(dir, id, Bytes.Mode.SORTED, false, docCount);
+      return Bytes.getValues(dir, id, Bytes.Mode.SORTED, false, docCount, context);
     default:
       throw new IllegalStateException("unrecognized index values mode " + type);
     }
Index: lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockVariableIntBlockCodec.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockVariableIntBlockCodec.java	(revision 1138188)
+++ lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockVariableIntBlockCodec.java	(working copy)
@@ -107,8 +107,8 @@
     }
 
     @Override
-    public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException {
-      final IndexOutput out = dir.createOutput(fileName, IOContext.DEFAULT);
+    public IntIndexOutput createOutput(Directory dir, String fileName, IOContext context) throws IOException {
+      final IndexOutput out = dir.createOutput(fileName, context);
       boolean success = false;
       try {
         out.writeInt(baseBlockSize);
@@ -248,6 +248,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
   }
 }
Index: lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java	(revision 1138188)
+++ lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java	(working copy)
@@ -103,8 +103,8 @@
     }
 
     @Override
-    public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException {
-      IndexOutput out = dir.createOutput(fileName, IOContext.DEFAULT);
+    public IntIndexOutput createOutput(Directory dir, String fileName, IOContext context) throws IOException {
+      IndexOutput out = dir.createOutput(fileName, context);
       boolean success = false;
       try {
         FixedIntBlockIndexOutput ret = new FixedIntBlockIndexOutput(out, blockSize) {
@@ -226,6 +226,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
   }
 }
Index: lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java	(revision 1138188)
+++ lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java	(working copy)
@@ -161,6 +161,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
   }
 }
Index: lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java	(revision 1138188)
+++ lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java	(working copy)
@@ -36,9 +36,9 @@
   final static int VERSION_START = 0;
   final static int VERSION_CURRENT = VERSION_START;
 
-  public MockSingleIntIndexOutput(Directory dir, String fileName) throws IOException {
+  public MockSingleIntIndexOutput(Directory dir, String fileName, IOContext context) throws IOException {
     //nocommit pass IOContext in via ctor!
-    out = dir.createOutput(fileName, IOContext.DEFAULT);
+    out = dir.createOutput(fileName, context);
     boolean success = false;
     try {
       CodecUtil.writeHeader(out, CODEC, VERSION_CURRENT);
Index: lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java	(revision 1138188)
+++ lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java	(working copy)
@@ -32,7 +32,7 @@
     return new MockSingleIntIndexInput(dir, fileName, context);
   }
   @Override
-  public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException {
-    return new MockSingleIntIndexOutput(dir, fileName);
+  public IntIndexOutput createOutput(Directory dir, String fileName, IOContext context) throws IOException {
+    return new MockSingleIntIndexOutput(dir, fileName, context);
   }
 }
Index: lucene/src/test-framework/org/apache/lucene/index/codecs/mockrandom/MockRandomCodec.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/index/codecs/mockrandom/MockRandomCodec.java	(revision 1138188)
+++ lucene/src/test-framework/org/apache/lucene/index/codecs/mockrandom/MockRandomCodec.java	(working copy)
@@ -115,12 +115,12 @@
     }
 
     @Override
-    public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException {
+    public IntIndexOutput createOutput(Directory dir, String fileName, IOContext context) throws IOException {
       final IntStreamFactory f = delegates.get((Math.abs(salt ^ getExtension(fileName).hashCode())) % delegates.size());
       if (LuceneTestCase.VERBOSE) {
         System.out.println("MockRandomCodec: write using int factory " + f + " to fileName=" + fileName);
       }
-      return f.createOutput(dir, fileName);
+      return f.createOutput(dir, fileName, context);
     }
   }
 
@@ -386,6 +386,6 @@
 
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
-    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+    return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId, state.context);
   }
 }
Index: lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java
===================================================================
--- lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java	(revision 1138188)
+++ lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java	(working copy)
@@ -33,6 +33,7 @@
 
 import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.MergeInfo;
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.ThrottledIndexOutput;
@@ -198,7 +199,8 @@
         byte[] zeroes = new byte[256];
         long upto = 0;
         //nocommit - randomize the IOContext here?
-        IndexOutput out = delegate.createOutput(name, IOContext.DEFAULT);
+        int contextSelect = randomState.nextInt(1);
+        IndexOutput out = delegate.createOutput(name, contextSelect > 0 ? IOContext.DEFAULT : IOContext.READONCE);
         while(upto < length) {
           final int limit = (int) Math.min(length-upto, zeroes.length);
           out.writeBytes(zeroes, 0, limit);
@@ -208,7 +210,7 @@
       } else if (count % 3 == 2) {
         // Truncate the file:
         //nocommit - randomize the IOContext here?
-        IndexOutput out = delegate.createOutput(name, IOContext.DEFAULT);
+        IndexOutput out = delegate.createOutput(name, new IOContext(new MergeInfo(4192,1024,true,false)));
         out.setLength(fileLength(name)/2);
         out.close();
       }
