 +  mt_samparse_end(linesplit->samparse);
 +}
 +
++typedef struct input_fps {
++  int n;
++  samFile *fp[];
++} input_fps_t;
++
++typedef struct input_files {
++  int n;
++  char *fn[];
++} input_files_t;
++
++typedef struct {
++  pthread_t tid;
++  struct mt_blkrd *mt;
++} blkrd_work_t;
++
++typedef struct mt_blkrd {
++  mt_linesplit_t *linesplit;
++  input_fps_t   *fps;
++  input_files_t *input_files;
++  blkrd_work_t *w;
++  void * orig_uncompressed_block;
++  size_t read_bytes;
++  blkrd_free_list2_t blkrd_free_list2;
++  //mt_drop_cache_t *drop_cache;
++  struct mt_progress *progress;
++  struct mt_drop_cache *drop_cache;
++
++  // profile
++  double time_open;
++  long   n_open;
++} mt_blkrd_t;
++
 +typedef struct mt_drop_cache {
++  mt_blkrd_t *blkrd;
 +  pthread_t tid;
 +  long count;
-+  int fd;
 +  volatile int done;
 +  struct timeval begin;
 +} mt_drop_cache_t;

+      }
+    }
+  }
+  struct timeval sort_start;
+  gettimeofday(&sort_start, NULL);
+  // sort the list of unmap_list_t nodes using block_seqid as the key

+static void *mt_drop_cache(void *data) {
+  mt_drop_cache_t * const mt = (mt_drop_cache_t*)data;
+  static off_t last = 0;
+  mt_blkrd_t * const blkrd = mt->blkrd;
+
+int i;
+for (i=0; i < blkrd->fps->n; i++) {
+//  BGZF * const bgzf = ((kstream_t*)fp->fp.voidp)->f;
+//  int const fd = ((hFILE_fd*)(bgzf->fp))->fd;
+  volatile samFile ** const p_fp = (volatile samFile **)(&blkrd->fps->fp[i]);
+  while(NULL == *p_fp) {
+    sleep(1);
+  }
+  samFile * const fp = (samFile *)*p_fp;
+  const int fd = ((hFILE_fd*)((kstream_t*)fp->fp.voidp)->f->fp)->fd;
+
+  struct stat st_buf;
+  st_buf.st_size = 0;
+  if (-1 == fstat(fd, &st_buf)) {
+    fprintf(stderr, "(W) DROP CACHE: fstat failed\n");
+    continue;
+  }
+  const size_t file_size = st_buf.st_size;
+  
+  last = 0;
+
+  while(1) {
+    off_t const curr = lseek(fd, 0, SEEK_CUR);
+    if (-1 == curr) {
+      fprintf(stderr, "(W) DROP CACHE: not drop the cache for %s skip since lseek SEEK_CUR failed\n", blkrd->input_files->fn[i]);
+      break;
+    } 
+    posix_fadvise(fd, last, curr - last, POSIX_FADV_DONTNEED);
+#if defined(VERBOSE_DROP_CACHE)
+    fprintf(stderr, "(I) DROP CACHE: drop region %ld - %ld of %s\n\n\n", last, curr, blkrd->input_files->fn[i]);
+#endif
+    if (file_size == curr) {
+#if defined(VERBOSE_DROP_CACHE)
+      fprintf(stderr, "(I) DROP CACHE: drop file cache done: %s\n\n\n", blkrd->input_files->fn[i]);
+#endif
+      break;
+    }
+    last = curr;
+
+    mt->count++;
