Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Block (data storage)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Sequence of bits or bytes of a maximum predetermined size}} {{About|the computer input/output technique|the process scheduling concept|Blocking (computing)}} {{Distinguish|Page (computer memory)|Bank (computer memory)}} {{More citations needed|date=April 2014}} {{Use dmy dates|date=March 2020|cs1-dates=y}} In [[computing]] (specifically [[data transmission]] and [[computer storage|data storage]]), a '''block''',<ref name="Buchholz_1962"/> sometimes called a '''physical record''', is a sequence of [[byte]]s or [[bit]]s, usually containing some whole number of [[record (computer science)|record]]s, having a fixed length; a ''block size''.<ref name="CNET14"/> Data thus [[Data structure|structured]] are said to be ''blocked''. The process of putting data into blocks is called ''blocking'', while ''deblocking'' is the process of extracting data from blocks. Blocked data is normally stored in a [[data buffer]], and read or written a whole block at a time. Blocking reduces the [[overhead (computing)|overhead]] and speeds up the handling of the [[data stream]].<ref name="Chang"/> For some devices, such as magnetic tape and [[Count Key Data|CKD disk device]]s, blocking reduces the amount of external storage required for the data. Blocking is almost universally employed when storing data to [[9-track tape|9-track]] [[magnetic tape]], NAND [[flash memory]], and rotating media such as [[floppy disk]]s, [[hard disk]]s, and [[optical disc]]s. Most [[file system]]s are based on a [[block device]], which is a level of [[abstraction (computer science)|abstraction]] 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 to [[internal 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 create [[slack space]]. Some newer file systems, such as [[Btrfs]] and [[FreeBSD]] [[Unix File System|UFS2]], attempt to solve this through techniques called [[block suballocation|block suballocation and tail merging]]. Other file systems such as [[ZFS]] support variable block sizes.<ref name="ZFS1"/><ref name="ZFS2"/> Block storage is normally abstracted by a file system or [[database management system]] (DBMS) for use by applications and end users. The physical or logical volumes accessed via ''block I/O'' may be devices internal to a server, directly attached via [[SCSI]] or [[Fibre Channel]], or distant devices accessed via a [[storage area network]] (SAN) using a protocol such as [[iSCSI]], or [[ATA over Ethernet|AoE]]. 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. The {{Mono|stat}} command part of [[GNU Core Utilities]] can be used to check the block size. In [[Rust (programming language)|Rust]] a block can be read with the {{Code|read_exact}} method.<ref>{{cite web |title=Read in std::io - Rust |url=https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact |website=doc.rust-lang.org |access-date=2 February 2025}}</ref> <syntaxhighlight lang="rust"> const BLOCK_SIZE: usize = 4096; if let Ok(mut file) = File::open("example.bin") { let mut buf = [0u8; BLOCK_SIZE]; file.read_exact(&mut buf); } </syntaxhighlight> In [[Python (programming language)|Python]] a block can be read with the {{Code|read}} method. <syntaxhighlight lang="python"> BLOCK_SIZE = 4096 with open("example.bin", "rb") as file: block = file.read(BLOCK_SIZE) </syntaxhighlight> In [[C Sharp (programming language)|C#]] a block can be read with the {{Code|FileStream}} class.<ref>{{cite web |title=FileStream.ReadAsync Method (System.IO) |url=https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream.readasync?view=net-9.0 |website=learn.microsoft.com |access-date=2 February 2025 |language=en-us}}</ref> <syntaxhighlight lang="csharp"> const int BLOCK_SIZE = 4096; using FileStream stream = File.Open("example.bin", FileMode.Open); var block = new byte[BLOCK_SIZE]; await stream.ReadAsync(block, 0, BLOCK_SIZE); </syntaxhighlight> == References == {{reflist|refs= <ref name="CNET14">{{cite news |author=<!-- staff writer, no byline --> |title=Available hard drive space, block sizes, and size terminology |newspaper=CNET |date=2009-05-05 |url=http://www.cnet.com/news/available-hard-drive-space-block-sizes-and-size-terminology/ |access-date=2014-04-29}}</ref> <ref name="Chang">{{cite web |author-last=Chang |author-first=S. K. |title=Physical Structures |work=Captain SK |url=http://people.cs.pitt.edu/~chang/156/08struct.html |access-date=2014-04-29}}</ref> <ref name="ZFS1">{{cite news |author-first=Rachel |author-last=Balik |title=Bruning Questions: ZFS Record Size |newspaper=Joyent |date=2013-03-29 |url=https://www.joyent.com/blog/bruning-questions-zfs-record-size/ |access-date=2013-03-29}}</ref> <ref name="ZFS2">{{cite news |author-first=Roch |author-last=Bourbonnais |title=Tuning ZFS recordsize |date=2006-06-07 |newspaper=Oracle |url=https://blogs.oracle.com/roch/tuning-zfs-recordsize}}</ref> <ref name="Buchholz_1962">{{citation |title=Planning a Computer System β Project Stretch |author-first1=Gerrit Anne |author-last1=Blaauw |author-link1=Gerrit Anne Blaauw |author-first2=Frederick Phillips |author-last2=Brooks, Jr. |author-link2=Frederick Phillips Brooks, Jr. |author-first3=Werner |author-last3=Buchholz |author-link3=Werner Buchholz |editor-first=Werner |editor-last=Buchholz |editor-link=Werner Buchholz |publisher=[[McGraw-Hill Book Company, Inc.]] / The Maple Press Company, York, PA. |lccn=61-10466 |date=1962 |chapter=4: Natural Data Units |pages=39β40 |chapter-url=http://archive.computerhistory.org/resources/text/IBM/Stretch/pdfs/Buchholz_102636426.pdf |access-date=2017-04-03 |url-status=live |archive-url=https://web.archive.org/web/20170403014651/http://archive.computerhistory.org/resources/text/IBM/Stretch/pdfs/Buchholz_102636426.pdf |archive-date=2017-04-03 |quote=[β¦] Terms used here to describe the structure imposed by the machine design, in addition to ''[[bit]]'', are listed below.<br/>''[[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 than ''[[character (computing)|character]]'' 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 from ''[[bite]]'', but respelled to avoid accidental mutation to ''bit''.)<br/>A ''[[word (computer architecture)|word]]'' 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 term ''[[catena (unit)|catena]]'' was coined for this purpose by the designers of the [[Groupe Bull|Bull]] {{ill|Bull Gamma 60{{!}}GAMMA 60|fr|Gamma 60}} computer.)<br/>''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. [β¦]}}</ref> }} [[Category:Articles with example C Sharp code]] [[Category:Articles with example Python (programming language) code]] [[Category:Articles with example Rust code]] [[Category:Computer data storage]] [[Category:Data transmission]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:About
(
edit
)
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Distinguish
(
edit
)
Template:Mono
(
edit
)
Template:More citations needed
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Use dmy dates
(
edit
)