Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 17: Data Synchronization



  1. If the inode access counter (i_count) has a value greater than 1, the kernel inserts the inode
    in the globalinode_in_uselist because it is still in use.

  2. When the access counter drops to 0, the inode can be placed in the global list of unused inode
    instances (inode_unused).


Thei_listelement of the inode is used as a list element in all the above situations.

The final step is to invokewake_up_inodevia the dispatcherinode_sync_complete.Thisfunctionwakes
processes that were placed on the queue of inodes waiting to be written back but whoseI_LOCKbit is
set. Because the inode is no longer needed by the current thread (and is therefore no longer locked),
the scheduler selects one of these processes to handle the inode. If the data have already been fully
synchronized, this process has nothing else to do. If dirty pages still need to be synchronized, the process
goes ahead and synchronizes them.

17.11 Congestion


I have used the termcongestiona few times without precisely defining what it means. On an intuitive
level it is not difficult to understand — when a kernel block device queue is overloaded with read or
write operations, it doesn’t make sense to add further requests for communication with the block device.
It is best to wait until a certain number of requests have been processed and the queue is shorter before
submitting new read or write requests.

Below I examine how the kernel implements this definition on a technical level.

17.11.1 Data Structures


A double wait queue is needed to implement thecongestionmethod. The definition is as follows:

mm/backing-dev.c
static wait_queue_head_t congestion_wqh[2] = {
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
__WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
};

The kernel provides two queues, one for input and one for output. Two pre-processor constants (READ
andWRITE)aredefinedin<fs.h>to allow access to the array elements and to clearly differentiate between
the two queues without the direct use of numbers.

The kernel makes a distinction between thedirectionsin which data are transmitted
to the queue — in other words, between input and output. The data structure does
notdifferentiate between the various devices in the system. As you will see shortly,
the data structures of the block layer contain queue-specific information on possible
congestion.

Notice that the queues are not supposed to be manipulated directly with standard wait queue methods.
Instead, a number of auxiliary functions declared in<backing-dev.h>are provided by the kernel; they
are covered in the following discussion.
Free download pdf