mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Issues with removable media
@ 2006-04-25 14:48 nani jampala
  0 siblings, 0 replies; only message in thread
From: nani jampala @ 2006-04-25 14:48 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-04-25 14:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-25 14:48 Issues with removable media nani jampala

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®