Re: open a file in spin_lock_irq()

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

 



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/


[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