Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9161745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:02:30+00:00 2026-06-17T14:02:30+00:00

I have block driver for a hot-pluggable PCI storage device. if the device is

  • 0

I have block driver for a hot-pluggable PCI storage device. if the device is removed during IO, I never seem to get a call to release (i.e. mydev_blk_release(struct gendisk *gd, fmode_t mode)), which I think is preventing del_gendisk() from completing, thus hanging the cleanup of the driver. I am ending all requests on the queue once an eject happens, but it still doesn’t seem to cause a release. What is the right way to terminate requests and delete the gendisk in the case of vanished media?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:02:31+00:00Added an answer on June 17, 2026 at 2:02 pm

    This is caused by not ending the request that is broken by the device removal. In my driver, I had the folowing request_fn:

    static void mydev_submit_req(struct request_queue *q)
    {
        struct mydev_info *mydev = q->queuedata;
    
        if (!mydev){
            struct request* req;
    
            while ((req = blk_fetch_request(q)) != NULL){
                   req->cmd_flags |= REQ_QUIET;
                   __blk_end_request_all(req, -ENODEV);
            }
        } else {
            queue_work(mydev->wq, &mydev->work);
        }
    }
    

    This will prevent the requests entering the driver’s workqueue when the device disappears (signified by the loss of mydev). However this hung because the last request was not actually completed, causing q->rq->elvpriv (now called q->nr_rqs_elvpriv) to remain at 1, which caused blk_drain_queue() to spin forever, which hung blk_cleanup_queue() and prevented the driver being able to remove the device.

    The solution looks like this (in the workqueue callback function in my driver, but this depends on how you structure the IO work):

    req = blk_fetch_request(q);
    while (req) {
        // returns -ENODEV if the disk is ejected during transfer
        //bytes tells us how many bytes we managed to do
        res = mydev_do_req(q, req, &bytes);
    
    
        if (unlikely(res == -ENODEV)) {
            dev_err(&mydev->pdev->dev, 
                "device ejected during transfer, returning\n");
    
            //end the current request, since we started it
            //THIS IS WHAT WAS MISSING
            __blk_end_request_all(req, -ENODEV);
            break;
            //get out - the rest of the  queue will be emptied on the next
            //submit_req
        } else if (!__blk_end_request(req, res, bytes)) {
            req = blk_fetch_request(q); //get the next request
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a block device driver for a hot-pluggable PCI memory device on 2.6.43.2-6.fc15
I have noticed that when I call lseek64 on my block device driver file
I am writing a Linux block device driver and I have a lot of
Hi I have following code block public class Driver { static String x =
I am using the Mongo Ruby driver and have this block of Ruby code
I have a device driver that allows a user-space app to perform various operations
I am allocating a block of memory with kmalloc in a device driver in
I'm writing a device driver that, among other things, allocates a block of memory
I have a block of HTML code that contains a button <button class=someButton onclick=openPage('test')></button>
I have a block of code in C like this- enum colors { //---->I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.