← Documents Documentation/ABI/testing/sysfs-block-bcache GitHub 원문 ↗

Linux 6.18.37 · ABI / testing

bcache block device sysfs ABI

bcache backing device와 cache의 unregister·통계·연결, hit와 sequential bypass, writeback policy, crash recovery·discard, bucket·btree·write accounting attributes를 설명합니다.

Source pathDocumentation/ABI/testing/sysfs-block-bcache
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

Device lifecycle와 cache linkage

sysfs-block-bcache:1-22

unregister는 dirty data를 안전하게 flush하고 backing device와 cache를 해제하며, clear_stats는 device 통계를 초기화하고 cache symlink는 backing device가 사용하는 cache를 가리킵니다.

Cache hit와 sequential bypass

sysfs-block-bcache:24-57

Backing device별 full hit·miss·hit ratio를 제공하고, sequential_cutoff를 넘은 I/O는 cache를 우회하며 bypassed가 그 누적 byte 수를 보고합니다.

Writeback policy와 flush timing

sysfs-block-bcache:59-95

writeback·writeback_running·writeback_delay·writeback_percent가 write buffering, dirty data flush, first-dirty delay와 cache utilization threshold를 제어합니다.

Synchronous recovery와 discard

sysfs-block-bcache:97-114

Cache의 synchronous mode는 unclean shutdown recovery를 위한 write ordering을 보장하며, discard는 device가 지원하는 TRIM을 켜거나 끕니다.

Cache geometry, btree와 write accounting

sysfs-block-bcache:116-156

bucket_size·nbuckets·tree_depth·btree_cache_size가 cache geometry와 in-memory btree 상태를, written·btree_written이 data와 btree write 총량을 보고합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 What: /sys/block/<disk>/bcache/unregister
2 Date: November 2010
3 Contact: Kent Overstreet <kent.overstreet@gmail.com>
4 Description:
5 A write to this file causes the backing device or cache to be
6 unregistered. If a backing device had dirty data in the cache,
7 writeback mode is automatically disabled and all dirty data is
8 flushed before the device is unregistered. Caches unregister
9 all associated backing devices before unregistering themselves.
10
11 What: /sys/block/<disk>/bcache/clear_stats
12 Date: November 2010
13 Contact: Kent Overstreet <kent.overstreet@gmail.com>
14 Description:
15 Writing to this file resets all the statistics for the device.
16
17 What: /sys/block/<disk>/bcache/cache
18 Date: November 2010
19 Contact: Kent Overstreet <kent.overstreet@gmail.com>
20 Description:
21 For a backing device that has cache, a symlink to
22 the bcache/ dir of that cache.
23
24 What: /sys/block/<disk>/bcache/cache_hits
25 Date: November 2010
26 Contact: Kent Overstreet <kent.overstreet@gmail.com>
27 Description:
28 For backing devices: integer number of full cache hits,
29 counted per bio. A partial cache hit counts as a miss.
30
31 What: /sys/block/<disk>/bcache/cache_misses
32 Date: November 2010
33 Contact: Kent Overstreet <kent.overstreet@gmail.com>
34 Description:
35 For backing devices: integer number of cache misses.
36
37 What: /sys/block/<disk>/bcache/cache_hit_ratio
38 Date: November 2010
39 Contact: Kent Overstreet <kent.overstreet@gmail.com>
40 Description:
41 For backing devices: cache hits as a percentage.
42
43 What: /sys/block/<disk>/bcache/sequential_cutoff
44 Date: November 2010
45 Contact: Kent Overstreet <kent.overstreet@gmail.com>
46 Description:
47 For backing devices: Threshold past which sequential IO will
48 skip the cache. Read and written as bytes in human readable
49 units (i.e. echo 10M > sequntial_cutoff).
50
51 What: /sys/block/<disk>/bcache/bypassed
52 Date: November 2010
53 Contact: Kent Overstreet <kent.overstreet@gmail.com>
54 Description:
55 Sum of all reads and writes that have bypassed the cache (due
56 to the sequential cutoff). Expressed as bytes in human
57 readable units.
58
59 What: /sys/block/<disk>/bcache/writeback
60 Date: November 2010
61 Contact: Kent Overstreet <kent.overstreet@gmail.com>
62 Description:
63 For backing devices: When on, writeback caching is enabled and
64 writes will be buffered in the cache. When off, caching is in
65 writethrough mode; reads and writes will be added to the
66 cache but no write buffering will take place.
67
68 What: /sys/block/<disk>/bcache/writeback_running
69 Date: November 2010
70 Contact: Kent Overstreet <kent.overstreet@gmail.com>
71 Description:
72 For backing devices: when off, dirty data will not be written
73 from the cache to the backing device. The cache will still be
74 used to buffer writes until it is mostly full, at which point
75 writes transparently revert to writethrough mode. Intended only
76 for benchmarking/testing.
77
78 What: /sys/block/<disk>/bcache/writeback_delay
79 Date: November 2010
80 Contact: Kent Overstreet <kent.overstreet@gmail.com>
81 Description:
82 For backing devices: In writeback mode, when dirty data is
83 written to the cache and the cache held no dirty data for that
84 backing device, writeback from cache to backing device starts
85 after this delay, expressed as an integer number of seconds.
86
87 What: /sys/block/<disk>/bcache/writeback_percent
88 Date: November 2010
89 Contact: Kent Overstreet <kent.overstreet@gmail.com>
90 Description:
91 For backing devices: If nonzero, writeback from cache to
92 backing device only takes place when more than this percentage
93 of the cache is used, allowing more write coalescing to take
94 place and reducing total number of writes sent to the backing
95 device. Integer between 0 and 40.
96
97 What: /sys/block/<disk>/bcache/synchronous
98 Date: November 2010
99 Contact: Kent Overstreet <kent.overstreet@gmail.com>
100 Description:
101 For a cache, a boolean that allows synchronous mode to be
102 switched on and off. In synchronous mode all writes are ordered
103 such that the cache can reliably recover from unclean shutdown;
104 if disabled bcache will not generally wait for writes to
105 complete but if the cache is not shut down cleanly all data
106 will be discarded from the cache. Should not be turned off with
107 writeback caching enabled.
108
109 What: /sys/block/<disk>/bcache/discard
110 Date: November 2010
111 Contact: Kent Overstreet <kent.overstreet@gmail.com>
112 Description:
113 For a cache, a boolean allowing discard/TRIM to be turned off
114 or back on if the device supports it.
115
116 What: /sys/block/<disk>/bcache/bucket_size
117 Date: November 2010
118 Contact: Kent Overstreet <kent.overstreet@gmail.com>
119 Description:
120 For a cache, bucket size in human readable units, as set at
121 cache creation time; should match the erase block size of the
122 SSD for optimal performance.
123
124 What: /sys/block/<disk>/bcache/nbuckets
125 Date: November 2010
126 Contact: Kent Overstreet <kent.overstreet@gmail.com>
127 Description:
128 For a cache, the number of usable buckets.
129
130 What: /sys/block/<disk>/bcache/tree_depth
131 Date: November 2010
132 Contact: Kent Overstreet <kent.overstreet@gmail.com>
133 Description:
134 For a cache, height of the btree excluding leaf nodes (i.e. a
135 one node tree will have a depth of 0).
136
137 What: /sys/block/<disk>/bcache/btree_cache_size
138 Date: November 2010
139 Contact: Kent Overstreet <kent.overstreet@gmail.com>
140 Description:
141 Number of btree buckets/nodes that are currently cached in
142 memory; cache dynamically grows and shrinks in response to
143 memory pressure from the rest of the system.
144
145 What: /sys/block/<disk>/bcache/written
146 Date: November 2010
147 Contact: Kent Overstreet <kent.overstreet@gmail.com>
148 Description:
149 For a cache, total amount of data in human readable units
150 written to the cache, excluding all metadata.
151
152 What: /sys/block/<disk>/bcache/btree_written
153 Date: November 2010
154 Contact: Kent Overstreet <kent.overstreet@gmail.com>
155 Description:
156 For a cache, sum of all btree writes in human readable units.
157

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

