* [PATCH] zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone()
@ 2021-03-16 12:30 Chao Yu
2021-03-16 23:30 ` Damien Le Moal
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2021-03-16 12:30 UTC (permalink / raw)
To: damien.lemoal, naohiro.aota, jth
Cc: linux-fsdevel, linux-kernel, chao, Chao Yu
In zonefs_open_zone(), if opened zone count is larger than
.s_max_open_zones threshold, we missed to recover .i_wr_refcnt,
fix this.
Fixes: b5c00e975779 ("zonefs: open/close zone on file open/close")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/zonefs/super.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 0fe76f376dee..be6b99f7de74 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -966,8 +966,7 @@ static int zonefs_open_zone(struct inode *inode)
mutex_lock(&zi->i_truncate_mutex);
- zi->i_wr_refcnt++;
- if (zi->i_wr_refcnt == 1) {
+ if (zi->i_wr_refcnt == 0) {
if (atomic_inc_return(&sbi->s_open_zones) > sbi->s_max_open_zones) {
atomic_dec(&sbi->s_open_zones);
@@ -978,7 +977,6 @@ static int zonefs_open_zone(struct inode *inode)
if (i_size_read(inode) < zi->i_max_size) {
ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN);
if (ret) {
- zi->i_wr_refcnt--;
atomic_dec(&sbi->s_open_zones);
goto unlock;
}
@@ -986,6 +984,8 @@ static int zonefs_open_zone(struct inode *inode)
}
}
+ zi->i_wr_refcnt++;
+
unlock:
mutex_unlock(&zi->i_truncate_mutex);
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone()
2021-03-16 12:30 [PATCH] zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone() Chao Yu
@ 2021-03-16 23:30 ` Damien Le Moal
2021-03-17 0:56 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2021-03-16 23:30 UTC (permalink / raw)
To: Chao Yu, Naohiro Aota, jth; +Cc: linux-fsdevel, linux-kernel, chao
On 2021/03/16 21:30, Chao Yu wrote:
> In zonefs_open_zone(), if opened zone count is larger than
> .s_max_open_zones threshold, we missed to recover .i_wr_refcnt,
> fix this.
>
> Fixes: b5c00e975779 ("zonefs: open/close zone on file open/close")
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> fs/zonefs/super.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 0fe76f376dee..be6b99f7de74 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -966,8 +966,7 @@ static int zonefs_open_zone(struct inode *inode)
>
> mutex_lock(&zi->i_truncate_mutex);
>
> - zi->i_wr_refcnt++;
> - if (zi->i_wr_refcnt == 1) {
> + if (zi->i_wr_refcnt == 0) {
Nit: if (!zi->i_wr_refcnt) ? I can change that when applying.
>
> if (atomic_inc_return(&sbi->s_open_zones) > sbi->s_max_open_zones) {
> atomic_dec(&sbi->s_open_zones);
> @@ -978,7 +977,6 @@ static int zonefs_open_zone(struct inode *inode)
> if (i_size_read(inode) < zi->i_max_size) {
> ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN);
> if (ret) {
> - zi->i_wr_refcnt--;
> atomic_dec(&sbi->s_open_zones);
> goto unlock;
> }
> @@ -986,6 +984,8 @@ static int zonefs_open_zone(struct inode *inode)
> }
> }
>
> + zi->i_wr_refcnt++;
> +
> unlock:
> mutex_unlock(&zi->i_truncate_mutex);
>
>
Good catch ! Will apply this and check zonefs test suite as this bug went
undetected.
Thanks.
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone()
2021-03-16 23:30 ` Damien Le Moal
@ 2021-03-17 0:56 ` Chao Yu
0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2021-03-17 0:56 UTC (permalink / raw)
To: Damien Le Moal, Naohiro Aota, jth; +Cc: linux-fsdevel, linux-kernel, chao
On 2021/3/17 7:30, Damien Le Moal wrote:
> On 2021/03/16 21:30, Chao Yu wrote:
>> In zonefs_open_zone(), if opened zone count is larger than
>> .s_max_open_zones threshold, we missed to recover .i_wr_refcnt,
>> fix this.
>>
>> Fixes: b5c00e975779 ("zonefs: open/close zone on file open/close")
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>> fs/zonefs/super.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
>> index 0fe76f376dee..be6b99f7de74 100644
>> --- a/fs/zonefs/super.c
>> +++ b/fs/zonefs/super.c
>> @@ -966,8 +966,7 @@ static int zonefs_open_zone(struct inode *inode)
>>
>> mutex_lock(&zi->i_truncate_mutex);
>>
>> - zi->i_wr_refcnt++;
>> - if (zi->i_wr_refcnt == 1) {
>> + if (zi->i_wr_refcnt == 0) {
>
> Nit: if (!zi->i_wr_refcnt) ? I can change that when applying.
More clean, thanks. :)
Thanks,
>
>>
>> if (atomic_inc_return(&sbi->s_open_zones) > sbi->s_max_open_zones) {
>> atomic_dec(&sbi->s_open_zones);
>> @@ -978,7 +977,6 @@ static int zonefs_open_zone(struct inode *inode)
>> if (i_size_read(inode) < zi->i_max_size) {
>> ret = zonefs_zone_mgmt(inode, REQ_OP_ZONE_OPEN);
>> if (ret) {
>> - zi->i_wr_refcnt--;
>> atomic_dec(&sbi->s_open_zones);
>> goto unlock;
>> }
>> @@ -986,6 +984,8 @@ static int zonefs_open_zone(struct inode *inode)
>> }
>> }
>>
>> + zi->i_wr_refcnt++;
>> +
>> unlock:
>> mutex_unlock(&zi->i_truncate_mutex);
>>
>>
>
> Good catch ! Will apply this and check zonefs test suite as this bug went
> undetected.
>
> Thanks.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-17 0:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 12:30 [PATCH] zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone() Chao Yu
2021-03-16 23:30 ` Damien Le Moal
2021-03-17 0:56 ` Chao Yu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.