Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Block (data storage)

From Wikipedia, the free encyclopedia
Sequence of bits or bytes of a fixed size
This article is about the computer input/output technique. For the process scheduling concept, seeBlocking (computing).
Not to be confused withPage (computer memory) orBank (computer memory).
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Block" data storage – news ·newspapers ·books ·scholar ·JSTOR
(April 2014) (Learn how and when to remove this message)

Incomputing (specificallydata transmission anddata storage), ablock,[1] sometimes called aphysical record, is a sequence ofbytes orbits, usually containing some whole number ofrecords, having a fixed length; ablock size.[2] Data thusstructured are said to beblocked. The process of putting data into blocks is calledblocking, whiledeblocking is the process of extracting data from blocks. Blocked data is normally stored in adata buffer, and read or written a whole block at a time. Blocking reduces theoverhead and speeds up the handling of thedata stream.[3] For some devices, such as magnetic tape andCKD disk devices, blocking reduces the amount of external storage required for the data. Blocking is almost universally employed when storing data to9-trackmagnetic tape, NANDflash memory, and rotating media such asfloppy disks,hard disks, andoptical discs.

Mostfile systems are based on ablock device, which is a level ofabstraction for the hardware responsible for storing and retrieving specified blocks of data, though the block size in file systems may be a multiple of the physical block size. This leads to space inefficiency due tointernal fragmentation, since file lengths are often not integer multiples of block size, and thus the last block of a file may remain partially empty. This will createslack space. Some newer file systems, such asBtrfs andFreeBSDUFS2, attempt to solve this through techniques calledblock suballocation and tail merging. Other file systems such asZFS support variable block sizes.[4][5]

Block storage is normally abstracted by a file system ordatabase management system (DBMS) for use by applications and end users. The physical or logical volumes accessed viablock I/O may be devices internal to a server, directly attached viaSCSI orFibre Channel, or distant devices accessed via astorage area network (SAN) using a protocol such asiSCSI, orAoE. DBMSes often use their own block I/O for improved performance and recoverability as compared to layering the DBMS on top of a file system.

On Linux the default block size for most file systems is 4096 bytes. Thestat command part ofGNU Core Utilities can be used to check the block size.

InRust a block can be read with theread_exact method.[6]

constBLOCK_SIZE:usize=4096;ifletOk(mutfile)=File::open("example.bin"){letmutbuf=[0u8;BLOCK_SIZE];file.read_exact(&mutbuf);}

InPython a block can be read with theread method.

BLOCK_SIZE=4096withopen("example.bin","rb")asfile:block=file.read(BLOCK_SIZE)

InC# a block can be read with theFileStream class.[7]

constintBLOCK_SIZE=4096;usingFileStreamstream=File.Open("example.bin",FileMode.Open);varblock=newbyte[BLOCK_SIZE];awaitstream.ReadAsync(block,0,BLOCK_SIZE);

References

[edit]
  1. ^Blaauw, Gerrit Anne;Brooks, Jr., Frederick Phillips;Buchholz, Werner (1962),"4: Natural Data Units"(PDF), inBuchholz, Werner (ed.),Planning a Computer System – Project Stretch,McGraw-Hill Book Company, Inc. / The Maple Press Company, York, PA., pp. 39–40,LCCN 61-10466,archived(PDF) from the original on 3 April 2017, retrieved3 April 2017,[…] Terms used here to describe the structure imposed by the machine design, in addition tobit, are listed below.
    Byte denotes a group of bits used to encode a character, or the number of bits transmitted in parallel to and from input-output units. A term other thancharacter is used here because a given character may be represented in different applications by more than one code, and different codes may use different numbers of bits (i.e., different byte sizes). In input-output transmission the grouping of bits may be completely arbitrary and have no relation to actual characters. (The term is coined frombite, but respelled to avoid accidental mutation tobit.)
    Aword consists of the number of data bits transmitted in parallel from or to memory in one memory cycle.Word size is thus defined as a structural property of the memory. (The termcatena was coined for this purpose by the designers of theBullGAMMA 60 [fr] computer.)
    Block refers to the number of words transmitted to or from an input-output unit in response to a single input-output instruction. Block size is a structural property of an input-output unit; it may have been fixed by the design or left to be varied by the program. […]
  2. ^"Available hard drive space, block sizes, and size terminology".CNET. 5 May 2009. Retrieved29 April 2014.
  3. ^Chang, S. K."Physical Structures".Captain SK. Retrieved29 April 2014.
  4. ^Balik, Rachel (29 March 2013)."Bruning Questions: ZFS Record Size".Joyent. Retrieved29 March 2013.
  5. ^Bourbonnais, Roch (7 June 2006)."Tuning ZFS recordsize".Oracle.
  6. ^"Read in std::io - Rust".doc.rust-lang.org. Archived fromthe original on 28 January 2026. Retrieved2 February 2025.
  7. ^"FileStream.ReadAsync Method (System.IO)".learn.microsoft.com. Archived fromthe original on 26 December 2025. Retrieved2 February 2025.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Block_(data_storage)&oldid=1336134092"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp