Workflow of Create and Read File Operations in GFS

Understand how GFS manages concurrent file creation and reading operations.

We'll cover the following

Since the GFS is a system that stores and retrieves data from files at a large scale, we must know how it performs different file operations. We listed the file operations that it supports in this lesson. This lesson focuses on the create and read file operations. The rest of the operations are discussed in the upcoming lessons.

Create a file

To create a file, the client needs to connect to the manager node. The manager creates a file in the directory specified by the client and updates the namespaceThe GFS namespace is a lookup table that contains the full pathnames of files and directories and the associated metadata. Each pathname is stored in a separate table row, and the mapping to the metadata is recorded in the same row in a different column.. Many other operations can be performed by different clients on the same directory concurrently. The manager needs to manage such concurrent requests. The manager acquires two types of locks to guarantee the atomicity and correctness of file creation operation.

  • A read lock is acquired on the directory name (full path to the directory) to make sure that the directory in which the file is being created is not deleted or renamed by another client during the file creation operation.

  • A write lock is acquired on the file name (full path to the file) to serialize the creation of two or more files with the same name.

The manager releases the locks acquired by an operation when it is done with that operation and has responded to the client. The following illustration shows the workflow for file creating operations.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.