Re: [PATCH] lightnvm: missing nvm_lock acquire

2015-11-25 Thread Matias Bjørling
On 11/25/2015 03:18 PM, Wenwei Tao wrote: Or we can add a new function static struct nvm_dev *nvm_find_nvm_dev_locked(const char *name) { struct nvm_dev *dev; + down_write(&nvm_lock); list_for_each_entry(dev, &nvm_devices, devices) if (!strcmp(name, de

Re: [PATCH] lightnvm: missing nvm_lock acquire

2015-11-25 Thread Wenwei Tao
Or we can add a new function static struct nvm_dev *nvm_find_nvm_dev_locked(const char *name) { struct nvm_dev *dev; + down_write(&nvm_lock); list_for_each_entry(dev, &nvm_devices, devices) if (!strcmp(name, dev->name)) return dev; +

Re: [PATCH] lightnvm: missing nvm_lock acquire

2015-11-25 Thread Wenwei Tao
Hi Matias Place the lock inside nvm_find_nvm_dev can make code cleaner, but sometime may lack of flexibility, cause redundant lock and unlock, just my opinion. Place the lock inside the function is okay with me, just make sure do the proper up_write(&nvm_lock) in nvm_create_target(), it has a lot

Re: [PATCH] lightnvm: missing nvm_lock acquire

2015-11-25 Thread Matias Bjørling
On 11/25/2015 09:57 AM, Wenwei Tao wrote: Hi Matias I think list_for_each_entry_safe(pos, n, head, member) cannot avoid race condition the item point by ‘n’ can be deleted and freed in the same time we operate on 'pos' so lock is still necessary. I've made the patch like this, ok? To avoid rac

Re: [PATCH] lightnvm: missing nvm_lock acquire

2015-11-25 Thread Matias Bjørling
On 11/25/2015 09:57 AM, Wenwei Tao wrote: Hi Matias I think list_for_each_entry_safe(pos, n, head, member) cannot avoid race condition the item point by ‘n’ can be deleted and freed in the same time we operate on 'pos' so lock is still necessary. You're right. Brainfart... I'll apply it with t

Re: [PATCH] lightnvm: missing nvm_lock acquire

2015-11-25 Thread Wenwei Tao
Hi Matias I think list_for_each_entry_safe(pos, n, head, member) cannot avoid race condition the item point by ‘n’ can be deleted and freed in the same time we operate on 'pos' so lock is still necessary. 2015-11-25 2:36 GMT+08:00 Matias : > On 11/24/2015 04:24 PM, Wenwei Tao wrote: >> >> To avoid

Re: [PATCH] lightnvm: missing nvm_lock acquire

2015-11-24 Thread Matias
On 11/24/2015 04:24 PM, Wenwei Tao wrote: To avoid race conditions, traverse dev, media manager, and targeet lists and also register, unregister entries to/from them, should be always under the nvm_lock control. Signed-off-by: Wenwei Tao --- drivers/lightnvm/core.c | 19 +--

Re: [PATCH] lightnvm: missing nvm_lock acquire

2015-11-24 Thread kbuild test robot
Hi Wenwei, [auto build test WARNING on v4.4-rc2] [also build test WARNING on next-20151124] url: https://github.com/0day-ci/linux/commits/Wenwei-Tao/lightnvm-missing-nvm_lock-acquire/20151124-232858 config: x86_64-randconfig-x016-11241713 (attached as .config) reproduce: # save the at