Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1603186 > unrolled thread
| Started by | Chao Yu <yuchao0@huawei.com> |
|---|---|
| First post | 2017-03-17 11:50 +0100 |
| Last post | 2017-03-20 12:10 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] f2fs: protect free nid operation with cp_rwsem Chao Yu <yuchao0@huawei.com> - 2017-03-17 11:50 +0100
Re: [PATCH] f2fs: protect free nid operation with cp_rwsem Jaegeuk Kim <jaegeuk@kernel.org> - 2017-03-19 23:50 +0100
Re: [PATCH] f2fs: protect free nid operation with cp_rwsem Chao Yu <yuchao0@huawei.com> - 2017-03-20 12:10 +0100
| From | Chao Yu <yuchao0@huawei.com> |
|---|---|
| Date | 2017-03-17 11:50 +0100 |
| Subject | [PATCH] f2fs: protect free nid operation with cp_rwsem |
| Message-ID | <tlXCj-535-31@gated-at.bofh.it> |
- f2fs_balance_fs_bg
- build_free_nids
- __build_free_nids
- scan_nat_page
- add_free_nid
- f2fs_create
- f2fs_new_inode
- alloc_nid
- remove_free_nid
This patch uses cp_rwsem to protect free nid allocation/initialization
to avoid reusing allocated nid in above scenario.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/inode.c | 2 ++
fs/f2fs/segment.c | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 2520fa72b23f..f941410f994a 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -423,7 +423,9 @@ void f2fs_evict_inode(struct inode *inode)
add_ino_entry(sbi, inode->i_ino, UPDATE_INO);
}
if (is_inode_flag_set(inode, FI_FREE_NID)) {
+ f2fs_lock_op(sbi);
alloc_nid_failed(sbi, inode->i_ino);
+ f2fs_unlock_op(sbi);
clear_inode_flag(inode, FI_FREE_NID);
}
f2fs_bug_on(sbi, err &&
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0bf024f62330..f85e1f443c99 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -426,8 +426,11 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
if (!available_free_memory(sbi, FREE_NIDS))
try_to_free_nids(sbi, MAX_FREE_NIDS);
- else
+ else {
+ f2fs_lock_op(sbi);
build_free_nids(sbi, false, false);
+ f2fs_unlock_op(sbi);
+ }
if (!is_idle(sbi))
return;
--
2.8.2.295.g3f1c1d0
[toc] | [next] | [standalone]
| From | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| Date | 2017-03-19 23:50 +0100 |
| Message-ID | <tmRO9-3Wn-3@gated-at.bofh.it> |
| In reply to | #1603186 |
Hi Chao,
On 03/17, Chao Yu wrote:
> - f2fs_balance_fs_bg
> - build_free_nids
> - __build_free_nids
> - scan_nat_page
> - add_free_nid
> - f2fs_create
> - f2fs_new_inode
> - alloc_nid
> - remove_free_nid
>
> This patch uses cp_rwsem to protect free nid allocation/initialization
> to avoid reusing allocated nid in above scenario.
It looks like description doesn't match to your change below?
Thanks,
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> fs/f2fs/inode.c | 2 ++
> fs/f2fs/segment.c | 5 ++++-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> index 2520fa72b23f..f941410f994a 100644
> --- a/fs/f2fs/inode.c
> +++ b/fs/f2fs/inode.c
> @@ -423,7 +423,9 @@ void f2fs_evict_inode(struct inode *inode)
> add_ino_entry(sbi, inode->i_ino, UPDATE_INO);
> }
> if (is_inode_flag_set(inode, FI_FREE_NID)) {
> + f2fs_lock_op(sbi);
> alloc_nid_failed(sbi, inode->i_ino);
> + f2fs_unlock_op(sbi);
> clear_inode_flag(inode, FI_FREE_NID);
> }
> f2fs_bug_on(sbi, err &&
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 0bf024f62330..f85e1f443c99 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -426,8 +426,11 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
>
> if (!available_free_memory(sbi, FREE_NIDS))
> try_to_free_nids(sbi, MAX_FREE_NIDS);
> - else
> + else {
> + f2fs_lock_op(sbi);
> build_free_nids(sbi, false, false);
> + f2fs_unlock_op(sbi);
> + }
>
> if (!is_idle(sbi))
> return;
> --
> 2.8.2.295.g3f1c1d0
[toc] | [prev] | [next] | [standalone]
| From | Chao Yu <yuchao0@huawei.com> |
|---|---|
| Date | 2017-03-20 12:10 +0100 |
| Message-ID | <tn3mi-3Qx-23@gated-at.bofh.it> |
| In reply to | #1604103 |
Hi Jaegeuk,
On 2017/3/20 6:44, Jaegeuk Kim wrote:
> Hi Chao,
>
> On 03/17, Chao Yu wrote:
>> - f2fs_balance_fs_bg
>> - build_free_ni
>> - __build_free_nids
>> - scan_nat_page
>> - add_free_nid
>> - f2fs_create
>> - f2fs_new_inode
>> - alloc_nid
>> - remove_free_nid
>>
>> This patch uses cp_rwsem to protect free nid allocation/initialization
>> to avoid reusing allocated nid in above scenario.
>
> It looks like description doesn't match to your change below?
It looks like the problem will not happen because on_build_free_nids will stop
alloc_nid stealing one allocated nid while building free nids. Please ignore
this patch, sorry.
I found another potential case, could you please check that one?
Thanks,
>
> Thanks,
>
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>> fs/f2fs/inode.c | 2 ++
>> fs/f2fs/segment.c | 5 ++++-
>> 2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
>> index 2520fa72b23f..f941410f994a 100644
>> --- a/fs/f2fs/inode.c
>> +++ b/fs/f2fs/inode.c
>> @@ -423,7 +423,9 @@ void f2fs_evict_inode(struct inode *inode)
>> add_ino_entry(sbi, inode->i_ino, UPDATE_INO);
>> }
>> if (is_inode_flag_set(inode, FI_FREE_NID)) {
>> + f2fs_lock_op(sbi);
>> alloc_nid_failed(sbi, inode->i_ino);
>> + f2fs_unlock_op(sbi);
>> clear_inode_flag(inode, FI_FREE_NID);
>> }
>> f2fs_bug_on(sbi, err &&
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index 0bf024f62330..f85e1f443c99 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -426,8 +426,11 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
>>
>> if (!available_free_memory(sbi, FREE_NIDS))
>> try_to_free_nids(sbi, MAX_FREE_NIDS);
>> - else
>> + else {
>> + f2fs_lock_op(sbi);
>> build_free_nids(sbi, false, false);
>> + f2fs_unlock_op(sbi);
>> + }
>>
>> if (!is_idle(sbi))
>> return;
>> --
>> 2.8.2.295.g3f1c1d0
>
> .
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web