Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: shrink the size of btrfs_device

There are two main causes of holes inside btrfs_device:

- The single bytes member of last_flush_error
Not only it's a single byte member, but we never really care about the
exact error number.

- The @devt member
Which is placed between two u64 members.

Shrink the size of btrfs_device by:

- Use a single bit flag for flush error
Use BTRFS_DEV_STATE_FLUSH_FAILED so that we no longer need that
dedicated member.

- Move @devt to the hole after dev_stat_values[]

This reduces the size of btrfs_device from 528 to exact 512 bytes for
x86_64.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Qu Wenruo and committed by
David Sterba
4681dbcf 8ecf596e

+12 -11
+3 -3
fs/btrfs/disk-io.c
··· 3834 3834 { 3835 3835 struct bio *bio = &device->flush_bio; 3836 3836 3837 - device->last_flush_error = BLK_STS_OK; 3837 + clear_bit(BTRFS_DEV_STATE_FLUSH_FAILED, &device->dev_state); 3838 3838 3839 3839 bio_init(bio, device->bdev, NULL, 0, 3840 3840 REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH); ··· 3859 3859 wait_for_completion_io(&device->flush_wait); 3860 3860 3861 3861 if (bio->bi_status) { 3862 - device->last_flush_error = bio->bi_status; 3862 + set_bit(BTRFS_DEV_STATE_FLUSH_FAILED, &device->dev_state); 3863 3863 btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_FLUSH_ERRS); 3864 3864 return true; 3865 3865 } ··· 3909 3909 } 3910 3910 3911 3911 /* 3912 - * Checks last_flush_error of disks in order to determine the device 3912 + * Checks flush failure of disks in order to determine the device 3913 3913 * state. 3914 3914 */ 3915 3915 if (unlikely(errors_wait && !btrfs_check_rw_degradable(info, NULL)))
+2 -2
fs/btrfs/volumes.c
··· 1169 1169 * any transaction and set the error state, guaranteeing no commits of 1170 1170 * unsafe super blocks. 1171 1171 */ 1172 - device->last_flush_error = 0; 1172 + clear_bit(BTRFS_DEV_STATE_FLUSH_FAILED, &device->dev_state); 1173 1173 1174 1174 /* Verify the device is back in a pristine state */ 1175 1175 WARN_ON(test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state)); ··· 7375 7375 7376 7376 if (!dev || !dev->bdev || 7377 7377 test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state) || 7378 - dev->last_flush_error) 7378 + test_bit(BTRFS_DEV_STATE_FLUSH_FAILED, &dev->dev_state)) 7379 7379 missing++; 7380 7380 else if (failing_dev && failing_dev == dev) 7381 7381 missing++;
+7 -6
fs/btrfs/volumes.h
··· 99 99 #define BTRFS_DEV_STATE_REPLACE_TGT (3) 100 100 #define BTRFS_DEV_STATE_FLUSH_SENT (4) 101 101 #define BTRFS_DEV_STATE_NO_READA (5) 102 + #define BTRFS_DEV_STATE_FLUSH_FAILED (6) 102 103 103 104 /* Set when the device item is found in chunk tree, used to catch unexpected registered device. */ 104 105 #define BTRFS_DEV_STATE_ITEM_FOUND (7) ··· 126 125 127 126 struct btrfs_zoned_device_info *zone_info; 128 127 129 - /* 130 - * Device's major-minor number. Must be set even if the device is not 131 - * opened (bdev == NULL), unless the device is missing. 132 - */ 133 - dev_t devt; 134 128 unsigned long dev_state; 135 - blk_status_t last_flush_error; 136 129 137 130 #ifdef __BTRFS_NEED_DEVICE_DATA_ORDERED 138 131 seqcount_t data_seqcount; ··· 189 194 /* Counter to record the change of device stats */ 190 195 atomic_t dev_stats_ccnt; 191 196 atomic_t dev_stat_values[BTRFS_DEV_STAT_VALUES_MAX]; 197 + 198 + /* 199 + * Device's major-minor number. Must be set even if the device is not 200 + * opened (bdev == NULL), unless the device is missing. 201 + */ 202 + dev_t devt; 192 203 193 204 struct extent_io_tree alloc_state; 194 205