linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ubifs: make ubifs_[get|set]xattr atomic
@ 2015-07-30  5:37 Dongsheng Yang
  2015-07-30  8:05 ` Richard Weinberger
  0 siblings, 1 reply; 14+ messages in thread
From: Dongsheng Yang @ 2015-07-30  5:37 UTC (permalink / raw)
  To: dedekind1, richard.weinberger; +Cc: linux-mtd, Dongsheng Yang

This commit make the ubifs_[get|set]xattr protected by ui_mutex,
making xfstests/generic/037 passed.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 fs/ubifs/xattr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index 96f3448..dec1afd 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -208,6 +208,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
 	if (err)
 		return err;
 
+	mutex_lock(&ui->ui_mutex);
 	kfree(ui->data);
 	ui->data = kmemdup(value, size, GFP_NOFS);
 	if (!ui->data) {
@@ -216,6 +217,7 @@ static int change_xattr(struct ubifs_info *c, struct inode *host,
 	}
 	inode->i_size = ui->ui_size = size;
 	ui->data_len = size;
+	mutex_unlock(&ui->ui_mutex);
 
 	mutex_lock(&host_ui->ui_mutex);
 	host->i_ctime = ubifs_current_time(host);
@@ -409,6 +411,7 @@ ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf,
 	ubifs_assert(inode->i_size == ui->data_len);
 	ubifs_assert(ubifs_inode(host)->xattr_size > ui->data_len);
 
+	mutex_lock(&ui->ui_mutex);
 	if (buf) {
 		/* If @buf is %NULL we are supposed to return the length */
 		if (ui->data_len > size) {
@@ -423,6 +426,7 @@ ssize_t ubifs_getxattr(struct dentry *dentry, const char *name, void *buf,
 	err = ui->data_len;
 
 out_iput:
+	mutex_unlock(&ui->ui_mutex);
 	iput(inode);
 out_unlock:
 	kfree(xent);
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-08-12  2:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-30  5:37 [PATCH] ubifs: make ubifs_[get|set]xattr atomic Dongsheng Yang
2015-07-30  8:05 ` Richard Weinberger
2015-07-31  0:04   ` Dongsheng Yang
2015-07-31  1:12     ` [PATCH v2] " Dongsheng Yang
2015-08-03 20:27       ` Richard Weinberger
2015-08-07  5:40         ` Dongsheng Yang
2015-08-07  6:07           ` [PATCH v3] " Dongsheng Yang
2015-08-10  8:05             ` Artem Bityutskiy
2015-08-11  3:32               ` Dongsheng Yang
2015-08-11 12:46                 ` Artem Bityutskiy
2015-08-12  2:37                   ` Dongsheng Yang
2015-08-11 12:57             ` Artem Bityutskiy
2015-08-12  2:37               ` Dongsheng Yang
2015-08-08 20:34           ` [PATCH v2] " Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).