$30
CSC3150 Assignment 4
In Assignment 4, you are required to simulate a mechanism of file system via GPU's
memory.
Background:
File systems provide efficient and convenient access to the disk by allowing data
to be stored, located, and retrieved easily.
A file system poses two quite different design problems. The first problem is
defining how the file system should look to the user. This task involves defining a
file with its attributes, the operations allowed on a file, and the directory
structure for organizing files.
The second problem is creating algorithms and data structures to map the logical
file system on to the physical secondary-storage devices.
The file-organization module knows about files and their logical blocks, as well as
physical blocks. By knowing the type of file allocation used and the location of
the file, the file-organization module can translate logical block address to
physical block address for the basic file system to transfer.
Each file’s logical blocks are numbered from 0 (or 1) through N. Since the
physical blocks containing the data usually do not match the logical numbers, a
translation is required to locate each block.
The file-organization module also includes the free-space manager, which tracks
unallocated blocks and provides these blocks to the file-organization module
when requested.
The logical file system manages the directory structure to provide the fileorganization module with the information the latter needs, given a symbolic file
name. It maintains file structure via file-control blocks.
A file-control block (FCB) (an inode in UNIX file systems) contains information
about the file, including ownership, permissions, and location of the file
contents.
Then we can try to implement a simple file system in CUDA GPU with single
thread, and limit global memory as volume.
The GPU File System we need to design:
We take the global memory as a volume (logical drive) from a hard disk.
No directory structure stored in volume, only one root directory, no
subdirectory in this file system.
A set of file operations should be implemented.
In this project, we use only one of GPU memory, the global memory as a
volume. We don’t create the shared memory as physical memory for any data
structures stored in, like system-wide open file table in memory.
In this simple file system, we just directly take the information from a volume (in
global memory) by single thread.
Specification:
The size of volume is 1085440 bytes (1060KB).
The size of files total is 1048576 bytes (1024KB).
The maximum number of file is 1024.
The maximum size of a file is 1024 bytes (1KB).
The maximum size of a file name is 20 bytes.
File name end with “\0”.
FCB size is 32 bytes.
FCB entries is 32KB/ 32 bytes = 1024.
Storage block size is 32 bytes.
open:
Open a file
Give a file pointer to find the file’s location.
Space in the file system must be found for the file.
An entry for the new file must be made in the directory.
Also accept access-mode information: read/write
When to use write mode, if no such file name can be found, create a new
zero byte file.
Return a write/read pointer.
Function definition:
Demo usage:
write:
To write a file.
There is a write pointer to identify the location in the file.
If the file has existed, cleanup the older contents of the file and write the
new contents.
Take the input buffer to write bytes data to the file.
Function definition:
Demo usage:
read:
To read contents from a file.
There is a read pointer to identify the location in the file.
To read bytes data from the file to the output buffer.
The offset of the opened file associated with the read pointer is 0 (always
read the file from head).
Function definition:
Demo usage:
rm:
To delete a file and release the file space.
Search the directory for the named file.
Implement gsys() to pass the RM command.
Function definition.
Demo usage
ls:
List information about files.
Implement gsys() to pass the LS_D/LS_S commands.
LS_D list all files name in the directory and order by modified time of files.
LS_S list all files name and size in the directory and order by size.
If there are several files with the same size, then first create first print.
Function definition
Demo usage
Demo output
Template structure:
Create your cuda project in VS, and add “data.bin” to your project. Pres
“Ctrl”+”F5” to run the template. If it successes, will have output like:
The storage size of the simulated file system is already definded as:
At first, load the binary file, named “data.bin” to input buffer (via
“load_binarary_file()”) before kernel launch.
Launch to GPU kernel with single thread.
In kernel function, simulate file operations for testing. We will replace this part
with different test cases.
You should complete the file operations for open/write/read/rm/ls_d/ls_s.
In CPU(host) main function, the output buffer is copied in device, and it is
written into “snapshot.bin” (via write_binarary_file()).
Function Requirements (90 points):
Implement file volume structure. (10 points)
Implement free space management. (For example, Bit-Vector / Bit-Map). (10
points)
Implement contiguous allocation. (10 points)
Implement open operation (10 points)
Implement write operation (10 points)
Implement read operation (10 points)
Implement rm operation (10 points)
Implement LS_D operation (10 points)
Implement LS_S operation (10 points)
Demo Output:
In the “CSC3150_Assignment_4/Test Case”, we provided three test cases, you could
copy them from txt file and replace them in kernel test part in template code.
Test Case 1
Test Case 2
Test Case 3
Bonus (10 points)
Referring to Chapter 11 Section 11.4 and 11.5, redesign the file system with linked
allocation.
The maximum size of a file is 1024 bytes (1KB).
The maximum size of a file name is 20 bytes.
File name end with “\0”.
You could extend the volume size with extra 32KB.
You could redesign the volume storage structure.
Compare the performance of these two file systems.
Report (10 points)
Write a report for your assignment, which should include main information as below:
How did you design your program?
What problems you met in this assignment and what is your solution?
The steps to execute your program.
Screenshot of your program output.
What did you learn from this assignment?
Submission
Please submit the file as package with directory structure as below:
CSC3150_Assignment_4_(Student ID)
- Source
o main.cu
o data.bin
o snapshot.bin
o bonus.cu (if you implement bonus part)
- Report
Due date: End (23:59) of 29 Nov, 2018
Grading rules
Completion Marks
Report 10 points
Bonus 10 points
Completed with good
quality
80 ~ 90
Completed accurately 80 +
Fully Submitted
(compile successfully)
60 +
Partial submitted 0 ~ 60
No submission 0
Late submission Not allowed