Jaegeuk Kim
21061b7d0f
FROMLIST: f2fs: remove i_xattr_sem to avoid deadlock and fix the original issue
This reverts commit 27161f13e3 "f2fs: avoid race in between read xattr & write xattr".
That introduced a deadlock case:
Thread #1:
[122554.641906][ T92] f2fs_getxattr+0xd4/0x5fc
-> waiting for f2fs_down_read(&F2FS_I(inode)->i_xattr_sem);
[122554.641927][ T92] __f2fs_get_acl+0x50/0x284
[122554.641948][ T92] f2fs_init_acl+0x84/0x54c
[122554.641969][ T92] f2fs_init_inode_metadata+0x460/0x5f0
[122554.641990][ T92] f2fs_add_inline_entry+0x11c/0x350
-> Locked dir->inode_page by f2fs_get_node_page()
[122554.642009][ T92] f2fs_do_add_link+0x100/0x1e4
[122554.642025][ T92] f2fs_create+0xf4/0x22c
[122554.642047][ T92] vfs_create+0x130/0x1f4
Thread #2:
[123996.386358][ T92] __get_node_page+0x8c/0x504
-> waiting for dir->inode_page lock
[123996.386383][ T92] read_all_xattrs+0x11c/0x1f4
[123996.386405][ T92] __f2fs_setxattr+0xcc/0x528
[123996.386424][ T92] f2fs_setxattr+0x158/0x1f4
-> f2fs_down_write(&F2FS_I(inode)->i_xattr_sem);
[123996.386443][ T92] __f2fs_set_acl+0x328/0x430
[123996.386618][ T92] f2fs_set_acl+0x38/0x50
[123996.386642][ T92] posix_acl_chmod+0xc8/0x1c8
[123996.386669][ T92] f2fs_setattr+0x5e0/0x6bc
[123996.386689][ T92] notify_change+0x4d8/0x580
[123996.386717][ T92] chmod_common+0xd8/0x184
[123996.386748][ T92] do_fchmodat+0x60/0x124
[123996.386766][ T92] __arm64_sys_fchmodat+0x28/0x3c
Let's take a look at the original issue back.
Thread A: Thread B:
-f2fs_getxattr
-lookup_all_xattrs
-xnid = F2FS_I(inode)->i_xattr_nid;
-f2fs_setxattr
-__f2fs_setxattr
-write_all_xattrs
-truncate_xattr_node
... ...
-write_checkpoint
... ...
-alloc_nid <- nid reuse
-get_node_page
-f2fs_bug_on <- nid != node_footer->nid
I think we don't need to truncate xattr pages eagerly which introduces lots of
data races without big benefits.
Bug: 280545073
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/linux-f2fs-devel/20230613233940.3643362-1-jaegeuk@kernel.org/T/#u
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Change-Id: Ifdbaf7defa50b479d82d2c945aa9d48e2e2317ed
2023-06-23 09:08:28 +00:00
..
2023-02-09 11:28:04 +01:00
2022-05-09 16:21:44 -04:00
2023-02-01 08:34:08 +01:00
2023-02-09 11:28:04 +01:00
2022-07-17 17:31:42 -07:00
2022-08-02 12:34:03 -04:00
2022-05-09 16:21:44 -04:00
2023-05-09 03:32:41 +00:00
2022-09-24 07:00:00 +02:00
2023-03-10 09:34:25 +01:00
2023-04-20 12:35:14 +02:00
2023-03-10 09:33:52 +01:00
2022-12-31 13:32:22 +01:00
2023-06-07 14:24:57 +00:00
2023-05-04 16:50:47 -07:00
2022-12-31 13:31:58 +01:00
2023-03-17 08:50:19 +01:00
2022-10-06 17:31:02 -07:00
2022-10-21 11:09:40 +02:00
2022-05-09 16:21:45 -04:00
2023-06-07 14:24:57 +00:00
2023-03-10 09:34:08 +01:00
2022-08-17 17:25:04 -04:00
2023-01-07 11:11:40 +01:00
2023-06-07 14:24:57 +00:00
2023-06-23 09:08:28 +00:00
2022-10-11 17:42:58 -06:00
2022-08-02 12:34:03 -04:00
2023-02-22 12:59:43 +01:00
2023-06-21 18:36:19 +00:00
2023-03-10 09:33:59 +01:00
2023-03-10 09:34:07 +01:00
2023-03-10 09:34:07 +01:00
2022-09-19 22:46:25 +02:00
2022-05-09 16:21:45 -04:00
2023-06-07 14:24:57 +00:00
2023-06-15 09:54:33 +01:00
2022-10-02 11:42:19 -07:00
2022-10-20 11:56:25 +02:00
2023-03-10 09:34:20 +01:00
2023-03-22 13:33:53 +01:00
2023-03-11 13:55:16 +01:00
2022-11-10 19:03:42 +01:00
2023-04-20 12:35:12 +02:00
2023-03-30 12:49:23 +02:00
2022-09-24 07:00:00 +02:00
2023-02-09 11:28:04 +01:00
2023-04-06 12:10:54 +02:00
2023-04-13 16:55:23 +02:00
2023-04-26 14:28:39 +02:00
2023-04-12 02:08:29 +00:00
2022-10-12 11:00:22 -07:00
2023-04-26 17:01:50 +00:00
2023-04-26 17:01:50 +00:00
2022-05-09 16:21:44 -04:00
2023-06-07 14:24:57 +00:00
2023-06-07 00:40:32 +00:00
2023-06-07 14:24:57 +00:00
2023-03-09 21:58:51 +00:00
2022-05-09 16:21:44 -04:00
2022-09-11 21:55:07 -07:00
2023-01-07 11:11:59 +01:00
2022-10-10 19:45:17 -07:00
2022-12-31 13:33:10 +01:00
2022-05-09 16:21:46 -04:00
2022-10-05 01:55:27 -05:00
2023-02-22 12:59:50 +01:00
2022-12-31 13:32:00 +01:00
2022-09-08 17:10:54 -04:00
2023-03-11 13:55:21 +01:00
2023-03-17 08:50:19 +01:00
2022-09-11 20:26:07 -07:00
2022-05-09 16:21:46 -04:00
2023-04-06 14:14:07 +00:00
2023-06-19 13:21:31 +00:00
2023-04-06 12:10:52 +02:00
2023-06-07 14:24:57 +00:00
2022-08-20 11:34:04 -04:00
2023-03-03 11:52:25 +01:00
2022-09-24 07:00:00 +02:00
2023-01-18 11:58:12 +01:00
2023-01-18 11:58:12 +01:00
2022-04-22 10:57:18 -07:00
2022-12-31 13:32:57 +01:00
2023-02-27 19:45:05 -08:00
2022-12-31 13:32:41 +01:00
2023-02-22 12:59:50 +01:00
2022-08-20 11:34:33 -04:00
2022-09-24 18:14:12 -07:00
2022-10-10 19:45:17 -07:00
2022-09-20 08:24:38 -06:00
2023-01-04 11:28:48 +01:00
2023-01-04 11:28:47 +01:00
2023-06-07 14:24:57 +00:00
2022-06-10 16:10:23 -04:00
2022-09-01 17:36:39 -04:00
2022-08-16 10:59:54 -04:00
2023-03-17 08:50:13 +01:00
2023-01-07 11:11:59 +01:00
2023-04-26 14:28:39 +02:00
2022-05-19 23:25:10 -04:00
2023-03-03 11:52:25 +01:00
2023-03-03 11:52:25 +01:00
2022-10-20 11:56:25 +02:00
2022-10-10 14:21:11 -07:00
2022-06-16 19:58:21 -07:00
2022-12-31 13:31:58 +01:00
2023-03-17 08:50:32 +01:00
2022-10-07 18:32:03 +02:00
2023-01-07 11:12:02 +01:00
2022-07-05 16:18:21 -04:00
2023-04-26 17:01:50 +00:00
2022-11-19 02:22:11 -05:00
2023-04-13 16:55:33 +02:00
2022-08-20 11:34:04 -04:00
2023-04-21 20:05:56 +00:00
2022-08-20 11:34:04 -04:00
2023-01-04 11:29:01 +01:00
2022-10-10 17:53:04 -07:00
2022-06-28 13:58:05 -04:00
2023-02-09 11:28:04 +01:00
2022-08-17 17:25:04 -04:00
2022-08-05 16:32:45 -07:00
2022-10-12 07:12:54 +00:00
2023-02-09 11:28:04 +01:00
2023-02-09 11:28:04 +01:00
2022-09-11 19:47:12 -05:00
2023-05-04 10:49:24 -07:00
2022-06-29 20:00:36 +02:00
2023-06-07 14:24:57 +00:00
2022-12-31 13:31:55 +01:00