Passing open file descriptors over unix domain sockets

Note:- This article is an example walk-through written for developers keeping in mind that you are aware of very basic network/socket programming concepts.

Some basics
All of you must have heard about file descriptors or popularly known as fds in Unix world. It is basically an index/indicator generally used to provide access to files, network sockets etc. File descriptor will always be a non-negative integer which has been part of POSIX standard from old days. Accordingly we have 3 standard POSIX file descriptors namely standard input or stdin with value 0, standard output or stdout with value 1 and standard error or stderr with value 2. Standard I/O library from C allows us to create fds via different system calls like open(), creat(), socket(), socketpair(), pipe() etc. For example, if we want to write some data into a file we normally invoke open(2) or create(2) to have an open file descriptor and subsequent write(2) operation is performed via that fd. Finally when we are done with operations we close the fd.

That’s all about some basic file operations work flow. On the other side we have Unix Domain Sockets which is commonly used for data communications between processes Read More »

Mandatory locks support with GlusterFS v3.8

antmascot

Latest version 3.8 from GlusterFS community comes out with the support for Mandatory locks. Please refer the blog post announcing the release to get an overview of all new features delivered with 3.8. This article will be a background cum architectural analysis on mandatory locks feature for GlusterFS and its further possibilities when working under various protocol environments.

Traditional/Advisory locks
Whenever it comes to a situation where file contents are being concurrently accessed by different applications there always raise the Read More »

POSIX deadlock detection: A walk through linux kernel source

A note to readers: The following content is completely oriented for developers, especially in C. In case you find it difficult to understand certain terms, please help yourselves to google around and understand the concepts. I have tried including links wherever necessary in order to effectively interpret the article(see provided links towards the end). Last but not least, as per POSIX documentation[1], deadlock detection is guaranteed for locks between different processes and not between different threads inside a process or between threads belonging to different processes.

As you can see from the heading of this article, I am aiming at explaining the source code for detecting POSIX deadlocks. Before that let me quickly brief the concept of deadlock in operating systems. A deadlock is a situation where two processes sharing the same resource are preventing each other from accessing the resource which will result in an undefined wait for those resources. Following are the four necessary conditions(Coffman conditions)[2] which leads to a deadlock scenario:

* Mutual exclusion
* Hold and Wait
* No pre-emption
* Circular wait

Read More »