Skip to contentSkip to conversation

patch "staging: erofs: fix race of initializing xattrs of a inode at the" added to staging-testing

PATCH [email protected] 1 participant 1 message Feb 20, 2019

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

staging: erofs: fix race of initializing xattrs of a inode at the

to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-testing branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will be merged to the staging-next branch sometime soon, after it passes testing, and the merge window is open.

If you have any questions about this process, please let me know.

From 62dc45979f3f8cb0ea67302a93bff686f0c46c5a Mon Sep 17 00:00:00 2001
From: Gao Xiang <[email protected]>
Date: Mon, 18 Feb 2019 15:19:04 +0800
Subject: staging: erofs: fix race of initializing xattrs of a inode at the
same time

In real scenario, there could be several threads accessing xattrs of the same xattr-uninitialized inode, and init_inode_xattrs() almost at the same time.

That's actually an unexpected behavior, this patch closes the race.

Fixes b17500a0fdba ("staging: erofs: introduce xattr & acl support")
Cc <[email protected]> # 4.19+
---
 drivers/staging/erofs/internal.h | 11 ++++++---
 drivers/staging/erofs/xattr.c    | 41 ++++++++++++++++++++++----------
 2 files changed, 37 insertions(+), 15 deletions(-)
drivers/staging/erofs/internal.h +8 -3
index 3a27c255950b..e3bfde00c7d2 100644
@@ -327,12 +327,17 @@ static inline erofs_off_t iloc(struct erofs_sb_info *sbi, erofs_nid_t nid)
 	return blknr_to_addr(sbi->meta_blkaddr) + (nid << sbi->islotbits);
 }
 
-#define inode_set_inited_xattr(inode)   (EROFS_V(inode)->flags |= 1)
-#define inode_has_inited_xattr(inode)   (EROFS_V(inode)->flags & 1)
+/* atomic flag definitions */
+#define EROFS_V_EA_INITED_BIT	0
+
+/* bitlock definitions (arranged in reverse order) */
+#define EROFS_V_BL_XATTR_BIT	(BITS_PER_LONG - 1)
 
 struct erofs_vnode {
 	erofs_nid_t nid;
-	unsigned int flags;
+
+	/* atomic flags (including bitlocks) */
+	unsigned long flags;
 
 	unsigned char data_mapping_mode;
 	/* inline size in bytes */
drivers/staging/erofs/xattr.c +29 -12

90 lines not on this page · raw message

Signature · 1 line
2.20.1