Skip to content

Commit d5c8238

Browse files
Davidlohr Buesokdave
authored andcommitted
btrfs: convert data_seqcount to seqcount_mutex_t
By doing so we can associate the sequence counter to the chunk_mutex for lockdep purposes (compiled-out otherwise), the mutex is otherwise used on the write side. Also avoid explicitly disabling preemption around the write region as it will now be done automatically by the seqcount machinery based on the lock type. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 0425e7b commit d5c8238

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

fs/btrfs/volumes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ static struct btrfs_device *__alloc_device(struct btrfs_fs_info *fs_info)
431431

432432
atomic_set(&dev->reada_in_flight, 0);
433433
atomic_set(&dev->dev_stats_ccnt, 0);
434-
btrfs_device_data_ordered_init(dev);
434+
btrfs_device_data_ordered_init(dev, fs_info);
435435
INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
436436
INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
437437
extent_io_tree_init(fs_info, &dev->alloc_state,

fs/btrfs/volumes.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ struct btrfs_io_geometry {
3939
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
4040
#include <linux/seqlock.h>
4141
#define __BTRFS_NEED_DEVICE_DATA_ORDERED
42-
#define btrfs_device_data_ordered_init(device) \
43-
seqcount_init(&device->data_seqcount)
42+
#define btrfs_device_data_ordered_init(device, info) \
43+
seqcount_mutex_init(&device->data_seqcount, &info->chunk_mutex)
4444
#else
45-
#define btrfs_device_data_ordered_init(device) do { } while (0)
45+
#define btrfs_device_data_ordered_init(device, info) do { } while (0)
4646
#endif
4747

4848
#define BTRFS_DEV_STATE_WRITEABLE (0)
@@ -72,7 +72,8 @@ struct btrfs_device {
7272
blk_status_t last_flush_error;
7373

7474
#ifdef __BTRFS_NEED_DEVICE_DATA_ORDERED
75-
seqcount_t data_seqcount;
75+
/* A seqcount_t with associated chunk_mutex (for lockdep) */
76+
seqcount_mutex_t data_seqcount;
7677
#endif
7778

7879
/* the internal btrfs device id */
@@ -163,11 +164,9 @@ btrfs_device_get_##name(const struct btrfs_device *dev) \
163164
static inline void \
164165
btrfs_device_set_##name(struct btrfs_device *dev, u64 size) \
165166
{ \
166-
preempt_disable(); \
167167
write_seqcount_begin(&dev->data_seqcount); \
168168
dev->name = size; \
169169
write_seqcount_end(&dev->data_seqcount); \
170-
preempt_enable(); \
171170
}
172171
#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
173172
#define BTRFS_DEVICE_GETSET_FUNCS(name) \

0 commit comments

Comments
 (0)