static void __iob_enc_dec (
struct bio * iob,
sector_t lbn
)
{
struct bio_vec *bvl;
sector_t nlbn;
int i;
$TRACE("Start %scrypting ...", bio_data_dir(iob) == WRITE ? "En" : "De");
#if 0
{
for (i = 0, bvl = iob->bi_io_vec; i < iob->bi_vcnt; i++, bvl++)
{
$SHOW_PTR(bvl->bv_page);
$SHOW_INT(bvl->bv_len);
$SHOW_INT(bvl->bv_offset);
}
}
bio_for_each_segment(bvec, iob, iter)
{
char * iobuf;
iobuf = __bio_kmap_atomic(iob, iter);
$TRACE("#%02d: page=%p, off=%u, len=%u, iobuf=%p, lbn=%lu",
iter.bi_idx, bvec.bv_page, bvec.bv_offset, bvec.bv_len, iobuf, iter.bi_sector);
iobuf += bvec.bv_offset;
lbn = iter.bi_sector;
nlbn = iter.bi_size/DUDRV$K_BLKSZ;
for ( ;nlbn; nlbn--, lbn++ , iobuf += DUDRV$K_BLKSZ)
{
bio_data_dir(iob) == WRITE
? __encrypt (&gost89_ctx, lbn, iobuf, iobuf)
: __decrypt (&gost89_ctx, lbn, iobuf, iobuf);
}
__bio_kunmap_atomic(iob);
}
#endif
for (i = 0, bvl = iob->bi_io_vec; i < iob->bi_vcnt; i++, bvl++)
{
void *kaddr = kmap_atomic(bvl->bv_page), *iobuf;
iobuf = kaddr + bvl->bv_offset;
nlbn = bvl->bv_len/DUDRV$K_BLKSZ;
$TRACE("#%02d: page=%p, off=%u, len=%u, iobuf=%p, lbn=%lu, nlbn=%lu",
i, bvl->bv_page, bvl->bv_offset, bvl->bv_len, iobuf, lbn, nlbn);
for ( ;nlbn; nlbn--, lbn++ , iobuf += DUDRV$K_BLKSZ)
{
if ( bio_data_dir(iob) == WRITE )
__encrypt (&gost89_ctx, lbn, iobuf, iobuf);
else __decrypt (&gost89_ctx, lbn, iobuf, iobuf);
}
kunmap_atomic(kaddr);
}
}