Re: VFS concurrency control and initialization

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

 



Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:

> First, I'm trying to modify 'sys_open' from fs/open.c, representing
> the 'open' system call.  I'd like to make an update to a global data
> structure on every open system call.  Updates to this data structure
> will need to be mutually exclusive in order to avoid data structure
> corruption.  Do I need to initiate some form of concurrency control,
> or does 'sys_open' already happen atomically?

I'll go ahead and answer my first question by quoting
Documentation/filesystems/vfs.txt:

    All VFS system calls (i.e. open(2), stat(2), read(2), write(2),
    chmod(2) and so on) are called from a process context. You should
    assume that these calls are made without any kernel locks being
    held. This means that the processes may be executing the same piece of
    filesystem or driver code at the same time, on different
    processors. You should ensure that access to shared resources is
    protected by appropriate locks.

> Secondly, I'm not exactly sure where to declare and initialize the
> global data structure I'm referring to in the above paragraph.  I
> expect it should be initialized when VFS is initialized.  Where should
> I look for VFS init?  I'm noticing that the buffer cache is
> initialized in 'buffer_init' from fs/buffer.c, but am looking for a
> general place to initialize my global data structure.

I've decided to stick this initialization somewhere in (or called
from) start_kernel().  That appears to be where VFS init happens.
-- 
Benjamin

--
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