]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/fs-io-direct.c
Disable pristine-tar option in gbp.conf, since there is no pristine-tar branch.
[bcachefs-tools-debian] / libbcachefs / fs-io-direct.c
index fdd57c5785c9cebf609959fb753ee30e55e85b92..33cb6da3a5ad28f2c014c2ef12408937933d49c3 100644 (file)
@@ -77,6 +77,10 @@ static int bch2_direct_IO_read(struct kiocb *req, struct iov_iter *iter)
 
        bch2_inode_opts_get(&opts, c, &inode->ei_inode);
 
+       /* bios must be 512 byte aligned: */
+       if ((offset|iter->count) & (SECTOR_SIZE - 1))
+               return -EINVAL;
+
        ret = min_t(loff_t, iter->count,
                    max_t(loff_t, 0, i_size_read(&inode->v) - offset));
 
@@ -84,6 +88,8 @@ static int bch2_direct_IO_read(struct kiocb *req, struct iov_iter *iter)
                return ret;
 
        shorten = iov_iter_count(iter) - round_up(ret, block_bytes(c));
+       if (shorten >= iter->count)
+               shorten = 0;
        iter->count -= shorten;
 
        bio = bio_alloc_bioset(NULL,