Fwd: Simulating the REMOVABLE media - Could any one please suggest me.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Resending to kernelnewbies due to failure ....

---------- Forwarded message ----------
From: Fawad Lateef <fawadlateef@xxxxxxxxx>
Date: Apr 26, 2006 1:59 PM
Subject: Re: FW: Simulating the REMOVABLE media - Could any one please
suggest me.
To: "Srinivas G." <srinivasg@xxxxxxxxxxxxxxxxxxxxx>
Cc: kernelnewbies <kernelnewbies@xxxxxxxxxxxx>, gauravd.chd@xxxxxxxxx,
J.A.K.Mouw@xxxxxxxxxxxxxx, hnagar2@xxxxxxxxx, bulb@xxxxxx,
mandeep.stinger@xxxxxxxxx, idoit.ief@xxxxxxxxx,
mulyadi.santosa@xxxxxxxxx, 2500.pradeep@xxxxxxxxx


Hello Srinivas,

On 4/26/06, Srinivas G. <srinivasg@xxxxxxxxxxxxxxxxxxxxx> wrote:
> I am facing a problem while simulating a removable media via simple
> block driver. But if I remove the floppy disk after mounting it, I could
> not get any problem with the floppy disk. But I do not understand why I
> am facing the problem with my device.
>
> I prepared an IOCTL to simulate the removable media to the kernel.
> When the applications issues IOCTL, it removes the device from the
> kernel space.
>
> when I issue #ls /mnt (mount point) ( i.e. after the application issues
> the IOCTL) the CONSOLE crashes, OR it crashes when tried to unload the
> module.
>
> I have been trying hard to understand the real problem with this module.
>
> What wrong am I doing in this module?
> Could any body explain the problem? Thanks in advance.
>

I think you are __not__ doing stuff in a right way. Please take a look
at the sample-code (sbull) of LDD3 book which simulates media_changed
(removal_disk) after specific timeout and that example will really
help you (as I think you can do the stuff which it does in timer
callback function in your ioctl)

Now as your question in your previous post on linux-kernel and
kernelnewbies (subject: Simple Block Driver (RAM DISK) - Console Crash
(specific case)) which is:

Quoting your previous mail : .................................

On Mon, 17 Apr 2006 20:52:34, Srinivas G.
<srinivasg@xxxxxxxxxxxxxxxxxxxxx> wrote:

I developed a simple ram disk driver. It is working fine.

But I am facing a new problem (console crash) when I try to run the "ls"
command on a mount point after removing the disk with out unmounting
(see the below - How I am removing the ram disk after mount without
unmounting).

Please find the attached source. I am using the following configuration.
--> x86 system with Fedora Core 3 installed (IA-32 Architecture)
--> Running 2.6.x kernels like 2.6.10, 2.6.12 and 2.6.14 on the same
system.

To reproduce the "console crash error" you just have to follow exactly
the next steps:

1) Copy the attached files to your system
2) Build the sbd.ko file using the attached Makefile (make)
3) Load (insert) the module into the kernel space (insmod sbd.ko)
4) wait a few milli seconds to create the device node and format the
device (mke2fs /dev/sbd0)
5) mount the device (mount /dev/sbd0 /mnt)
6) copy some files into the mount point (cp *.c /mnt)
7) un mount the device (umount /mnt OR umount /dev/sbd0)
8) then again, mount the device (mount /dev/sbd0 /mnt)
9) remove the mounted device (compile the app.c file [cc app.c] then run
the ./a.out which will remove the mounted device) You can easily
understand by seeing the code.
10) cd /mnt
11) run ls (which shows the errors messages - see attachment mes_log
file)
12) run again ls - console crash

SEE THE BELOW TWO CONDITIONS WHERE I AM NOT ABLE TO SEE THE CONSOLE
CRASH.

1)      After mounting the FDD, I removed the floppy with out un
mounting (The floppy disk has already some files in it).
2)      If I perform the above procedure WITH OUT STEPS 6, 7 and 8.

Could any one explain why the problem occurs?
If I am wrong please correct me.

Quotation End ..............

Case 1) Have you checked by opening the data/files in the floppy disk
(I pretty sure, it will be in currupted state, b/c the data first goes
into the cache and mostly at umount time or eject time floppy disk
driver perform flushing/synching them to disk). And floppy disk driver
assigns block_device_operations -> media_changed and revalidate_disk
which I think called if filesystem found some changes in the media or
might be called from some other place in the kernel.

Case 2) If you won't do steps 6,7 and 8, then it means that your disk
don't have any data to be syncronized, so it won't give any problem
and filesystem performs ls well, else ls will perform reading on the
device and you already removed that (just try to figure-out the
stack/function_call trace from your log that from bottom of stack to
up which last function (top-most function) is called and created
problem).

I think it helps, else you can ask more questions (I will try to reply
if got time, as I already thinking of replying for your previous mail
but havn't got time for that) and someone will definitely reply.

Cheers :)


--
Fawad Lateef


--
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux