Re: [bug report] bcache: avoid unnecessary btree nodes flushing in btree_flush_write()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020/1/27 2:17 下午, Dan Carpenter wrote:
> Hello Coly Li,
> 
> The patch 2aa8c529387c: "bcache: avoid unnecessary btree nodes
> flushing in btree_flush_write()" from Jan 24, 2020, leads to the
> following static checker warning:
> 
> 	drivers/md/bcache/journal.c:444 btree_flush_write()
> 	warn: 'ref_nr' unsigned <= 0
> 

Hi Dan,

Thank you, I will submit the fix in following v5.6-rc version.

BTW, now I use 0-DAY kernel test infrastructure from Intel and my local
gcc -Wall to detect static issue. What is the tool you use to find such
check-minus-value-to-unsigned prlbem ?

Coly Li

> drivers/md/bcache/journal.c
>    422  static void btree_flush_write(struct cache_set *c)
>    423  {
>    424          struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR];
>    425          unsigned int i, nr, ref_nr;
>                                     ^^^^^^
> 
>    426          atomic_t *fifo_front_p, *now_fifo_front_p;
>    427          size_t mask;
>    428  
>    429          if (c->journal.btree_flushing)
>    430                  return;
>    431  
>    432          spin_lock(&c->journal.flush_write_lock);
>    433          if (c->journal.btree_flushing) {
>    434                  spin_unlock(&c->journal.flush_write_lock);
>    435                  return;
>    436          }
>    437          c->journal.btree_flushing = true;
>    438          spin_unlock(&c->journal.flush_write_lock);
>    439  
>    440          /* get the oldest journal entry and check its refcount */
>    441          spin_lock(&c->journal.lock);
>    442          fifo_front_p = &fifo_front(&c->journal.pin);
>    443          ref_nr = atomic_read(fifo_front_p);
>    444          if (ref_nr <= 0) {
>                     ^^^^^^^^^^^
> Unsigned can't be less than zero.
> 
>    445                  /*
>    446                   * do nothing if no btree node references
>    447                   * the oldest journal entry
>    448                   */
>    449                  spin_unlock(&c->journal.lock);
>    450                  goto out;
>    451          }
>    452          spin_unlock(&c->journal.lock);
> 
> regards,
> dan carpenter
> 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux