mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 08:46:46 +00:00
Btrfs: autodetect SSD devices
During mount, btrfs will check the queue nonrot flag for all the devices found in the FS. If they are all non-rotating, SSD mode is enabled by default. If the FS was mounted with -o nossd, the non-rotating flag is ignored. Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
parent
451d7585a8
commit
c289811cc0
5 changed files with 24 additions and 0 deletions
|
@ -1101,6 +1101,7 @@ struct btrfs_root {
|
||||||
#define BTRFS_MOUNT_NOTREELOG (1 << 6)
|
#define BTRFS_MOUNT_NOTREELOG (1 << 6)
|
||||||
#define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7)
|
#define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7)
|
||||||
#define BTRFS_MOUNT_SSD_SPREAD (1 << 8)
|
#define BTRFS_MOUNT_SSD_SPREAD (1 << 8)
|
||||||
|
#define BTRFS_MOUNT_NOSSD (1 << 9)
|
||||||
|
|
||||||
#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
|
#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
|
||||||
#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
|
#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
|
||||||
|
|
|
@ -1850,6 +1850,14 @@ struct btrfs_root *open_ctree(struct super_block *sb,
|
||||||
if (IS_ERR(fs_info->transaction_kthread))
|
if (IS_ERR(fs_info->transaction_kthread))
|
||||||
goto fail_cleaner;
|
goto fail_cleaner;
|
||||||
|
|
||||||
|
if (!btrfs_test_opt(tree_root, SSD) &&
|
||||||
|
!btrfs_test_opt(tree_root, NOSSD) &&
|
||||||
|
!fs_info->fs_devices->rotating) {
|
||||||
|
printk(KERN_INFO "Btrfs detected SSD devices, enabling SSD "
|
||||||
|
"mode\n");
|
||||||
|
btrfs_set_opt(fs_info->mount_opt, SSD);
|
||||||
|
}
|
||||||
|
|
||||||
if (btrfs_super_log_root(disk_super) != 0) {
|
if (btrfs_super_log_root(disk_super) != 0) {
|
||||||
u64 bytenr = btrfs_super_log_root(disk_super);
|
u64 bytenr = btrfs_super_log_root(disk_super);
|
||||||
|
|
||||||
|
@ -1893,6 +1901,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
|
||||||
fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, &location);
|
fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, &location);
|
||||||
if (!fs_info->fs_root)
|
if (!fs_info->fs_root)
|
||||||
goto fail_trans_kthread;
|
goto fail_trans_kthread;
|
||||||
|
|
||||||
return tree_root;
|
return tree_root;
|
||||||
|
|
||||||
fail_trans_kthread:
|
fail_trans_kthread:
|
||||||
|
|
|
@ -184,6 +184,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
|
||||||
case Opt_nossd:
|
case Opt_nossd:
|
||||||
printk(KERN_INFO "btrfs: not using ssd allocation "
|
printk(KERN_INFO "btrfs: not using ssd allocation "
|
||||||
"scheme\n");
|
"scheme\n");
|
||||||
|
btrfs_set_opt(info->mount_opt, NOSSD);
|
||||||
btrfs_clear_opt(info->mount_opt, SSD);
|
btrfs_clear_opt(info->mount_opt, SSD);
|
||||||
btrfs_clear_opt(info->mount_opt, SSD_SPREAD);
|
btrfs_clear_opt(info->mount_opt, SSD_SPREAD);
|
||||||
break;
|
break;
|
||||||
|
@ -438,6 +439,8 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
|
||||||
seq_printf(seq, ",thread_pool=%d", info->thread_pool_size);
|
seq_printf(seq, ",thread_pool=%d", info->thread_pool_size);
|
||||||
if (btrfs_test_opt(root, COMPRESS))
|
if (btrfs_test_opt(root, COMPRESS))
|
||||||
seq_puts(seq, ",compress");
|
seq_puts(seq, ",compress");
|
||||||
|
if (btrfs_test_opt(root, NOSSD))
|
||||||
|
seq_puts(seq, ",nossd");
|
||||||
if (btrfs_test_opt(root, SSD_SPREAD))
|
if (btrfs_test_opt(root, SSD_SPREAD))
|
||||||
seq_puts(seq, ",ssd_spread");
|
seq_puts(seq, ",ssd_spread");
|
||||||
else if (btrfs_test_opt(root, SSD))
|
else if (btrfs_test_opt(root, SSD))
|
||||||
|
|
|
@ -605,6 +605,9 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
|
||||||
device->in_fs_metadata = 0;
|
device->in_fs_metadata = 0;
|
||||||
device->mode = flags;
|
device->mode = flags;
|
||||||
|
|
||||||
|
if (!blk_queue_nonrot(bdev_get_queue(bdev)))
|
||||||
|
fs_devices->rotating = 1;
|
||||||
|
|
||||||
fs_devices->open_devices++;
|
fs_devices->open_devices++;
|
||||||
if (device->writeable) {
|
if (device->writeable) {
|
||||||
fs_devices->rw_devices++;
|
fs_devices->rw_devices++;
|
||||||
|
@ -1473,6 +1476,9 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
|
||||||
root->fs_info->fs_devices->rw_devices++;
|
root->fs_info->fs_devices->rw_devices++;
|
||||||
root->fs_info->fs_devices->total_rw_bytes += device->total_bytes;
|
root->fs_info->fs_devices->total_rw_bytes += device->total_bytes;
|
||||||
|
|
||||||
|
if (!blk_queue_nonrot(bdev_get_queue(bdev)))
|
||||||
|
root->fs_info->fs_devices->rotating = 1;
|
||||||
|
|
||||||
total_bytes = btrfs_super_total_bytes(&root->fs_info->super_copy);
|
total_bytes = btrfs_super_total_bytes(&root->fs_info->super_copy);
|
||||||
btrfs_set_super_total_bytes(&root->fs_info->super_copy,
|
btrfs_set_super_total_bytes(&root->fs_info->super_copy,
|
||||||
total_bytes + device->total_bytes);
|
total_bytes + device->total_bytes);
|
||||||
|
|
|
@ -107,6 +107,11 @@ struct btrfs_fs_devices {
|
||||||
int seeding;
|
int seeding;
|
||||||
|
|
||||||
int opened;
|
int opened;
|
||||||
|
|
||||||
|
/* set when we find or add a device that doesn't have the
|
||||||
|
* nonrot flag set
|
||||||
|
*/
|
||||||
|
int rotating;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct btrfs_bio_stripe {
|
struct btrfs_bio_stripe {
|
||||||
|
|
Loading…
Reference in a new issue