[dm-devel] [PATCH] dm thin: make const array descs static
Don't populate the read-only const array ramp_base on the stack but instead make it static. Add in a const to clean up checkpatch warning too since the data and the pointer are const. Also makes the object code a little smaller. Signed-off-by: Colin Ian King --- drivers/md/dm-thin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index e76c96c760a9..d228177fdf35 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -293,7 +293,7 @@ static enum pool_mode get_pool_mode(struct pool *pool) static void notify_of_pool_mode_change(struct pool *pool) { - const char *descs[] = { + static const char * const descs[] = { "write", "out-of-data-space", "read-only", -- 2.37.3 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
[dm-devel] [PATCH] dm: make static read-only array table const
The static array table as read-only so it make sense to make it const. Add in the int type to clean up checkpatch warning. Signed-off-by: Colin Ian King --- drivers/md/dm-cache-policy-smq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-cache-policy-smq.c b/drivers/md/dm-cache-policy-smq.c index b61aac00ff40..19eac5d980a8 100644 --- a/drivers/md/dm-cache-policy-smq.c +++ b/drivers/md/dm-cache-policy-smq.c @@ -1026,7 +1026,9 @@ static unsigned default_promote_level(struct smq_policy *mq) * This scheme reminds me of a graph of entropy vs probability of a * binary variable. */ - static unsigned table[] = {1, 1, 1, 2, 4, 6, 7, 8, 7, 6, 4, 4, 3, 3, 2, 2, 1}; + static const unsigned int table[] = { + 1, 1, 1, 2, 4, 6, 7, 8, 7, 6, 4, 4, 3, 3, 2, 2, 1 + }; unsigned hits = mq->cache_stats.hits; unsigned misses = mq->cache_stats.misses; -- 2.33.1 -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
Re: [dm-devel] dm: Forbid requeue of writes to zones
Hi, Static analysis with Coverity on Linux next has found and issue in drivers/md/dm.c with the following commit: commit 2c243153d1d4be4e23735cd10984ac17c7a54531 Author: Damien Le Moal Date: Wed May 26 06:24:58 2021 +0900 dm: Forbid requeue of writes to zones The analysis is as follows: 828 static void dec_pending(struct dm_io *io, blk_status_t error) 829 { 830unsigned long flags; 831blk_status_t io_error; 1. var_decl: Declaring variable bio without initializer. 832struct bio *bio; 833struct mapped_device *md = io->md; 834 835/* Push-back supersedes any I/O errors */ 2. Condition !!error, taking true branch. 836if (unlikely(error)) { 837spin_lock_irqsave(>endio_lock, flags); 3. Condition io->status == 11 /* (blk_status_t)11 */, taking false branch. 838if (!(io->status == BLK_STS_DM_REQUEUE && __noflush_suspending(md))) 839io->status = error; 840spin_unlock_irqrestore(>endio_lock, flags); 841} 842 4. Condition atomic_dec_and_test(>io_count), taking true branch. 843if (atomic_dec_and_test(>io_count)) { 5. Condition io->status == 11 /* (blk_status_t)11 */, taking true branch. 844if (io->status == BLK_STS_DM_REQUEUE) { 845/* 846 * Target requested pushing back the I/O. 847 */ 848spin_lock_irqsave(>deferred_lock, flags); 6. Condition __noflush_suspending(md), taking true branch. 849if (__noflush_suspending(md) && Uninitialized pointer read 7. uninit_use_in_call: Using uninitialized value bio when calling dm_is_zone_write. 850!WARN_ON_ONCE(dm_is_zone_write(md, bio))) 851/* NOTE early return due to BLK_STS_DM_REQUEUE below */ 852bio_list_add_head(>deferred, io->orig_bio); The pointer bio is not initialized and yet is being used in the call to function dm_is_zone_write where pointer bio is being accessed. I'm not sure what the original intent was, but this looks incorrect. Colin -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
[dm-devel] NAK: [PATCH][next] dm space maps: Fix uninitialized variable r2
On 21/05/2021 10:40, Colin King wrote: > From: Colin Ian King > > In the case where recursing(mm) is true variable r2 is not > inintialized and an uninitialized value is being used in the > call combine_errors later on. Fix this by setting r2 to zero. > > Addresses-Coverity: ("Uninitialized scalar variable") > Fixes: def6a7a9a7f0 ("dm space maps: improve performance with inc/dec on > ranges of blocks") > Signed-off-by: Colin Ian King > --- > drivers/md/persistent-data/dm-space-map-metadata.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c > b/drivers/md/persistent-data/dm-space-map-metadata.c > index 3b70ee861cf5..5be5ef4c831f 100644 > --- a/drivers/md/persistent-data/dm-space-map-metadata.c > +++ b/drivers/md/persistent-data/dm-space-map-metadata.c > @@ -432,9 +432,10 @@ static int sm_metadata_dec_blocks(struct dm_space_map > *sm, dm_block_t b, dm_bloc > int32_t nr_allocations; > struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); > > - if (recursing(smm)) > + if (recursing(smm)) { > r = add_bop(smm, BOP_DEC, b, e); > - else { > + r2 = 0; > + } else { > in(smm); > r = sm_ll_dec(>ll, b, e, _allocations); > r2 = out(smm); > There is a another occurrence of this, I'll send a V2 shortly -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
Re: [dm-devel] dm: rename multipath path selector source files to have "dm-ps" prefix
Hi, Static analysis on linux-next has detected an initialized variable issue with the following recent commit: commit 28784347451fdbf4671ba97018f816041ba2306a Author: Mike Snitzer Date: Tue Nov 10 13:41:53 2020 -0500 dm: rename multipath path selector source files to have "dm-ps" prefix The analysis is as follows: 43 static int ioa_add_path(struct path_selector *ps, struct dm_path *path, 44int argc, char **argv, char **error) 45 { 46struct selector *s = ps->context; 47struct path_info *pi = NULL; 1. var_decl: Declaring variable cpu without initializer. 48unsigned int cpu; 49int ret; 50 2. Condition argc != 1, taking false branch. 51if (argc != 1) { 52*error = "io-affinity ps: invalid number of arguments"; 53return -EINVAL; 54} 55 Uninitialized scalar variable (UNINIT) 3. uninit_use_in_call: Using uninitialized value cpu when calling __cpu_to_node. 56pi = kzalloc_node(sizeof(*pi), GFP_KERNEL, cpu_to_node(cpu)); 57if (!pi) { 58*error = "io-affinity ps: Error allocating path context"; 59return -ENOMEM; 60} Colin -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
Re: [dm-devel] [PATCH] dm ioctl: make dm_open and dm_release release
On 10/05/17 10:18, Colin King wrote: > From: Colin Ian King <colin.k...@canonical.com> > > Making dm_open and dm_release static fixes the sparse warnings: > > warning: symbol 'dm_open' was not declared. Should it be static? > warning: symbol 'dm_release' was not declared. Should it be static? > > Fixes: ab2c6224f4c0c ("dm: a basic support for using the select or poll > function") > Signed-off-by: Colin Ian King <colin.k...@canonical.com> > --- > drivers/md/dm-ioctl.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c > index 70dc5db90ef2..d45c68115d4c 100644 > --- a/drivers/md/dm-ioctl.c > +++ b/drivers/md/dm-ioctl.c > @@ -1893,7 +1893,7 @@ static long dm_compat_ctl_ioctl(struct file *file, uint > command, ulong u) > #define dm_compat_ctl_ioctl NULL > #endif > > -int dm_open(struct inode *inode, struct file *filp) > +static int dm_open(struct inode *inode, struct file *filp) > { > int r; > struct dm_file *priv; > @@ -1911,7 +1911,7 @@ int dm_open(struct inode *inode, struct file *filp) > return 0; > } > > -int dm_release(struct inode *inode, struct file *filp) > +static int dm_release(struct inode *inode, struct file *filp) > { > kfree(filp->private_data); > return 0; > Sorry, ignore this, it had a mistake in the subject line -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel