All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] btrfs: convert volume rotating flag into bitmap
@ 2018-06-04 15:00 Anand Jain
  2018-06-04 15:00 ` [PATCH 2/3] btrfs: convert volume seeding " Anand Jain
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Anand Jain @ 2018-06-04 15:00 UTC (permalink / raw)
  To: linux-btrfs

Add bitmap btrfs_fs_devices::volume_state to maintain the volume states and
flags. This patch in perticular converts btrfs_fs_devices::rotating into
flag BTRFS_VOLUME_STATE_ROTATING.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/disk-io.c |  3 ++-
 fs/btrfs/volumes.c |  7 ++++---
 fs/btrfs/volumes.h | 15 ++++++++++-----
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 002d20b3ed61..b3c9e1f1a11d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3146,7 +3146,8 @@ int open_ctree(struct super_block *sb,
 		goto fail_cleaner;
 
 	if (!btrfs_test_opt(fs_info, NOSSD) &&
-	    !fs_info->fs_devices->rotating) {
+	    !test_bit(BTRFS_VOLUME_STATE_ROTATING,
+		      &fs_info->fs_devices->volume_state)) {
 		btrfs_set_and_info(fs_info, SSD, "enabling ssd optimizations");
 	}
 
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 16c320a7661d..0513ecd694e6 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -726,7 +726,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
 
 	q = bdev_get_queue(bdev);
 	if (!blk_queue_nonrot(q))
-		fs_devices->rotating = 1;
+		set_bit(BTRFS_VOLUME_STATE_ROTATING, &fs_devices->volume_state);
 
 	device->bdev = bdev;
 	clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);
@@ -2328,7 +2328,7 @@ static int btrfs_prepare_sprout(struct btrfs_fs_info *fs_info)
 	fs_devices->num_devices = 0;
 	fs_devices->open_devices = 0;
 	fs_devices->missing_devices = 0;
-	fs_devices->rotating = 0;
+	clear_bit(BTRFS_VOLUME_STATE_ROTATING, &fs_devices->volume_state);
 	fs_devices->seed = seed_devices;
 
 	generate_random_uuid(fs_devices->fsid);
@@ -2524,7 +2524,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 	atomic64_add(device->total_bytes, &fs_info->free_chunk_space);
 
 	if (!blk_queue_nonrot(q))
-		fs_info->fs_devices->rotating = 1;
+		set_bit(BTRFS_VOLUME_STATE_ROTATING,
+			&fs_info->fs_devices->volume_state);
 
 	tmp = btrfs_super_total_bytes(fs_info->super_copy);
 	btrfs_set_super_total_bytes(fs_info->super_copy,
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 5139ec8daf4c..6bedfd0e918f 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -206,6 +206,14 @@ BTRFS_DEVICE_GETSET_FUNCS(total_bytes);
 BTRFS_DEVICE_GETSET_FUNCS(disk_total_bytes);
 BTRFS_DEVICE_GETSET_FUNCS(bytes_used);
 
+/*
+ * btrfs_fs_devices::volume_state bitmap
+ */
+/*
+ * Set when we find or add a device that doesn't have the nonrot flag set
+ */
+#define BTRFS_VOLUME_STATE_ROTATING	(0)
+
 struct btrfs_fs_devices {
 	u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */
 	struct list_head fs_list;
@@ -232,15 +240,12 @@ struct btrfs_fs_devices {
 	struct list_head alloc_list;
 
 	struct btrfs_fs_devices *seed;
+
+	unsigned long volume_state;
 	int seeding;
 
 	int opened;
 
-	/* set when we find or add a device that doesn't have the
-	 * nonrot flag set
-	 */
-	int rotating;
-
 	struct btrfs_fs_info *fs_info;
 	/* sysfs kobjects */
 	struct kobject fsid_kobj;
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-06-30  2:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-04 15:00 [PATCH 1/3] btrfs: convert volume rotating flag into bitmap Anand Jain
2018-06-04 15:00 ` [PATCH 2/3] btrfs: convert volume seeding " Anand Jain
2018-06-04 15:00 ` [PATCH 3/3] btrfs: fix race between mkfs and mount Anand Jain
2018-06-07 16:39   ` David Sterba
2018-06-19 13:53     ` David Sterba
2018-06-26  6:25       ` Anand Jain
2018-06-26 12:19         ` David Sterba
2018-06-26 14:42           ` Anand Jain
2018-06-29 12:06             ` David Sterba
2018-06-30  2:16               ` Anand Jain
2018-06-20 14:06   ` David Sterba
2018-06-26  6:38     ` Anand Jain
2018-06-20 14:01 ` [PATCH 1/3] btrfs: convert volume rotating flag into bitmap David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.