Skip to content

Commit

Permalink
Merge pull request #20 from marcelhuberfoo/DiscardZeroesFix
Browse files Browse the repository at this point in the history
fixes discard_zeroes kernel module compilation error
  • Loading branch information
pkoutoupis authored Aug 29, 2017
2 parents cff5388 + f36bab7 commit 354c759
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions module/rapiddisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ rdsk_make_request(struct request_queue *q, struct bio *bio)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,336)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0)
if (unlikely(bio_op(bio) == REQ_OP_DISCARD)) {
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)
if ((unlikely(bio_op(bio) == REQ_OP_DISCARD)) || (unlikely(bio_op(bio) == REQ_OP_WRITE_ZEROES))) {
#else
if (unlikely(bio->bi_rw & REQ_DISCARD)) {
#endif
Expand Down Expand Up @@ -705,7 +707,9 @@ static int attach_device(int size)
rdsk->rdsk_queue->nr_requests = nr_requests;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
rdsk->rdsk_queue->limits.discard_granularity = PAGE_SIZE;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0)
rdsk->rdsk_queue->limits.discard_zeroes_data = 1;
#endif
rdsk->rdsk_queue->limits.max_discard_sectors = UINT_MAX;
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, rdsk->rdsk_queue);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int archive_rd_volume(struct RD_PROFILE *prof, unsigned char *src,
in = (char *)malloc(BUFSZ);
out = (char *)malloc(BUFSZ);

if ((in == '\0') || (out == '\0')) {
if ((in == NULL) || (out == NULL)) {
printf("Error. Unable to acquire memory space.\n");
return -ENOMEM;
}
Expand Down Expand Up @@ -150,7 +150,7 @@ int restore_rd_volume(struct RD_PROFILE *prof, unsigned char *src,
in = (char *)malloc(BUFSZ);
out = (char *)malloc(BUFSZ);

if ((in == '\0') || (out == '\0')) {
if ((in == NULL) || (out == NULL)) {
printf("Error. Unable to acquire memory space.\n");
return -ENOMEM;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ int detach_device(struct RD_PROFILE *rd_prof, RC_PROFILE * rc_prof, unsigned cha
rc_prof = rc_prof->next;
}

if ((buf = (char *)malloc(BUFSZ)) == '\0') {
if ((buf = (char *)malloc(BUFSZ)) == NULL) {
printf("%s: malloc: Unable to allocate memory.\n", __func__);
return -1;
}
Expand Down Expand Up @@ -459,7 +459,7 @@ int cache_map(struct RD_PROFILE *rd_prof, struct RC_PROFILE * rc_prof,
rc_prof = rc_prof->next;
}

if ((buf = (char *)malloc(BUFSZ)) == '\0') {
if ((buf = (char *)malloc(BUFSZ)) == NULL) {
printf("%s: malloc: Unable to allocate memory.\n", __func__);
return -1;
}
Expand Down Expand Up @@ -547,7 +547,7 @@ int cache_unmap(struct RC_PROFILE *prof, unsigned char *string)
return -ENOENT;
}

if ((buf = (char *)malloc(BUFSZ)) == '\0') {
if ((buf = (char *)malloc(BUFSZ)) == NULL) {
printf("%s: malloc: Unable to allocate memory.\n", __func__);
return -ENOMEM;
}
Expand Down Expand Up @@ -599,7 +599,7 @@ int rdsk_flush(struct RD_PROFILE *rd_prof, RC_PROFILE *rc_prof, unsigned char *s
rc_prof = rc_prof->next;
}

if ((buf = (char *)malloc(BUFSZ)) == '\0') {
if ((buf = (char *)malloc(BUFSZ)) == NULL) {
printf("%s: malloc: Unable to allocate memory.\n", __func__);
return -ENOMEM;
}
Expand Down

0 comments on commit 354c759

Please sign in to comment.