GFS File Operations
Let's understand the GFS API for its clients and compare its similarities and differences with a traditional file system API.
We saw the high-level architecture of GFS in the previous lesson, along with its system-level goals. Since it stores files, we should also know about the API it provides to its clients for storing, retrieving, or deleting their data. In this lesson, we will look into the GFS client API. Next, we will explain how GFS handles each of the client operations and how it meets its system-level goals.
The illustration below shows all of the operations that GFS clients can perform on files or directories.
GFS clients can perform the following simple directory-level operations. The semantics for these operations are the same as those of the Unix file system.
Create directory: Users can create multiple directories to organize their files.
Delete directory: Users should be able to delete a directory. The system should ensure this operation doesn't leave dangling data on the chunkservers. It should also ensure that all the files in the directory are deleted before deleting the directory itself. If the directory contains files, the system should ask the client to delete those files first.
List directory: The users should be able to list what's inside a directory. In GFS, there is no
for representing namespaces. GFS represents a file with its fullinode-like data structure The inode (index node) is a data structure in a Unix-style file system that defines file system object (FSO) model like files or directories. Each inode stores the attributes and disk block locations of the object's data. Attributes of a file or a directory object may include metadata like times of last change, access, and modification, with owner and permission data. A directory is a list of inodes with their assigned names. The list includes an entry for itself, its parent, and each of its children. [source: Wikipedia] pathname
. A lookup table is maintained that maps the fullpathname
of a file to its metadata, as shown in the following table. This table logically represents the namespace. The last component in the path can be a file or a directory. The rest of the path is all about directories. In the table below, listing a directory with path/dir1/dir2
should list the path names that are one name longer than it, for example,/dir1/dir2/fileA
and/dir1/dir2/dir4
and so on.
File operations
GFS client API allows the users to perform the following file operations.