btrfs-progs: mkfs: don't autoselect DUP on SSD for metadata anymore

The original idea of not doing DUP on SSD was that the duplicate blocks
get deduplicated again by the driver firmware. This was in 2013, years
ago. Then it was speculative and even nowadays we don't have much
reliable information from vendors what optimizations are done on the
drive level.

After the year there's enough information gathered by user community and
there's no simple answer. Expensive drives are more reliable but less
common, for cheap consumer drive it's vice versa. The characteristics
are described in more detail in manual page btrfs(5) in section "SOLID
STATE DRIVES (SSD)".

The reasoning is based on numerous reports on IRC and technical
difficulty on mkfs side to do the right decision. The default is chosen
to be the safe option and up to user to change that based on informed
decision.

Issue: #319
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-09-28 00:29:53 +02:00
parent 72260bc3b9
commit 65181c273e
3 changed files with 21 additions and 18 deletions

View File

@ -53,15 +53,28 @@ Specify the profile for the metadata block groups.
Valid values are 'raid0', 'raid1', 'raid1c3', 'raid1c4', 'raid5', 'raid6',
'raid10', 'single' or 'dup' (case does not matter).
+
Default on a single device filesystem is 'DUP', unless an SSD is detected, in which
case it will default to 'single'. The detection is based on the value of
`/sys/block/DEV/queue/rotational`, where 'DEV' is the short name of the device.
Default on a single device filesystem is 'DUP' and is recommended for metadata
in general. The duplication might not be necessary in some use cases and it's
up to the user to changed that at mkfs time or later. This depends on hardware
that could potentially deduplicate the blocks again but this cannot be detected
at mkfs time.
+
[NOTE]
.NOTE
====
Up to version 5.14 there was a detection of a SSD device (more precisely
if it's a rotational device, determined by the contents of file
`/sys/block/DEV/queue/rotational`) that used to select 'single'. This has
changed in version 5.15 to be always 'dup'.
Note that the rotational status can be arbitrarily set by the underlying block
device driver and may not reflect the true status (network block device, memory-backed
SCSI devices etc). It's recommended to options '--data/--metadata' to avoid confusion.
+
SCSI devices, real block device behind some additonal device mapper layer,
etc). It's recommended to always set the options '--data/--metadata' to avoid
confusion and unexpected results.
See 'DUP PROFILES ON A SINGLE DEVICE' for more details.
====
+
On multiple devices the default is 'raid1'.

View File

@ -33,7 +33,6 @@
*/
#define BTRFS_MKFS_DEFAULT_DATA_ONE_DEVICE 0 /* SINGLE */
#define BTRFS_MKFS_DEFAULT_META_ONE_DEVICE BTRFS_BLOCK_GROUP_DUP
#define BTRFS_MKFS_DEFAULT_META_ONE_DEVICE_SSD 0 /* SINGLE */
#define BTRFS_MKFS_DEFAULT_DATA_MULTI_DEVICE 0 /* SINGLE */
#define BTRFS_MKFS_DEFAULT_META_MULTI_DEVICE BTRFS_BLOCK_GROUP_RAID1

View File

@ -1131,19 +1131,10 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
u64 tmp;
if (!metadata_profile_opt) {
if (dev_cnt == 1 && ssd && bconf.verbose)
printf("Detected a SSD, turning off metadata "
"duplication. Mkfs with -m dup if you want to "
"force metadata duplication.\n");
if (dev_cnt > 1) {
if (dev_cnt > 1)
tmp = BTRFS_MKFS_DEFAULT_META_MULTI_DEVICE;
} else {
if (ssd)
tmp = BTRFS_MKFS_DEFAULT_META_ONE_DEVICE_SSD;
else
tmp = BTRFS_MKFS_DEFAULT_META_ONE_DEVICE;
}
else
tmp = BTRFS_MKFS_DEFAULT_META_ONE_DEVICE;
metadata_profile = tmp;
}
if (!data_profile_opt) {