struct buf *lmfs_next; /* used to link all free bufs in a chain */
struct buf *lmfs_prev; /* used to link all free bufs the other way */
struct buf *lmfs_hash; /* used to link bufs on hash chains */
- block_t lmfs_blocknr; /* block number of its (minor) device */
dev_t lmfs_dev; /* major | minor device where block resides */
+ block64_t lmfs_blocknr; /* block number of its (minor) device */
char lmfs_count; /* number of users of this buffer */
char lmfs_needsetcache; /* to be identified to VM */
unsigned int lmfs_bytes; /* Number of bytes allocated in bp */
void lmfs_reset_rdwt_err(void);
int lmfs_rdwt_err(void);
void lmfs_buf_pool(int new_nr_bufs);
-struct buf *lmfs_get_block(dev_t dev, block_t block,int only_search);
-struct buf *lmfs_get_block_ino(dev_t dev, block_t block,int only_search,
+struct buf *lmfs_get_block(dev_t dev, block64_t block,int only_search);
+struct buf *lmfs_get_block_ino(dev_t dev, block64_t block,int only_search,
ino_t ino, u64_t off);
void lmfs_invalidate(dev_t device);
void lmfs_put_block(struct buf *bp, int block_type);
* TODO: limit according to the number of available buffers.
*/
static void
-block_prefetch(dev_t dev, block_t block, block_t nblocks)
+block_prefetch(dev_t dev, block64_t block, unsigned int nblocks)
{
struct buf *bp, *bufs[NR_IOREQS];
unsigned int count;
lmfs_bio(dev_t dev, struct fsdriver_data * data, size_t bytes, off_t pos,
int call)
{
- block_t block, blocks_left;
+ block64_t block;
size_t block_size, off, block_off, chunk;
+ unsigned int blocks_left;
struct buf *bp;
int r, write, how;
assert(block_size > 0);
- /* FIXME: block_t is 32-bit, so we have to impose a limit here. */
- if (pos < 0 || pos / block_size > UINT32_MAX || bytes > SSIZE_MAX)
+ if (bytes == 0)
+ return 0; /* just in case */
+
+ if (pos < 0 || bytes > SSIZE_MAX || pos > INT64_MAX - bytes + 1)
return EINVAL;
off = 0;
#include <minix/u64.h>
#include <minix/bdev.h>
-#define BUFHASH(b) ((b) % nr_bufs)
+#define BUFHASH(b) ((unsigned int)((b) % nr_bufs))
#define MARKCLEAN lmfs_markclean
#define MINBUFS 6 /* minimal no of bufs for sanity check */
/*===========================================================================*
* lmfs_get_block *
*===========================================================================*/
-struct buf *lmfs_get_block(register dev_t dev, register block_t block,
- int only_search)
+struct buf *lmfs_get_block(dev_t dev, block64_t block, int only_search)
{
return lmfs_get_block_ino(dev, block, only_search, VMC_NO_INODE, 0);
}
/*===========================================================================*
* lmfs_get_block_ino *
*===========================================================================*/
-struct buf *lmfs_get_block_ino(dev_t dev, block_t block, int only_search,
+struct buf *lmfs_get_block_ino(dev_t dev, block64_t block, int only_search,
ino_t ino, u64_t ino_off)
{
/* Check to see if the requested block is in the block cache. If so, return
int b;
static struct buf *bp;
- u64_t dev_off = (u64_t) block * fs_block_size;
+ uint64_t dev_off;
struct buf *prev_ptr;
assert(buf_hash);
assert(dev != NO_DEV);
+ assert(block <= UINT64_MAX / fs_block_size);
+
+ dev_off = block * fs_block_size;
+
if((ino_off % fs_block_size)) {
printf("cache: unaligned lmfs_get_block_ino ino_off %llu\n",
* disk immediately if they are dirty.
*/
dev_t dev;
- off_t dev_off;
+ uint64_t dev_off;
int r;
if (bp == NULL) return; /* it is easier to check here than in caller */
dev = bp->lmfs_dev;
- dev_off = (off_t) bp->lmfs_blocknr * fs_block_size;
+ dev_off = bp->lmfs_blocknr * fs_block_size;
lowercount(bp);
if (bp->lmfs_count != 0) return; /* block is still in use */
BDEV_NOFLAGS);
}
if (r < 0) {
- printf("fs cache: I/O error on device %d/%d, block %u\n",
- major(dev), minor(dev), bp->lmfs_blocknr);
+ printf("fs cache: I/O error on device %d/%d, block %"PRIu64"\n",
+ major(dev), minor(dev), bp->lmfs_blocknr);
op_failed = 1;
} else if (r != (ssize_t) fs_block_size) {
r = END_OF_FILE;
int p;
vir_bytes vdata, blockrem;
bp = bufq[nblocks];
- if (bp->lmfs_blocknr != (block_t) bufq[0]->lmfs_blocknr + nblocks)
+ if (bp->lmfs_blocknr != bufq[0]->lmfs_blocknr + nblocks)
break;
if(niovecs >= NR_IOREQS-iov_per_block) break;
vdata = (vir_bytes) bp->data;
* may have done less than what we asked for.
*/
if (r < 0) {
- printf("fs cache: I/O error %d on device %d/%d, block %u\n",
- r, major(dev), minor(dev), bufq[0]->lmfs_blocknr);
+ printf("fs cache: I/O error %d on device %d/%d, "
+ "block %"PRIu64"\n",
+ r, major(dev), minor(dev), bufq[0]->lmfs_blocknr);
}
for (i = 0; i < nblocks; i++) {
bp = bufq[i];