Skip to content

Commit

Permalink
[DE81] Do not free zio_cmd in uzfs_zvol_worker if zio_cmd is meant fo…
Browse files Browse the repository at this point in the history
…r rebuild. (#92)

Signed-off-by: satbir <[email protected]>
  • Loading branch information
satbirchhikara authored and vishnuitta committed Aug 10, 2018
1 parent 3be0407 commit 635c465
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/zrepl_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ typedef struct zvol_io_cmd_s {
zvol_io_hdr_t hdr;
void *zv;
void *buf;
uint64_t buf_len;
metadata_desc_t *metadata_desc;
int conn;
} zvol_io_cmd_t;
Expand Down
11 changes: 7 additions & 4 deletions lib/libzrepl/data_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ zio_cmd_alloc(zvol_io_hdr_t *hdr, int fd)
(hdr->opcode == ZVOL_OPCODE_WRITE) ||
(hdr->opcode == ZVOL_OPCODE_OPEN)) {
zio_cmd->buf = kmem_zalloc(sizeof (char) * hdr->len, KM_SLEEP);
zio_cmd->buf_len = hdr->len;
}

zio_cmd->conn = fd;
Expand All @@ -81,7 +82,7 @@ zio_cmd_free(zvol_io_cmd_t **cmd)
case ZVOL_OPCODE_WRITE:
case ZVOL_OPCODE_OPEN:
if (zio_cmd->buf != NULL) {
kmem_free(zio_cmd->buf, zio_cmd->hdr.len);
kmem_free(zio_cmd->buf, zio_cmd->buf_len);
}
break;

Expand Down Expand Up @@ -260,11 +261,13 @@ uzfs_zvol_worker(void *arg)
read_metadata = hdr->flags & ZVOL_OP_FLAG_READ_METADATA;

/*
* Why to delay offline activity ? anyway
* we are not going to ACK these IOs
* For rebuild case, do not free zio_cmd
*/
if (zinfo->state == ZVOL_INFO_STATE_OFFLINE) {
zio_cmd_free(&zio_cmd);
hdr->status = ZVOL_OP_STATUS_FAILED;
hdr->len = 0;
if (!(rebuild_cmd_req && (hdr->opcode == ZVOL_OPCODE_WRITE)))
zio_cmd_free(&zio_cmd);
goto drop_refcount;
}

Expand Down

0 comments on commit 635c465

Please sign in to comment.