Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4376446pxf; Tue, 16 Mar 2021 11:53:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW2mOS9qJHhfz1GBDhI3h1XVau1613AS1xSNFWE7rrmP2MzkTkSHdbdUu+q22mzuLKngBm X-Received: by 2002:aa7:cd6a:: with SMTP id ca10mr38091976edb.7.1615920793118; Tue, 16 Mar 2021 11:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615920793; cv=none; d=google.com; s=arc-20160816; b=sBQcxwbCEP0oiW1zYzgONMerawTBA7wvSTzwkOVZLx1XPwkRqotkUwNuLDCnNjpaND 0GOJiBRL9MhPmpynrNwvEV8NuQwb9Y8N57AISVOJ0JwV6j5CGBNa4eurzCklzrJBD1QQ aK4zadIJkxg9+a5eibbfoZNlui2piaEThk1Qe3qwT6ZR9KPjCLZ+GdVmWDvp5eVfxeDr NE5NqZMpCQ1bbVr+j+btqr8fdB/hGZ7omun0Ro6gOmQhiSoQWNtVE/aKbAan3ObT0fBn MODo8jZXAElBd2FhzU0tXunLCupv2xuvOtNeCg27GoIsNIRJVcMoAH3DANDMshhsBMfL YH6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=1c9PMnI3jijiqkMmPi7F0pN1+NG3lhoKMHf0T3s5clY=; b=prwUhaGLYH+A20NZAadTbp4NMPsKTbtf+q7+AxKf/47XL7zVMBt+OJs7XlhSR2ZkUO qBIxdDHiwW9P5JZnnHnG3AfVBtaLWezP4pwt3dUpt60uN5apnZTRpnjfi0nVTK9Opp0N mdo67+fokg5jPXlUauzZh+bqDjWa2SSbEPDNPXPN6x1AqL8Wi7uKlP0+QXp++dD71mxb xnENvPlLSxxOGwhi8dFfmAZy7uwXoTo0nN+rSSKi3kL0dins9LeTDBGEnHJLfecQGTE2 wce/VYcXExnRvR+hcjUEScLs6coKmEhmyPz8GHsW5A5wNAwVQ2HHsWOuzu12Eelm9qIW MbHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si14298437edo.515.2021.03.16.11.52.50; Tue, 16 Mar 2021 11:53:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231738AbhCPMbP (ORCPT + 99 others); Tue, 16 Mar 2021 08:31:15 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:13545 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231783AbhCPMau (ORCPT ); Tue, 16 Mar 2021 08:30:50 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4F0CHp4LkLzNndK; Tue, 16 Mar 2021 20:28:22 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Tue, 16 Mar 2021 20:30:35 +0800 From: Chao Yu To: , , CC: , , , Chao Yu Subject: [PATCH] zonefs: fix to update .i_wr_refcnt correctly in zonefs_open_zone() Date: Tue, 16 Mar 2021 20:30:26 +0800 Message-ID: <20210316123026.115473-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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