提交 69b5bba6 编写于 作者: Z Zhihao Cheng 提交者: Zheng Zengkai

ubifs: Remove ui_mutex in ubifs_xattr_get and change_xattr

mainline inclusion
from mainline-v5.14
commit 819f9ab4
category: bugfix
bugzilla: 173879 https://gitee.com/openeuler/kernel/issues/I4DDEL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=819f9ab430a4478ce519e5cc8ae4de438d8ad4ba

---------------------------

Since ubifs_xattr_get and ubifs_xattr_set cannot being executed
parallelly after importing @host_ui->xattr_sem, now we can remove
ui_mutex imported by commit ab92a20b ("ubifs: make
ubifs_[get|set]xattr atomic").

@xattr_size, @xattr_names and @xattr_cnt can't be out of protection
by @host_ui->mutex yet, they are sill accesed in other places, such as
pack_inode() called by ubifs_write_inode() triggered by page-writeback.
Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: NRichard Weinberger <richard@nod.at>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 cc375a63
...@@ -208,13 +208,11 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, ...@@ -208,13 +208,11 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
err = -ENOMEM; err = -ENOMEM;
goto out_free; goto out_free;
} }
mutex_lock(&ui->ui_mutex);
kfree(ui->data); kfree(ui->data);
ui->data = buf; ui->data = buf;
inode->i_size = ui->ui_size = size; inode->i_size = ui->ui_size = size;
old_size = ui->data_len; old_size = ui->data_len;
ui->data_len = size; ui->data_len = size;
mutex_unlock(&ui->ui_mutex);
mutex_lock(&host_ui->ui_mutex); mutex_lock(&host_ui->ui_mutex);
host->i_ctime = current_time(host); host->i_ctime = current_time(host);
...@@ -362,7 +360,6 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf, ...@@ -362,7 +360,6 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
ubifs_assert(c, inode->i_size == ui->data_len); ubifs_assert(c, inode->i_size == ui->data_len);
ubifs_assert(c, ubifs_inode(host)->xattr_size > ui->data_len); ubifs_assert(c, ubifs_inode(host)->xattr_size > ui->data_len);
mutex_lock(&ui->ui_mutex);
if (buf) { if (buf) {
/* If @buf is %NULL we are supposed to return the length */ /* If @buf is %NULL we are supposed to return the length */
if (ui->data_len > size) { if (ui->data_len > size) {
...@@ -375,7 +372,6 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf, ...@@ -375,7 +372,6 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
err = ui->data_len; err = ui->data_len;
out_iput: out_iput:
mutex_unlock(&ui->ui_mutex);
iput(inode); iput(inode);
out_cleanup: out_cleanup:
up_read(&ubifs_inode(host)->xattr_sem); up_read(&ubifs_inode(host)->xattr_sem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册