为什么 bdev_get_queue return NULL?

Why bdev_get_queue return NULL?

我正在为块设备开发一个 "filter" (Linux, Ubuntu 16), 在过滤器驱动程序的初始化过程中,我尝试了后端(存在设备)的 queue 指针,bdev_get_queue[=27= 的主体] 宏显示很酷的评论 "this never NULL",但我为 bd_disk 字段设置了 NULL= ]结构block_device.

我还需要检查什么?

static int __init dua_init(void)
{
    int status;
    struct request_queue *backend_queue = NULL;
    struct super_block *sb = NULL;

    printk(KERN_NOTICE __MODULE__ ": Initialize the driver ...\n");

    if ( IS_ERR(backend_bdev = lookup_bdev(dudrv_bckend, FMODE_READ)) )
        {
        status = PTR_ERR(backend_bdev);
        printk(KERN_ERR __MODULE__ ": lookup_bdev(%s) -> %d\n", dudrv_bckend, status);
        return  status;
        }

    $DELAY(1);

    if ( sb = freeze_bdev(backend_bdev) )
        $TRACE(": freeze I/O on block device %s ...", dudrv_bckend);

    $DELAY(1);

    $TRACE(" %p ", backend_bdev->bd_disk);

    $DELAY(1);

    backend_queue = bdev_get_queue(backend_bdev);

    $TRACE(" -- ");

    $DELAY(1);

    if ( backend_make_request_fn != backend_queue->make_request_fn )
        {
        backend_make_request_fn = backend_queue->make_request_fn;
        backend_queue->make_request_fn = dua_make_request_fn;

        $TRACE(": Change for %s request_fn = %p -> %p, ", dudrv_bckend, backend_make_request_fn, backend_queue->make_request_fn);
        }
    else    {
        printk(KERN_NOTICE __MODULE__ ": I/O request process has been set.\n");
        }

    $TRACE(" -- ");

    /* unlock filesystem */
    $DELAY(1);
    if ( sb )
        if (status = thaw_bdev(backend_bdev, sb))
            printk(KERN_NOTICE __MODULE__ ": thaw_bdev() -> %d\n", status);

    printk(KERN_NOTICE __MODULE__ ": End the driver initialization.\n");

    return 0;
}

Update1:​​队列指针应该由 bdev_get_queuestruct block_device 返回的区别是什么?bd_queue ?

lookup_bdev() 不创建完整块 I/O 上下文。