sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}(hhparenthuba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget&/translations/zh_CN/admin-guide/bcachemodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}(hhhh2ubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/zh_TW/admin-guide/bcachemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}(hhhhFubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/it_IT/admin-guide/bcachemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}(hhhhZubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/ja_JP/admin-guide/bcachemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}(hhhhnubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/ko_KR/admin-guide/bcachemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}(hhhhubah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/sp_SP/admin-guide/bcachemodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hA block layer cache (bcache)h]hA block layer cache (bcache)}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh@/var/lib/git/docbuild/linux/Documentation/admin-guide/bcache.rsthKubh paragraph)}(hzSay you've got a big slow raid 6, and an ssd or three. Wouldn't it be nice if you could use them as cache... Hence bcache.h]h~Say you’ve got a big slow raid 6, and an ssd or three. Wouldn’t it be nice if you could use them as cache... Hence bcache.}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhdefinition_list)}(hhh](hdefinition_list_item)}(hBThe bcache wiki can be found at: https://bcache.evilpiepirate.org h](hterm)}(h The bcache wiki can be found at:h]h The bcache wiki can be found at:}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhubh definition)}(hhh]h)}(h https://bcache.evilpiepirate.orgh]h reference)}(hhh]h https://bcache.evilpiepirate.org}(hhhhhhhNhNubah}(h]h ]h"]h$]h&]refurihuh1hhhubah}(h]h ]h"]h$]h&]uh1hhhhK hhubah}(h]h ]h"]h$]h&]uh1hhhubeh}(h]h ]h"]h$]h&]uh1hhhhK hhubh)}(huThis is the git repository of bcache-tools: https://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-tools.git/ h](h)}(h+This is the git repository of bcache-tools:h]h+This is the git repository of bcache-tools:}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hj ubh)}(hhh]h)}(hHhttps://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-tools.git/h]h)}(hj$h]hHhttps://git.kernel.org/pub/scm/linux/kernel/git/colyli/bcache-tools.git/}(hhhj&hhhNhNubah}(h]h ]h"]h$]h&]refurij$uh1hhj"ubah}(h]h ]h"]h$]h&]uh1hhhhK hjubah}(h]h ]h"]h$]h&]uh1hhj ubeh}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hThe latest bcache kernel code can be found from mainline Linux kernel: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ h](h)}(hFThe latest bcache kernel code can be found from mainline Linux kernel:h]hFThe latest bcache kernel code can be found from mainline Linux kernel:}(hjLhjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjFubh)}(hhh]h)}(hChttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/h]h)}(hj]h]hChttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/}(hhhj_hhhNhNubah}(h]h ]h"]h$]h&]refurij]uh1hhj[ubah}(h]h ]h"]h$]h&]uh1hhhhKhjXubah}(h]h ]h"]h$]h&]uh1hhjFubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h]h ]h"]h$]h&]uh1hhhhhhhhNubh)}(hXkIt's designed around the performance characteristics of SSDs - it only allocates in erase block sized buckets, and it uses a hybrid btree/log to track cached extents (which can be anywhere from a single sector to the bucket size). It's designed to avoid random writes at all costs; it fills up an erase block sequentially, then issues a discard before reusing it.h]hXoIt’s designed around the performance characteristics of SSDs - it only allocates in erase block sized buckets, and it uses a hybrid btree/log to track cached extents (which can be anywhere from a single sector to the bucket size). It’s designed to avoid random writes at all costs; it fills up an erase block sequentially, then issues a discard before reusing it.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXiBoth writethrough and writeback caching are supported. Writeback defaults to off, but can be switched on and off arbitrarily at runtime. Bcache goes to great lengths to protect your data - it reliably handles unclean shutdown. (It doesn't even have a notion of a clean shutdown; bcache simply doesn't return writes as completed until they're on stable storage).h]hXoBoth writethrough and writeback caching are supported. Writeback defaults to off, but can be switched on and off arbitrarily at runtime. Bcache goes to great lengths to protect your data - it reliably handles unclean shutdown. (It doesn’t even have a notion of a clean shutdown; bcache simply doesn’t return writes as completed until they’re on stable storage).}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hWriteback caching can use most of the cache for buffering writes - writing dirty data to the backing device is always done sequentially, scanning from the start to the end of the index.h]hWriteback caching can use most of the cache for buffering writes - writing dirty data to the backing device is always done sequentially, scanning from the start to the end of the index.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXSince random IO is what SSDs excel at, there generally won't be much benefit to caching large sequential IO. Bcache detects sequential IO and skips it; it also keeps a rolling average of the IO sizes per task, and as long as the average is above the cutoff it will skip all IO from that task - instead of caching the first 512k after every seek. Backups and large file copies should thus entirely bypass the cache.h]hXSince random IO is what SSDs excel at, there generally won’t be much benefit to caching large sequential IO. Bcache detects sequential IO and skips it; it also keeps a rolling average of the IO sizes per task, and as long as the average is above the cutoff it will skip all IO from that task - instead of caching the first 512k after every seek. Backups and large file copies should thus entirely bypass the cache.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK!hhhhubh)}(hXFIn the event of a data IO error on the flash it will try to recover by reading from disk or invalidating cache entries. For unrecoverable errors (meta data or dirty data), caching is automatically disabled; if dirty data was present in the cache it first disables writeback caching and waits for all dirty data to be flushed.h]hXFIn the event of a data IO error on the flash it will try to recover by reading from disk or invalidating cache entries. For unrecoverable errors (meta data or dirty data), caching is automatically disabled; if dirty data was present in the cache it first disables writeback caching and waits for all dirty data to be flushed.}(hjhjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hhhhubh)}(hGetting started: You'll need bcache util from the bcache-tools repository. Both the cache device and backing device must be formatted before use::h]hGetting started: You’ll need bcache util from the bcache-tools repository. Both the cache device and backing device must be formatted before use:}(hGetting started: You'll need bcache util from the bcache-tools repository. Both the cache device and backing device must be formatted before use:hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hhhhubh literal_block)}(h/bcache make -B /dev/sdb bcache make -C /dev/sdch]h/bcache make -B /dev/sdb bcache make -C /dev/sdc}(hhhjubah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhK2hhhhubh)}(h`bcache make` has the ability to format multiple devices at the same time - if you format your backing devices and cache device at the same time, you won't have to manually attach::h](htitle_reference)}(h `bcache make`h]h bcache make}(hhhjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh has the ability to format multiple devices at the same time - if you format your backing devices and cache device at the same time, you won’t have to manually attach:}(h has the ability to format multiple devices at the same time - if you format your backing devices and cache device at the same time, you won't have to manually attach:hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK5hhhhubj)}(h,bcache make -B /dev/sda /dev/sdb -C /dev/sdch]h,bcache make -B /dev/sda /dev/sdb -C /dev/sdc}(hhhj ubah}(h]h ]h"]h$]h&]jjuh1jhhhK9hhhhubh)}(hIf your bcache-tools is not updated to latest version and does not have the unified `bcache` utility, you may use the legacy `make-bcache` utility to format bcache device with same -B and -C parameters.h](hTIf your bcache-tools is not updated to latest version and does not have the unified }(hTIf your bcache-tools is not updated to latest version and does not have the unified hjhhhNhNubj)}(h`bcache`h]hbcache}(hhhj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh! utility, you may use the legacy }(h! utility, you may use the legacy hjhhhNhNubj)}(h `make-bcache`h]h make-bcache}(hhhj5hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh@ utility to format bcache device with same -B and -C parameters.}(h@ utility to format bcache device with same -B and -C parameters.hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK;hhhhubh)}(hbcache-tools now ships udev rules, and bcache devices are known to the kernel immediately. Without udev, you can manually register devices like this::h]hbcache-tools now ships udev rules, and bcache devices are known to the kernel immediately. Without udev, you can manually register devices like this:}(hbcache-tools now ships udev rules, and bcache devices are known to the kernel immediately. Without udev, you can manually register devices like this:hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK?hhhhubj)}(hOecho /dev/sdb > /sys/fs/bcache/register echo /dev/sdc > /sys/fs/bcache/registerh]hOecho /dev/sdb > /sys/fs/bcache/register echo /dev/sdc > /sys/fs/bcache/register}(hhhj]ubah}(h]h ]h"]h$]h&]jjuh1jhhhKBhhhhubh)}(hXRegistering the backing device makes the bcache device show up in /dev; you can now format it and use it as normal. But the first time using a new bcache device, it'll be running in passthrough mode until you attach it to a cache. If you are thinking about using bcache later, it is recommended to setup all your slow devices as bcache backing devices without a cache, and you can choose to add a caching device later. See 'ATTACHING' section below.h]hXRegistering the backing device makes the bcache device show up in /dev; you can now format it and use it as normal. But the first time using a new bcache device, it’ll be running in passthrough mode until you attach it to a cache. If you are thinking about using bcache later, it is recommended to setup all your slow devices as bcache backing devices without a cache, and you can choose to add a caching device later. See ‘ATTACHING’ section below.}(hjmhjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKEhhhhubh)}(hThe devices show up as::h]hThe devices show up as:}(hThe devices show up as:hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKMhhhhubj)}(h/dev/bcacheh]h/dev/bcache}(hhhjubah}(h]h ]h"]h$]h&]jjuh1jhhhKOhhhhubh)}(hAs well as (with udev)::h]hAs well as (with udev):}(hAs well as (with udev):hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhhhhubj)}(h7/dev/bcache/by-uuid/ /dev/bcache/by-label/