mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 06:31:49 +00:00
- fix a 4.6-rc1 bio-based DM 'struct dm_target_io' leak in an error path
- stable@ fix for DM cache metadata's READ_LOCK macros that were incorrectly returning error if the block manager was in read-only mode; also cleanup multi-statement macros to use do {} while(0) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJXEA8BAAoJEMUj8QotnQNauNoH/i5bVVPZTMKA3wzCpziuP08X V5E9nLhd+Lvng05AZLsrTeIdvDfS7eAPQyFkPY9NpvzoJEAL0ft6bjGdaDTH090u Y4mn08BcCwCzaJL41u43TGe3+iRZfUA/W7uu80SSaTuKq7EFeRha+LfyOUCwrNcT P5LEPsl7EKhan3K3+9BrnX3IPG1MwswDAt9Sw0e83cyhFH5Xzy5AkygaSgHSamvf /LJ3Hid8kCbdGseODJQ+sVg957+5H4mpZ3VUaTek/+DurCPpMFCxNQJTv2nxTd4h AiEh+ed/RGzAP8hrZdtQTqKjc6ILiR0tRCtYX9WHDXLklkiJ5ZGKMgKyyrZYrzo= =lzmV -----END PGP SIGNATURE----- Merge tag 'dm-4.6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm Pull device mapper fixes from Mike Snitzer: - fix a 4.6-rc1 bio-based DM 'struct dm_target_io' leak in an error path - stable@ fix for DM cache metadata's READ_LOCK macros that were incorrectly returning error if the block manager was in read-only mode; also cleanup multi-statement macros to use do {} while(0) * tag 'dm-4.6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm cache metadata: fix READ_LOCK macros and cleanup WRITE_LOCK macros dm: fix dm_target_io leak if clone_bio() returns an error
This commit is contained in:
commit
63a1281b65
@ -867,39 +867,55 @@ static int blocks_are_unmapped_or_clean(struct dm_cache_metadata *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define WRITE_LOCK(cmd) \
|
||||
down_write(&cmd->root_lock); \
|
||||
if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { \
|
||||
up_write(&cmd->root_lock); \
|
||||
return -EINVAL; \
|
||||
static bool cmd_write_lock(struct dm_cache_metadata *cmd)
|
||||
{
|
||||
down_write(&cmd->root_lock);
|
||||
if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) {
|
||||
up_write(&cmd->root_lock);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#define WRITE_LOCK_VOID(cmd) \
|
||||
down_write(&cmd->root_lock); \
|
||||
if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { \
|
||||
up_write(&cmd->root_lock); \
|
||||
return; \
|
||||
}
|
||||
#define WRITE_LOCK(cmd) \
|
||||
do { \
|
||||
if (!cmd_write_lock((cmd))) \
|
||||
return -EINVAL; \
|
||||
} while(0)
|
||||
|
||||
#define WRITE_LOCK_VOID(cmd) \
|
||||
do { \
|
||||
if (!cmd_write_lock((cmd))) \
|
||||
return; \
|
||||
} while(0)
|
||||
|
||||
#define WRITE_UNLOCK(cmd) \
|
||||
up_write(&cmd->root_lock)
|
||||
up_write(&(cmd)->root_lock)
|
||||
|
||||
#define READ_LOCK(cmd) \
|
||||
down_read(&cmd->root_lock); \
|
||||
if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { \
|
||||
up_read(&cmd->root_lock); \
|
||||
return -EINVAL; \
|
||||
static bool cmd_read_lock(struct dm_cache_metadata *cmd)
|
||||
{
|
||||
down_write(&cmd->root_lock);
|
||||
if (cmd->fail_io) {
|
||||
up_write(&cmd->root_lock);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#define READ_LOCK_VOID(cmd) \
|
||||
down_read(&cmd->root_lock); \
|
||||
if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { \
|
||||
up_read(&cmd->root_lock); \
|
||||
return; \
|
||||
}
|
||||
#define READ_LOCK(cmd) \
|
||||
do { \
|
||||
if (!cmd_read_lock((cmd))) \
|
||||
return -EINVAL; \
|
||||
} while(0)
|
||||
|
||||
#define READ_LOCK_VOID(cmd) \
|
||||
do { \
|
||||
if (!cmd_read_lock((cmd))) \
|
||||
return; \
|
||||
} while(0)
|
||||
|
||||
#define READ_UNLOCK(cmd) \
|
||||
up_read(&cmd->root_lock)
|
||||
up_read(&(cmd)->root_lock)
|
||||
|
||||
int dm_cache_resize(struct dm_cache_metadata *cmd, dm_cblock_t new_cache_size)
|
||||
{
|
||||
|
@ -1662,8 +1662,10 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
|
||||
tio = alloc_tio(ci, ti, target_bio_nr);
|
||||
tio->len_ptr = len;
|
||||
r = clone_bio(tio, bio, sector, *len);
|
||||
if (r < 0)
|
||||
if (r < 0) {
|
||||
free_tio(ci->md, tio);
|
||||
break;
|
||||
}
|
||||
__map_bio(tio);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user