TAILIEUCHUNG - UNIX Filesystems Evolution Design and Implementation PHẦN 3

Chuỗi các sự kiện ở đây cũng có kết quả trong một tập tin có kích thước 2048 byte. Tuy nhiên, bằng cách tìm kiếm một phần của tập tin không tồn tại và bằng văn bản, phân bổ xảy ra ở vị trí trong các tập tin theo quy định của con trỏ tập tin. Do đó, một khối duy nhất 1KB được phân bổ vào tập tin. | 68 UNIX Filesystems Evolution Design and Implementation User create write 1k of a s write 1k of b s close Filesystem Create a new file Allocate a new 1k block for range 0 to 1023 bytes Allocate a new 1k block for range 1024 to 2047 bytes Close the file In this example following the close call the file has a size of 2048 bytes. The data written to the file is stored in two 1k blocks. Now consider the example below User Filesystem create lseek to 1k write 1k of b s close Create a new file No effect on the file Allocate a new 1k block for range 1024 to 2047 bytes Close the file The chain of events here also results in a file of size 2048 bytes. However by seeking to a part of the file that doesn t exist and writing the allocation occurs at the position in the file as specified by the file pointer. Thus a single 1KB block is allocated to the file. The two different allocations are shown in Figure . Note that although filesystems will differ in their individual implementations each file will contain a block map mapping the blocks that are allocated to the file and at which offsets. Thus in Figure the hole is explicitly marked. So what use are sparse files and what happens if the file is read All UNIX standards dictate that if a file contains a hole and data is read from a portion of a file containing a hole zeroes must be returned. Thus when reading the sparse file above we will see the same result as for a file created as follows User create write 1k of 0s write 1k of b s close Filesystem Create a new file Allocate a new 1k block for range 1023 to 2047 bytes Allocate a new 1k block for range 1024 to 2047 bytes Close the file Not all filesystems implement sparse files and as the examples above show from a programmatic perspective the holes in the file are not actually visible. The main benefit comes from the amount of storage that is saved. Thus if an application wishes to create a file for which large parts of the file contain zeroes this is a useful way to save

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.