Skip to content

Commit

Permalink
lwnbd: blockshift -> blocksize
Browse files Browse the repository at this point in the history
  • Loading branch information
bignaux committed Aug 30, 2021
1 parent e03af9b commit 53751dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions modules/network/lwnbdsvr/drivers/atad.c
Expand Up @@ -30,12 +30,12 @@ int atad_ctor(atad_driver *const me, int device)
// int ata_device_sce_identify_drive(int device, void *data);
strcpy(me->super.export_desc, "PlayStation 2 HDD via ATAD");
strcpy(me->super.export_name, "hdd0");
me->super.blockshift = 9;
me->super.blocksize = 512;
me->super.buffer = nbd_buffer;
me->super.eflags = NBD_FLAG_HAS_FLAGS;

if (dev_info != NULL && dev_info->exists) {
me->super.export_size = (uint64_t)dev_info->total_sectors << me->super.blockshift;
me->super.export_size = (uint64_t)dev_info->total_sectors * me->super.blocksize;
return 0;
}
return 1;
Expand Down
20 changes: 10 additions & 10 deletions modules/network/lwnbdsvr/lwNBD/nbd_protocol.c
Expand Up @@ -233,10 +233,10 @@ int transmission_phase(const int client_socket, const nbd_context *ctx)
else {
error = NBD_SUCCESS;
sendflag = MSG_MORE;
bufbklsz = NBD_BUFFER_LEN >> ctx->blockshift;
blkremains = request.count >> ctx->blockshift;
offset = request.offset >> ctx->blockshift;
byteread = bufbklsz << ctx->blockshift;
bufbklsz = NBD_BUFFER_LEN / ctx->blocksize;
blkremains = request.count / ctx->blocksize;
offset = request.offset / ctx->blocksize;
byteread = bufbklsz * ctx->blocksize;
}

reply.error = ntohl(error);
Expand All @@ -247,7 +247,7 @@ int transmission_phase(const int client_socket, const nbd_context *ctx)

if (blkremains < bufbklsz) {
bufbklsz = blkremains;
byteread = bufbklsz << ctx->blockshift;
byteread = bufbklsz * ctx->blocksize;
}

if (blkremains <= bufbklsz)
Expand Down Expand Up @@ -283,17 +283,17 @@ int transmission_phase(const int client_socket, const nbd_context *ctx)
else {
error = NBD_SUCCESS;
sendflag = MSG_MORE;
bufbklsz = NBD_BUFFER_LEN >> ctx->blockshift;
blkremains = request.count >> ctx->blockshift;
offset = request.offset >> ctx->blockshift;
byteread = bufbklsz << ctx->blockshift;
bufbklsz = NBD_BUFFER_LEN / ctx->blocksize;
blkremains = request.count / ctx->blocksize;
offset = request.offset / ctx->blocksize;
byteread = bufbklsz * ctx->blocksize;
}

while (sendflag) {

if (blkremains < bufbklsz) {
bufbklsz = blkremains;
byteread = bufbklsz << ctx->blockshift;
byteread = bufbklsz * ctx->blocksize;
}

if (blkremains <= bufbklsz)
Expand Down
2 changes: 1 addition & 1 deletion modules/network/lwnbdsvr/lwNBD/nbd_server.h
Expand Up @@ -124,7 +124,7 @@ typedef struct nbd_context
char export_name[32];
uint64_t export_size; /* size of export in byte */
uint16_t eflags; /* per-export flags */
uint8_t blockshift; /* in power of 2 for bit shifting - log2(blocksize) */
uint16_t blocksize; /* in power of 2 for bit shifting - log2(blocksize) */
uint8_t *buffer;

} nbd_context;
Expand Down

0 comments on commit 53751dd

Please sign in to comment.