This project involves the implementation of a distributed Network File System (NFS) in C, which allows clients to interact with a centralized storage infrastructure using various file-related operations. The NFS comprises multiple components, including clients, storage servers, and a naming server, which together manage and execute operations like reading, writing, creating, deleting, and streaming files over the network.
This project simulates a distributed NFS system where multiple clients interact with multiple storage servers through a naming server. The primary functions of the system are to manage file creation, reading, writing, deletion, and streaming over the network. The system is designed to be scalable and fault-tolerant, supporting asynchronous writes, multiple concurrent clients, and storage server replication for backup.
Clients represent the systems or users requesting file access in the NFS. They initiate various file operations (read, write, delete, create, stream) and communicate with the Naming Server (NM) to locate the appropriate Storage Server (SS) where the file is stored.
The Naming Server is a central hub in the NFS architecture. It acts as a directory service, mapping client file requests to the appropriate Storage Server. The NM keeps track of all accessible paths in the system and dynamically updates them when new paths are created, deleted, or modified.
Storage Servers store the actual files and provide direct access to clients for file operations. Each SS is responsible for managing a set of files and directories, including their persistence, reading, writing, and streaming. Storage Servers are registered with the NM, which manages their communication with clients.
Clients can initiate various file operations through the NFS:
- Create a File/Folder: Clients can request the creation of a file or folder, and the NM will allocate the task to an available Storage Server.
- Delete a File/Folder: Clients can request to delete files or folders. The NM forwards the request to the appropriate SS for deletion.
- Read a File: Clients can request to read a file from a Storage Server, which will stream the contents to the client.
- Write to a File: Clients can write data to files. This operation supports both synchronous and asynchronous writes.
- Streaming Audio Files: Clients can request to stream audio files directly from the SS for playback.
- Asynchronous Writes: Optimized for large file transfers, allowing clients to continue operations without waiting for the file to be fully written.
- Synchronous Writes: Provides priority for critical operations by waiting until the write is complete.
- Concurrent Access: Multiple clients can read the same file simultaneously.
- Exclusive Writes: Only one client can write to a file at a time (either synchronously or asynchronously).
- Descriptive Error Codes: Examples include
File Not Found
,File in Use
, andServer Failure
.
- Efficient Search: Uses hashmaps and tries for fast lookups.
- LRU Caching: Caches recent searches to improve response times.
- Replication: Files are replicated across multiple servers to ensure fault tolerance.
- Asynchronous Duplication: Write operations are duplicated across replicated Storage Servers.
- Server Recovery: Synchronizes files when a Storage Server comes back online after failure.
Clone the repository:
git clone https://github.com/your-username/nfs.git
cd nfs