Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebbede42 authored by Anand Jain's avatar Anand Jain Committed by David Sterba
Browse files

btrfs: cleanup device states define BTRFS_DEV_STATE_WRITEABLE



Currently device state is being managed by each individual int
variable such as struct btrfs_device::writeable. Instead of that
declare device state BTRFS_DEV_STATE_WRITEABLE and use the
bit operations.

Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
[ whitespace adjustments ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3c958bd2
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -3393,7 +3393,8 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
			continue;
		if (!dev->bdev)
			continue;
		if (!dev->in_fs_metadata || !dev->writeable)
		if (!dev->in_fs_metadata ||
		    !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
			continue;

		write_dev_flush(dev);
@@ -3408,7 +3409,8 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
			errors_wait++;
			continue;
		}
		if (!dev->in_fs_metadata || !dev->writeable)
		if (!dev->in_fs_metadata ||
		    !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
			continue;

		ret = wait_dev_flush(dev);
@@ -3505,7 +3507,8 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
			total_errors++;
			continue;
		}
		if (!dev->in_fs_metadata || !dev->writeable)
		if (!dev->in_fs_metadata ||
		    !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
			continue;

		btrfs_set_stack_device_generation(dev_item, 0);
@@ -3544,7 +3547,8 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
	list_for_each_entry(dev, head, dev_list) {
		if (!dev->bdev)
			continue;
		if (!dev->in_fs_metadata || !dev->writeable)
		if (!dev->in_fs_metadata ||
		    !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
			continue;

		ret = wait_dev_supers(dev, max_mirrors);
+1 −1
Original line number Diff line number Diff line
@@ -10878,7 +10878,7 @@ static int btrfs_trim_free_extents(struct btrfs_device *device,
	*trimmed = 0;

	/* Not writeable = nothing to do. */
	if (!device->writeable)
	if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state))
		return 0;

	/* No free space = nothing to do. */
+2 −1
Original line number Diff line number Diff line
@@ -2026,7 +2026,8 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
	bio->bi_iter.bi_sector = sector;
	dev = bbio->stripes[bbio->mirror_num - 1].dev;
	btrfs_put_bbio(bbio);
	if (!dev || !dev->bdev || !dev->writeable) {
	if (!dev || !dev->bdev ||
	    !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) {
		btrfs_bio_counter_dec(fs_info);
		bio_put(bio);
		return -EIO;
+1 −1
Original line number Diff line number Diff line
@@ -1503,7 +1503,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
		goto out_free;
	}

	if (!device->writeable) {
	if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {
		btrfs_info(fs_info,
			   "resizer unable to apply on readonly device %llu",
		       devid);
+2 −1
Original line number Diff line number Diff line
@@ -4117,7 +4117,8 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
		return -ENODEV;
	}

	if (!is_dev_replace && !readonly && !dev->writeable) {
	if (!is_dev_replace && !readonly &&
	    !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) {
		mutex_unlock(&fs_info->fs_devices->device_list_mutex);
		rcu_read_lock();
		name = rcu_dereference(dev->name);
Loading