bcache device lifecycle와 cache 연결

1-22
WhatDateContact전문 번역
/sys/block/<disk>/bcache/unregister2010년 11월Kent Overstreet <kent.overstreet@gmail.com>이 file에 쓰면 backing device 또는 cache가 unregister됩니다. Backing device의 dirty data가 cache에 있었다면 writeback mode를 자동으로 disable하고, device를 unregister하기 전에 모든 dirty data를 flush합니다. Cache는 자기 자신을 unregister하기 전에 연결된 모든 backing device를 unregister합니다.
/sys/block/<disk>/bcache/clear_stats2010년 11월Kent Overstreet <kent.overstreet@gmail.com>이 file에 쓰면 device의 모든 statistics가 reset됩니다.
/sys/block/<disk>/bcache/cache2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Cache가 있는 backing device에서는 해당 cache의 bcache/ directory를 가리키는 symlink입니다.
bcache unregister ordering
Write unregisterDisable writeback when dirtyFlush all dirty dataUnregister backing device
Unregister cacheUnregister associated backing devicesUnregister cache itself
Backing devicecache symlinkCache bcache directory

Dirty backing data와 cache dependency를 정리한 뒤 object를 unregister하는 순서를 보여 준다.

Cache hit statistics와 sequential I/O bypass

24-57
WhatDateContact전문 번역
/sys/block/<disk>/bcache/cache_hits2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Backing device용 attribute입니다. Full cache hit의 정수 개수를 bio 단위로 셉니다. Partial cache hit는 miss로 계산합니다.
/sys/block/<disk>/bcache/cache_misses2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Backing device용 attribute입니다. Cache miss의 정수 개수입니다.
/sys/block/<disk>/bcache/cache_hit_ratio2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Backing device용 attribute입니다. Cache hit를 percentage로 나타냅니다.
/sys/block/<disk>/bcache/sequential_cutoff2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Backing device용 attribute입니다. Sequential I/O가 이 threshold를 넘으면 cache를 건너뜁니다. Human-readable unit의 byte 수로 읽고 씁니다.
/sys/block/<disk>/bcache/bypassed2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Sequential cutoff 때문에 cache를 우회한 모든 read와 write의 합입니다. Human-readable unit의 byte 수로 표현합니다.

