If I understand properly, you are using the spinlock to protect your list. But why do you want to protect the writing to file too using the spinlock? The VFS make sure that consistent writes to the file are safe by locking internally... Regds Ed --- Guillaume Thouvenin <guillaume.thouvenin@polymtl.ca> wrote: > Selon Guillaume Thouvenin > <guillaume.thouvenin@POLYMTL.CA>: > > > I wrote a piece of kernel code that deals with > new structure. Those > > stucture > > are manipulated by a driver. So, I implemented a > classical ioctl() with a > > switch > > to select appropriate action to perform. One of > this action is to remove a > > data > > from a list: > > Oops, some parts of the mail are missing so I > resume: > > I implemented the ioctl as follow: > > int my_ioctl(...) { > ... > switch(cmd) { > case REMOVE_AN_ITEM: > spin_lock_irq(&my_lock); > update_my_structure(); > spin_unlock_irq(&my_lock); > break; > .... > } > } > > Function update_my_structure() remove an item from a > list of items and if the > list is empty, it dumps information about this list > in a file. So, in this > function I call filp_open() if list is empty. The > problem is that you can not > call filp_open() if you are in a spinlock because > irq must be enable. So my > question is how can you open a file if you are in a > spin_lock_irq()? Can I use > spin_lock() instead of spin_lock_irq() when doing > some ioctl? > > I tried (peudo-code): > > int update_my_structure() > { > ... > remove_item(); > if (list is empty()) { > local_irq_enable(); > f = filp_open(); > f->write(info); > filp_close(f); > local_irq_disable(); > } > ... > > > But it doesn't work. It seems that it produces a > lock and kernel freezes. > > Thanks for your help > Guillaume > > -- > Kernelnewbies: Help each other learn about the Linux > kernel. > Archive: > http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/