Skip to content

Commit aad5b23

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
dm: fix dm_io and dm_target_io flags race condition on Alpha
Early alpha processors cannot write a single byte or short; they read 8 bytes, modify the value in registers and write back 8 bytes. This could cause race condition in the structure dm_io - if the fields flags and io_count are modified simultaneously. Fix this bug by using 32-bit flags if we are on Alpha and if we are compiling for a processor that doesn't have the byte-word-extension. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Fixes: bd4a6dd ("dm: reduce size of dm_io and dm_target_io structs") [snitzer: Jens allowed this change since Mikulas owns a relevant Alpha!] Acked-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent cc09e8a commit aad5b23

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/md/dm-core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ struct dm_table {
210210
#define DM_TIO_MAGIC 28714
211211
struct dm_target_io {
212212
unsigned short magic;
213-
unsigned short flags;
213+
blk_short_t flags;
214214
unsigned int target_bio_nr;
215215
struct dm_io *io;
216216
struct dm_target *ti;
@@ -244,7 +244,7 @@ static inline void dm_tio_set_flag(struct dm_target_io *tio, unsigned int bit)
244244
#define DM_IO_MAGIC 19577
245245
struct dm_io {
246246
unsigned short magic;
247-
unsigned short flags;
247+
blk_short_t flags;
248248
atomic_t io_count;
249249
struct mapped_device *md;
250250
struct bio *orig_bio;

include/linux/blk_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ struct block_device {
8585
*/
8686
#if defined(CONFIG_ALPHA) && !defined(__alpha_bwx__)
8787
typedef u32 __bitwise blk_status_t;
88+
typedef u32 blk_short_t;
8889
#else
8990
typedef u8 __bitwise blk_status_t;
91+
typedef u16 blk_short_t;
9092
#endif
9193
#define BLK_STS_OK 0
9294
#define BLK_STS_NOTSUPP ((__force blk_status_t)1)

0 commit comments

Comments
 (0)