Skip to content

Commit f609818

Browse files
Jaegeuk KimAltaf-Mahdi
authored andcommitted
f2fs: avoid double lock for cp_rwsem
The __f2fs_add_link is covered by cp_rwsem all the time. This calls init_inode_metadata, which conducts some acl operations including memory allocation with GFP_KERNEL previously. But, under memory pressure, f2fs_write_data_page can be called, which also grabs cp_rwsem too. In this case, this incurs a deadlock pointed by Chao. Thread Grarak#1 Thread Grarak#2 down_read down_write down_read -> here down_read should wait forever. Reviewed-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 0d29a96 commit f609818

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/f2fs/acl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static struct posix_acl *f2fs_acl_from_disk(const char *value, size_t size)
6262
if (count == 0)
6363
return NULL;
6464

65-
acl = posix_acl_alloc(count, GFP_KERNEL);
65+
acl = posix_acl_alloc(count, GFP_NOFS);
6666
if (!acl)
6767
return ERR_PTR(-ENOMEM);
6868

@@ -116,7 +116,7 @@ static void *f2fs_acl_to_disk(const struct posix_acl *acl, size_t *size)
116116
int i;
117117

118118
f2fs_acl = kmalloc(sizeof(struct f2fs_acl_header) + acl->a_count *
119-
sizeof(struct f2fs_acl_entry), GFP_KERNEL);
119+
sizeof(struct f2fs_acl_entry), GFP_NOFS);
120120
if (!f2fs_acl)
121121
return ERR_PTR(-ENOMEM);
122122

0 commit comments

Comments
 (0)