xattr patches from feb?

Mats Kärrman Mats.Karrman at tritech.se
Thu Jun 27 05:37:18 EDT 2013


Hi Marc,

Thanks for your response! it was held captive by the spam filter for a while (my fault) so I didn't notice it.
I know about customers and changing priorities ;)

I havn't received any patches from you yet (also a mail program issue?).
I have only adopted 1/5 "xattr: protect ui_size and data_len by ui_mutex" and 2/5 "fix couple bugs in
UBIFS extended attribute len" (appended below).
Those two seem to work well (testing still in progress) and should not be affected by the locking issue?

BR // Mats

---------------------------
diff -pruN a/fs/ubifs/journal.c b/fs/ubifs/journal.c
--- a/fs/ubifs/journal.c	2013-06-24 15:06:39.213689332 +0200
+++ b/fs/ubifs/journal.c	2013-06-24 15:26:36.842825120 +0200
@@ -553,7 +553,8 @@ int ubifs_jnl_update(struct ubifs_info *
 
 	dbg_jnl("ino %lu, dent '%.*s', data len %d in dir ino %lu",
 		inode->i_ino, nm->len, nm->name, ui->data_len, dir->i_ino);
-	ubifs_assert(dir_ui->data_len == 0);
+	if (!xent)
+		ubifs_assert(dir_ui->data_len == 0);
 	ubifs_assert(mutex_is_locked(&dir_ui->ui_mutex));
 
 	dlen = UBIFS_DENT_NODE_SZ + nm->len + 1;
@@ -573,6 +574,8 @@ int ubifs_jnl_update(struct ubifs_info *
 	aligned_dlen = ALIGN(dlen, 8);
 	aligned_ilen = ALIGN(ilen, 8);
 	len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ;
+	len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ +
+	      dir_ui->data_len;
 	dent = kmalloc(len, GFP_NOFS);
 	if (!dent)
 		return -ENOMEM;
@@ -649,7 +652,8 @@ int ubifs_jnl_update(struct ubifs_info *
 
 	ino_key_init(c, &ino_key, dir->i_ino);
 	ino_offs += aligned_ilen;
-	err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs, UBIFS_INO_NODE_SZ);
+	err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs,
+			    UBIFS_INO_NODE_SZ + dir_ui->data_len);
 	if (err)
 		goto out_ro;
 
diff -pruN a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
--- a/fs/ubifs/xattr.c	2013-06-24 15:06:39.233689282 +0200
+++ b/fs/ubifs/xattr.c	2013-06-24 15:12:12.196863493 +0200
@@ -143,10 +143,10 @@ static int create_xattr(struct ubifs_inf
 		err = -ENOMEM;
 		goto out_free;
 	}
-	inode->i_size = ui->ui_size = size;
-	ui->data_len = size;
 
 	mutex_lock(&host_ui->ui_mutex);
+	inode->i_size = ui->ui_size = size;
+	ui->data_len = size;
 	host->i_ctime = ubifs_current_time(host);
 	host_ui->xattr_cnt += 1;
 	host_ui->xattr_size += CALC_DENT_SIZE(nm->len);
@@ -208,10 +208,10 @@ static int change_xattr(struct ubifs_inf
 		err = -ENOMEM;
 		goto out_free;
 	}
-	inode->i_size = ui->ui_size = size;
-	ui->data_len = size;
 
 	mutex_lock(&host_ui->ui_mutex);
+	inode->i_size = ui->ui_size = size;
+	ui->data_len = size;
 	host->i_ctime = ubifs_current_time(host);
 	host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len);
 	host_ui->xattr_size += CALC_XATTR_BYTES(size);
---------------------------



More information about the linux-mtd mailing list