if: adapt to 3d745ea5b09 (kernel 5.7+)

This commit is contained in:
Thomas Schoebel-Theuer 2022-08-09 14:22:25 +02:00
parent 25e3831695
commit d69d069e7f
2 changed files with 28 additions and 1 deletions

View File

@ -131,6 +131,15 @@ extern int __oldcompat_unlink(
#include <linux/backing-dev.h> #include <linux/backing-dev.h>
#endif #endif
/* Adapt to 3d745ea5b095a3985129e162900b7e6c22518a9d
* detected via 9243c6f3e012a92dd900d97ef45efaf8a8edc448
* and see its comment.
*/
#if !defined(GENHD_FL_MEDIA_CHANGE_NOTIFY) || \
defined(IOCB_WAITQ)
#define MARS_NEW_BLK_ALLOC_QUEUE
#endif
/* Detect upstream commits /* Detect upstream commits
* 2a842acab109f40f0d7d10b38e9ca88390628996 * 2a842acab109f40f0d7d10b38e9ca88390628996
* 4e4cbee93d56137ebff722be022cae5f70ef84fb * 4e4cbee93d56137ebff722be022cae5f70ef84fb

View File

@ -1066,7 +1066,17 @@ static int if_switch(struct if_brick *brick)
#endif #endif
status = -ENOMEM; status = -ENOMEM;
#ifdef MARS_NEW_BLK_ALLOC_QUEUE
/* Moved from obsolete blk_queue_make_request() to here.
* See 3d745ea5b095a3985129e162900b7e6c22518a9d
* and many thanks to Christoph Hellwig!
*/
q = blk_alloc_queue(if_make_request, GFP_MARS);
#else
/* old code before 3d745ea5b095a3985129e162900b7e6c22518a9d
*/
q = blk_alloc_queue(GFP_MARS); q = blk_alloc_queue(GFP_MARS);
#endif
if (!q) { if (!q) {
MARS_ERR("cannot allocate device request queue\n"); MARS_ERR("cannot allocate device request queue\n");
goto is_down; goto is_down;
@ -1093,8 +1103,16 @@ static int if_switch(struct if_brick *brick)
capacity = if_get_capacity(brick); capacity = if_get_capacity(brick);
MARS_DBG("created device name %s, capacity=%lld\n", disk->disk_name, capacity); MARS_DBG("created device name %s, capacity=%lld\n", disk->disk_name, capacity);
if_set_capacity(input, capacity); if_set_capacity(input, capacity);
#ifdef MARS_NEW_BLK_ALLOC_QUEUE
/* No longer called right here.
* Moved to blk_alloc_queue(), see 3d745ea5b095a3985129e162900b7e6c22518a9d
* and many thanks to Christoph Hellwig!
*/
#else
blk_queue_make_request(q, if_make_request); blk_queue_make_request(q, if_make_request);
#endif
#ifdef USE_MAX_SECTORS #ifdef USE_MAX_SECTORS
#ifdef MAX_SEGMENT_SIZE #ifdef MAX_SEGMENT_SIZE
MARS_DBG("blk_queue_max_sectors()\n"); MARS_DBG("blk_queue_max_sectors()\n");