원문은 sequential_cutoff 설정 예시를 다음과 같이 제시하며 file 이름을 sequntial_cutoff로 표기합니다.

echo 10M > sequntial_cutoff

Writeback mode, running state와 threshold

59-95
WhatDateContact전문 번역
/sys/block/<disk>/bcache/writeback2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Backing device용 attribute입니다. On이면 writeback caching을 enable하여 write를 cache에 buffer합니다. Off이면 caching이 writethrough mode가 됩니다. Read와 write를 cache에 추가하지만 write buffering은 수행하지 않습니다.
/sys/block/<disk>/bcache/writeback_running2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Backing device용 attribute입니다. Off이면 dirty data를 cache에서 backing device로 쓰지 않습니다. Cache가 대부분 찰 때까지 write buffer로 계속 사용하며, 그 시점부터 write는 투명하게 writethrough mode로 되돌아갑니다. Benchmarking과 testing만을 위한 기능입니다.
/sys/block/<disk>/bcache/writeback_delay2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Backing device용 attribute입니다. Writeback mode에서 dirty data가 cache에 기록되었고 이 backing device용 dirty data가 이전에는 cache에 전혀 없었다면, 이 delay가 지난 뒤 cache에서 backing device로 writeback을 시작합니다. Delay는 정수 seconds로 표현합니다.
/sys/block/<disk>/bcache/writeback_percent2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Backing device용 attribute입니다. 값이 0이 아니면 cache 사용량이 이 percentage보다 많을 때만 cache에서 backing device로 writeback합니다. 더 많은 write coalescing을 허용하고 backing device에 보내는 전체 write 수를 줄입니다. 값은 0부터 40 사이의 정수입니다.
bcache write policy
writeback=onBuffer writes in cacheDirty dataDelay and utilization policyBacking device
writeback=offWritethrough modeCache reads and writesNo write buffering
writeback_running=offKeep buffering until mostly fullTransparent writethrough fallback

Writeback controls가 foreground write buffering과 background dirty-data flush를 서로 다르게 제어한다.

Synchronous mode와 discard/TRIM

97-114
WhatDateContact전문 번역
/sys/block/<disk>/bcache/synchronous2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Cache용 boolean으로 synchronous mode를 켜고 끌 수 있습니다. Synchronous mode에서는 cache가 unclean shutdown에서 안정적으로 recovery할 수 있도록 모든 write의 순서를 정합니다. Disable하면 bcache는 일반적으로 write 완료를 기다리지 않지만 cache가 clean하게 shutdown되지 않았을 때 cache의 모든 data를 버립니다. Writeback caching을 enable한 상태에서는 끄지 말아야 합니다.
/sys/block/<disk>/bcache/discard2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Cache용 boolean입니다. Device가 discard/TRIM을 지원한다면 이 기능을 끄거나 다시 켤 수 있습니다.

Cache bucket, btree와 write accounting

116-156
WhatDateContact전문 번역
/sys/block/<disk>/bcache/bucket_size2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Cache용 attribute입니다. Cache 생성 시 설정한 bucket size를 human-readable unit으로 나타냅니다. 최적의 성능을 위해 SSD의 erase block size와 일치해야 합니다.
/sys/block/<disk>/bcache/nbuckets2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Cache용 attribute입니다. 사용할 수 있는 bucket 수입니다.
/sys/block/<disk>/bcache/tree_depth2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Cache용 attribute입니다. Leaf node를 제외한 btree의 height입니다. 예를 들어 node가 하나인 tree의 depth는 0입니다.
/sys/block/<disk>/bcache/btree_cache_size2010년 11월Kent Overstreet <kent.overstreet@gmail.com>현재 memory에 cache된 btree bucket 또는 node 수입니다. 이 cache는 system 나머지 부분의 memory pressure에 대응하여 동적으로 커지고 줄어듭니다.
/sys/block/<disk>/bcache/written2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Cache용 attribute입니다. Cache에 기록된 data의 total amount를 human-readable unit으로 나타냅니다. 모든 metadata는 제외합니다.
/sys/block/<disk>/bcache/btree_written2010년 11월Kent Overstreet <kent.overstreet@gmail.com>Cache용 attribute입니다. 모든 btree write의 합을 human-readable unit으로 나타냅니다.