diff --git a/scst/include/backport.h b/scst/include/backport.h index de48788f9..3b94bb87b 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -868,6 +868,10 @@ static inline void sg_mark_end(struct scatterlist *sg) { } +static inline void sg_unmark_end(struct scatterlist *sg) +{ +} + #ifndef __BACKPORT_LINUX_SCATTERLIST_H_TO_2_6_23__ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) @@ -895,6 +899,15 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page, #endif /* for_each_sg */ #endif /* __BACKPORT_LINUX_SCATTERLIST_H_TO_2_6_23__ */ +#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0) +/* + * See also commit c8164d8931fd ("scatterlist: introduce sg_unmark_end"; + * v3.10). + */ +static inline void sg_unmark_end(struct scatterlist *sg) +{ + sg->page_link &= ~0x02; +} #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) */ /* */ diff --git a/scst/src/scst_mem.c b/scst/src/scst_mem.c index 7c1139519..53dc11476 100644 --- a/scst/src/scst_mem.c +++ b/scst/src/scst_mem.c @@ -1099,6 +1099,7 @@ success: *sgv = obj; obj->sg_entries[cnt-1].length -= PAGE_ALIGN(size) - size; + sg_mark_end(&obj->sg_entries[cnt-1]); TRACE_MEM("obj=%p, sg_entries %p (size=%d, pages=%d, sg_count=%d, " "count=%d, last_len=%d)", obj, obj->sg_entries, size, pages, @@ -1224,6 +1225,7 @@ void sgv_pool_free(struct sgv_pool_obj *obj, struct scst_mem_lim *mem_lim) if (obj->cache_num >= 0) { obj->sg_entries[obj->orig_sg].length = obj->orig_length; + sg_unmark_end(&obj->sg_entries[obj->orig_sg]); sgv_put_obj(obj); } else { obj->owner_pool->alloc_fns.free_pages_fn(obj->sg_entries,