[PATCH v3] ubifs: make ubifs_[get|set]xattr atomic
Dongsheng Yang
yangds.fnst at cn.fujitsu.com
Tue Aug 11 19:37:53 PDT 2015
On 08/11/2015 08:57 PM, Artem Bityutskiy wrote:
> On Fri, 2015-08-07 at 14:07 +0800, Dongsheng Yang wrote:
>> + mutex_lock(&ui->ui_mutex);
>> kfree(ui->data);
>> ui->data = kmemdup(value, size, GFP_NOFS);
>> if (!ui->data) {
>> + mutex_unlock(&ui->ui_mutex);
>> err = -ENOMEM;
>> goto out_free;
>> }
>> inode->i_size = ui->ui_size = size;
>> ui->data_len = size;
>> + mutex_unlock(&ui->ui_mutex);
>
>
> Just one note - should kmemdup() be called outside of the critical
> section, to make is shorter (memory allocation is a potentially slow
> operation)?
>
> Something like:
>
> buf = kmemdup()
> mutex_lock()
> kfree(ui->data)
> ui->data = buf
> mutex_unlock()
Good point, will update it.
Yang
>
> Artem.
>
More information about the linux-mtd
mailing list