aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-06-10 09:51:32 -0400
committerChris Mason <chris.mason@oracle.com>2009-06-10 11:29:52 -0400
commitc289811cc096c57ff35550ee8132793a4f9b5b59 (patch)
tree47599d47419911c8365e0350e286dece1d5e48dd /fs
parent451d7585a8bb1b9bec0d676ce3dece1923164e55 (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/disk-io.c9
-rw-r--r--fs/btrfs/super.c3
-rw-r--r--fs/btrfs/volumes.c6
-rw-r--r--fs/btrfs/volumes.h5
5 files changed, 24 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b9d8788b299e..5fa7d7d287a4 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1101,6 +1101,7 @@ struct btrfs_root {
1101#define BTRFS_MOUNT_NOTREELOG (1 << 6) 1101#define BTRFS_MOUNT_NOTREELOG (1 << 6)
1102#define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7) 1102#define BTRFS_MOUNT_FLUSHONCOMMIT (1 << 7)
1103#define BTRFS_MOUNT_SSD_SPREAD (1 << 8) 1103#define BTRFS_MOUNT_SSD_SPREAD (1 << 8)
1104#define BTRFS_MOUNT_NOSSD (1 << 9)
1104 1105
1105#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) 1106#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1106#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) 1107#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index e572cf478a5d..f4dfbb7ab496 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1850,6 +1850,14 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1850 if (IS_ERR(fs_info->transaction_kthread)) 1850 if (IS_ERR(fs_info->transaction_kthread))
1851 goto fail_cleaner; 1851 goto fail_cleaner;
1852 1852
1853 if (!btrfs_test_opt(tree_root, SSD) &&
1854 !btrfs_test_opt(tree_root, NOSSD) &&
1855 !fs_info->fs_devices->rotating) {
1856 printk(KERN_INFO "Btrfs detected SSD devices, enabling SSD "
1857 "mode\n");
1858 btrfs_set_opt(fs_info->mount_opt, SSD);
1859 }
1860
1853 if (btrfs_super_log_root(disk_super) != 0) { 1861 if (btrfs_super_log_root(disk_super) != 0) {
1854 u64 bytenr = btrfs_super_log_root(disk_super); 1862 u64 bytenr = btrfs_super_log_root(disk_super);
1855 1863
@@ -1893,6 +1901,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1893 fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, &location); 1901 fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, &location);
1894 if (!fs_info->fs_root) 1902 if (!fs_info->fs_root)
1895 goto fail_trans_kthread; 1903 goto fail_trans_kthread;
1904
1896 return tree_root; 1905 return tree_root;
1897 1906
1898fail_trans_kthread: 1907fail_trans_kthread:
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 7f5b2889949a..3427db28f6fe 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -184,6 +184,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
184 case Opt_nossd: 184 case Opt_nossd:
185 printk(KERN_INFO "btrfs: not using ssd allocation " 185 printk(KERN_INFO "btrfs: not using ssd allocation "
186 "scheme\n"); 186 "scheme\n");
187 btrfs_set_opt(info->mount_opt, NOSSD);
187 btrfs_clear_opt(info->mount_opt, SSD); 188 btrfs_clear_opt(info->mount_opt, SSD);
188 btrfs_clear_opt(info->mount_opt, SSD_SPREAD); 189 btrfs_clear_opt(info->mount_opt, SSD_SPREAD);
189 break; 190 break;
@@ -438,6 +439,8 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
438 seq_printf(seq, ",thread_pool=%d", info->thread_pool_size); 439 seq_printf(seq, ",thread_pool=%d", info->thread_pool_size);
439 if (btrfs_test_opt(root, COMPRESS)) 440 if (btrfs_test_opt(root, COMPRESS))
440 seq_puts(seq, ",compress"); 441 seq_puts(seq, ",compress");
442 if (btrfs_test_opt(root, NOSSD))
443 seq_puts(seq, ",nossd");
441 if (btrfs_test_opt(root, SSD_SPREAD)) 444 if (btrfs_test_opt(root, SSD_SPREAD))
442 seq_puts(seq, ",ssd_spread"); 445 seq_puts(seq, ",ssd_spread");
443 else if (btrfs_test_opt(root, SSD)) 446 else if (btrfs_test_opt(root, SSD))
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 27d5f37b845f..3f4a5932eac9 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -605,6 +605,9 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
605 device->in_fs_metadata = 0; 605 device->in_fs_metadata = 0;
606 device->mode = flags; 606 device->mode = flags;
607 607
608 if (!blk_queue_nonrot(bdev_get_queue(bdev)))
609 fs_devices->rotating = 1;
610
608 fs_devices->open_devices++; 611 fs_devices->open_devices++;
609 if (device->writeable) { 612 if (device->writeable) {
610 fs_devices->rw_devices++; 613 fs_devices->rw_devices++;
@@ -1473,6 +1476,9 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1473 root->fs_info->fs_devices->rw_devices++; 1476 root->fs_info->fs_devices->rw_devices++;
1474 root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; 1477 root->fs_info->fs_devices->total_rw_bytes += device->total_bytes;
1475 1478
1479 if (!blk_queue_nonrot(bdev_get_queue(bdev)))
1480 root->fs_info->fs_devices->rotating = 1;
1481
1476 total_bytes = btrfs_super_total_bytes(&root->fs_info->super_copy); 1482 total_bytes = btrfs_super_total_bytes(&root->fs_info->super_copy);
1477 btrfs_set_super_total_bytes(&root->fs_info->super_copy, 1483 btrfs_set_super_total_bytes(&root->fs_info->super_copy,
1478 total_bytes + device->total_bytes); 1484 total_bytes + device->total_bytes);
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 5c3ff6d02fd7..3c1f7310421e 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -107,6 +107,11 @@ struct btrfs_fs_devices {
107 int seeding; 107 int seeding;
108 108
109 int opened; 109 int opened;
110
111 /* set when we find or add a device that doesn't have the
112 * nonrot flag set
113 */
114 int rotating;
110}; 115};
111 116
112struct btrfs_bio_stripe { 117struct btrfs_bio_stripe {