Re: [PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

2018-05-24 Thread Peter Zijlstra
On Wed, May 23, 2018 at 12:22:39PM -0700, Shaohua Li wrote: > I don't know what is changed in the refcount, such raid5 change has attempted > before and didn't work. 0 for the stripe count is a valid usage and we do > inc-from-zero in several places. Nothing much has changed with refcount; and the

Re: [PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

2018-05-23 Thread Shaohua Li
On Wed, May 23, 2018 at 07:49:04PM +0200, Peter Zijlstra wrote: > On Wed, May 23, 2018 at 06:21:19AM -0700, Matthew Wilcox wrote: > > On Wed, May 09, 2018 at 09:36:40PM +0200, Sebastian Andrzej Siewior wrote: > > > refcount_t type and corresponding API should be used instead of atomic_t > > > when

Re: [PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

2018-05-23 Thread Peter Zijlstra
On Wed, May 23, 2018 at 06:21:19AM -0700, Matthew Wilcox wrote: > On Wed, May 09, 2018 at 09:36:40PM +0200, Sebastian Andrzej Siewior wrote: > > refcount_t type and corresponding API should be used instead of atomic_t > > when > > the variable is used as a reference counter. This allows to avoid a

Re: [PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

2018-05-23 Thread Matthew Wilcox
On Wed, May 09, 2018 at 09:36:40PM +0200, Sebastian Andrzej Siewior wrote: > refcount_t type and corresponding API should be used instead of atomic_t when > the variable is used as a reference counter. This allows to avoid accidental > refcounter overflows that might lead to use-after-free situatio

Re: [PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

2018-05-23 Thread Peter Zijlstra
On Wed, May 23, 2018 at 02:50:07PM +0200, Sebastian Andrzej Siewior wrote: > On 2018-05-23 14:36:15 [+0200], Peter Zijlstra wrote: > > > Most changes are 1:1 replacements except for > > > BUG_ON(atomic_inc_return(&sh->count) != 1); > > > > That doesn't look right, 'inc_return == 1' implies inc-f

Re: [PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

2018-05-23 Thread Sebastian Andrzej Siewior
On 2018-05-23 14:36:15 [+0200], Peter Zijlstra wrote: > > Most changes are 1:1 replacements except for > > BUG_ON(atomic_inc_return(&sh->count) != 1); > > That doesn't look right, 'inc_return == 1' implies inc-from-zero, which > is not allowed by refcount. > > > which has been turned into > >

Re: [PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

2018-05-23 Thread Peter Zijlstra
> Most changes are 1:1 replacements except for > BUG_ON(atomic_inc_return(&sh->count) != 1); That doesn't look right, 'inc_return == 1' implies inc-from-zero, which is not allowed by refcount. > which has been turned into > refcount_inc(&sh->count); > BUG_ON(refcount_read(&s

[PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

2018-05-09 Thread Sebastian Andrzej Siewior
refcount_t type and corresponding API should be used instead of atomic_t when the variable is used as a reference counter. This allows to avoid accidental refcounter overflows that might lead to use-after-free situations. Most changes are 1:1 replacements except for BUG_ON(atomic_inc_retur