]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dm cache metadata: fix READ_LOCK macros and cleanup WRITE_LOCK macros
authorMike Snitzer <snitzer@redhat.com>
Tue, 12 Apr 2016 16:14:46 +0000 (12:14 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 May 2016 21:48:59 +0000 (14:48 -0700)
commitbe5fb2757b1855f55e05e6970d2808ac280ceddd
tree16992ea4ec7dbf6edf4ad85db05d16b95c7b7cda
parentb1fb1321ed52927cfddc532af376d16e4abab866
dm cache metadata: fix READ_LOCK macros and cleanup WRITE_LOCK macros

commit 9567366fefddeaea4ed1d713270535d93a3b3c76 upstream.

The READ_LOCK macro was incorrectly returning -EINVAL if
dm_bm_is_read_only() was true -- it will always be true once the cache
metadata transitions to read-only by dm_cache_metadata_set_read_only().

Wrap READ_LOCK and WRITE_LOCK multi-statement macros in do {} while(0).
Also, all accesses of the 'cmd' argument passed to these related macros
are now encapsulated in parenthesis.

A follow-up patch can be developed to eliminate the use of macros in
favor of pure C code.  Avoiding that now given that this needs to apply
to stable@.

Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Fixes: d14fcf3dd79 ("dm cache: make sure every metadata function checks fail_io")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-cache-metadata.c