static iovec_t iovec[NR_IOREQS];
u64_t pos;
int iov_per_block;
+ int start_in_use = bufs_in_use, start_bufqsize = bufqsize;
+
+ assert(bufqsize >= 0);
+ if(bufqsize == 0) return;
+
+ /* for READING, check all buffers on the list are obtained and held
+ * (count > 0)
+ */
+ if (rw_flag == READING) {
+ for(i = 0; i < bufqsize; i++) {
+ assert(bufq[i] != NULL);
+ assert(bufq[i]->lmfs_count > 0);
+ }
+
+ /* therefore they are all 'in use' and must be at least this many */
+ assert(start_in_use >= start_bufqsize);
+ }
assert(dev != NO_DEV);
assert(!(fs_block_size % PAGE_SIZE));
}
r -= fs_block_size;
}
- bufq += nblocks;
- bufqsize -= nblocks;
+
+ bufq += i;
+ bufqsize -= i;
+
if (rw_flag == READING) {
/* Don't bother reading more than the device is willing to
* give at this time. Don't forget to release those extras.
break;
}
}
+
+ if(rw_flag == READING) {
+ assert(start_in_use >= start_bufqsize);
+
+ /* READING callers assume all bufs are released. */
+ assert(start_in_use - start_bufqsize == bufs_in_use);
+ }
}
/*===========================================================================*
}
/* In all cases, bp now points to a valid buffer. */
- assert(bp);
+ assert(bp != NULL);
if (rw_flag == WRITING && chunk != block_size && !block_spec &&
(off_t) ex64lo(position) >= rip->i_size && off == 0) {
static unsigned int readqsize = 0;
static struct buf **read_q;
u64_t position_running;
+ int inuse_before = lmfs_bufs_in_use();
if(readqsize != nr_bufs) {
if(readqsize > 0) {
bp = lmfs_get_block_ino(dev, block, PREFETCH, rip->i_num, position);
assert(bp != NULL);
+ assert(bp->lmfs_count > 0);
if (lmfs_dev(bp) != NO_DEV) return(bp);
/* The best guess for the number of blocks to prefetch: A lot.
/* Acquire block buffers. */
for (;;) {
block_t thisblock;
+ assert(bp->lmfs_count > 0);
read_q[read_q_size++] = bp;
if (--blocks_ahead == 0) break;
} else {
bp = get_block(dev, block, PREFETCH);
}
+ assert(bp);
+ assert(bp->lmfs_count > 0);
if (lmfs_dev(bp) != NO_DEV) {
/* Oops, block already in the cache, get out. */
put_block(bp, FULL_DATA_BLOCK);
}
lmfs_rw_scattered(dev, read_q, read_q_size, READING);
+ assert(inuse_before == lmfs_bufs_in_use());
+
if(block_spec)
return get_block(dev, baseblock, NORMAL);
return(lmfs_get_block_ino(dev, baseblock, NORMAL, rip->i_num, position));