mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "nani jampala" <nani.bhanu007@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Issues with removable media
Date: Tue, 25 Apr 2006 20:18:07 +0530	[thread overview]
Message-ID: <6db17a060604250748u5fd3905ej23e5f7f1092bacc2@mail.gmail.com> (raw)

Dear Linux Kernel Govers,

I have read through the LDD3 & LWN and got a fair understanding about
implementing Linux removable block driver. I made an attempt to
simulate the Removable media in a Simple block driver module.

I am doing the following when trying to simulate the Removable media:

/******* Simple block Driver request ********/

 static void sbd_request(request_queue_t *q)
 {
    struct request *req;
    int status;

    while ((req = elv_next_request(q)) != NULL) {
      if (! blk_fs_request(req)) {
          printk (KERN_NOTICE "Skip non-CMD request\n");
          end_request(req, 0);
          continue;
      }

      /* Simple memcpy based on the request ; Returns success or
        failure which is passed to end_that_request_first() */
      status = sbd_transfer(&Device, req->sector, req->current_nr_sectors,
                 req->buffer, rq_data_dir(req));

      if(!end_that_request_first(req, status, req->current_nr_sectors)) {
                  blkdev_dequeue_request(req);
                  end_that_request_last(req);
            }
  }

Then, I prepared an IOCTL to simulate the removable media to the kernel.

When the applications issues IOCTL, it performs the following to
notify the kernel of removed disk.

/* Simulate the Removal Media Disk */
Case REMOVE_MOUNTED_DISK:

            if(Device.bdev)
                  invalidate_bdev(Device.bdev,1);
            del_gendisk(Device.gd);
            put_disk(Device.gd);
            blk_cleanup_queue(Queue);
            vfree(Device.data);
            return 0;

when I issue #ls /mnt (mount point) ( i.e. after the application
issues the IOCTL)
the Kernel crashes,
	OR
it crashes when tried to unload the module.

I have been trying hard to understand the real problem with this
module a long time from now.

What wrong am I doing in this module?
I will provide you with source code if you need it any time.
Please let me know what additional things should I handle when writing
code for removable media?

Regards,
Mukund Jampala

                 reply	other threads:[~2006-04-25 14:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6db17a060604250748u5fd3905ej23e5f7f1092bacc2@mail.gmail.com \
    --to=nani.bhanu007@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®