From patchwork Fri May 5 20:40:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13233013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19CE2C77B75 for ; Fri, 5 May 2023 20:40:15 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pv2Ds-0005Xy-DW; Fri, 05 May 2023 20:40:12 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pv2Dr-0005Xs-1g for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 20:40:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=OGFXeU2dXaRo8clMCkR8c/hfrCLvrLrfrAcbGat2bS8=; b=kAn3+1RE1vcN/LB2aydrMcqqhm 7p+vgqx+ccCR14xF2BW23tGw1jbB8dIeVJObI4hjFn2OSKSVctlTXjAs5ykoMRB7WWgp3TGh71iue RY/fc81C9Ln8QGS7cTPiRpsvkKFAz0smYTH0bluVMBFHXbhwGgivSUI64p3KUZYy+XxU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=OGFXeU2dXaRo8clMCkR8c/hfrCLvrLrfrAcbGat2bS8=; b=f GiAFwekfIJgBXhEJBwjf+vKq5/zkAWQW0F4Zvy24/QstAM2MX/L8JHsflw864m3WWiTqUr5ToXIVr 5+GfbYSL0ItEykOTCER3qo25x3TthCFFSIsWswyjclSdnxsWtfq6txlbXdByoVikpcFU4rtkcq3uP ZbY9q2yiMQL2jKe4=; Received: from mail-pj1-f50.google.com ([209.85.216.50]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pv2Dq-0003PL-Eu for linux-f2fs-devel@lists.sourceforge.net; Fri, 05 May 2023 20:40:10 +0000 Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-24df4ef05d4so2038835a91.2 for ; Fri, 05 May 2023 13:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683319205; x=1685911205; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OGFXeU2dXaRo8clMCkR8c/hfrCLvrLrfrAcbGat2bS8=; b=gM0mLhZPPogTqDhH2p1bvP3RMMjdphDn/Ubq+8G64h4i2qq7VyxacwfPbtU+trWfKU U7gTntgoYJnK0Th0YsMLnQFnRLwRle6BHJYf9oxow1BmL14BDo+u9P0ZiNigKd3cRj/P uJpIpOx5Mv2xA32aqLN6X8fjC+LabvrS4mt2mpMYMeEnhZaPHdphaz4LbzSEXIiMoOG0 GHMZ9uKkL+h0BauzZ0vBeJF/R79NsUchwPmDsX/fSIu+hWBN/68zg5TKJmn5j/hlUJUR 9qEi/QfcJy0yyve6CDIg7gFaZvjW+DmLiuytY1TkGxjQgf8tH1W5aUYRtnPca2XVR0xs 9U1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683319205; x=1685911205; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OGFXeU2dXaRo8clMCkR8c/hfrCLvrLrfrAcbGat2bS8=; b=Bq8eAMHwDIJaN/FRyyXd+CC4fx35JcSH6jnQoD7EXcvqnSMvPDv/FCOI/sEQuzdHsN 7gDUmDi1IyQsSMID6f+Ch21IBq9a0OHkBNY2Fhe3KVs22LRUIiQ5mYi2SphIDARxL9zx no/T5bdPlgMys46ZPwJQWlpBlbDgEQTVI2BGnClswdf2Z4zwBU39sNLpW6Dsiawpzc0W kvONcOIwfYM8KZtZKZFOBIKgQaghkyzKwUTnRE5Gl1enuNxk4H9I0s8RPTc6uLlsfdDn dJghI6PRbg9nvQru/k5ualoEjUZfK1iF4fYOgZCLR1iU2QzcbhDXKz4ahNWxK+je7eER 7SLA== X-Gm-Message-State: AC+VfDy2m2FkWWqdBA534uBI0Wq/H0RygZgSVgy+w9RM0dFbNQxpkrnS SdPMCvvf8a9y4hgVqI24uOvLP3Ibt94= X-Google-Smtp-Source: ACHHUZ6dB/vPtTYWg7uhHznNlXJ0K2YkXLUMaIa/tmbVDicNbO1mh6N+YwG2esq5hI9+qVRtISfWng== X-Received: by 2002:a17:90a:b281:b0:24e:1dcd:4e73 with SMTP id c1-20020a17090ab28100b0024e1dcd4e73mr3000560pjr.0.1683319204509; Fri, 05 May 2023 13:40:04 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2620:15c:211:201:4c39:b490:cecf:cb9c]) by smtp.gmail.com with ESMTPSA id i14-20020a17090ad34e00b0024e3d26f644sm6057166pjx.3.2023.05.05.13.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 13:40:04 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Fri, 5 May 2023 13:40:00 -0700 Message-ID: <20230505204000.3604748-1-daeho43@gmail.com> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog MIME-Version: 1.0 X-Headers-End: 1pv2Dq-0003PL-Eu Subject: [f2fs-dev] [PATCH] f2fs: close unused open zones while mounting X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong Zoned UFS allows only 6 open zones at the same time, so we need to take care of the count of open zones while mounting. Signed-off-by: Daeho Jeong --- fs/f2fs/segment.c | 53 +++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 6db410f1bb8c..43d537d29b52 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4810,40 +4810,49 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi, break; } - /* - * If last valid block is beyond the write pointer, report the - * inconsistency. This inconsistency does not cause write error - * because the zone will not be selected for write operation until - * it get discarded. Just report it. - */ - if (last_valid_block >= wp_block) { - f2fs_notice(sbi, "Valid block beyond write pointer: " - "valid block[0x%x,0x%x] wp[0x%x,0x%x]", - GET_SEGNO(sbi, last_valid_block), - GET_BLKOFF_FROM_SEG0(sbi, last_valid_block), - wp_segno, wp_blkoff); + // The write pointer matches with the valid blocks + if (last_valid_block + 1 == wp_block) return 0; - } - /* - * If there is no valid block in the zone and if write pointer is - * not at zone start, reset the write pointer. - */ - if (last_valid_block + 1 == zone_block && zone->wp != zone->start) { + if (last_valid_block + 1 == zone_block) { + /* + * If there is no valid block in the zone and if write pointer + * is not at zone start, reset the write pointer. + */ f2fs_notice(sbi, "Zone without valid block has non-zero write " "pointer. Reset the write pointer: wp[0x%x,0x%x]", wp_segno, wp_blkoff); ret = __f2fs_issue_discard_zone(sbi, fdev->bdev, zone_block, zone->len >> log_sectors_per_block); - if (ret) { + if (ret) f2fs_err(sbi, "Discard zone failed: %s (errno=%d)", fdev->path, ret); - return ret; - } + + return ret; } - return 0; + /* + * If there are valid blocks and the write pointer doesn't + * match with them, we need to report the inconsistency and + * fill the zone till the end to close the zone. This inconsistency + * does not cause write error because the zone will not be selected + * for write operation until it get discarded. + */ + f2fs_notice(sbi, "Valid blocks are not aligned with write pointer: " + "valid block[0x%x,0x%x] wp[0x%x,0x%x]", + GET_SEGNO(sbi, last_valid_block), + GET_BLKOFF_FROM_SEG0(sbi, last_valid_block), + wp_segno, wp_blkoff); + + ret = blkdev_issue_zeroout(fdev->bdev, zone->wp, + zone->len - (zone->wp - zone->start), + GFP_NOFS, 0); + if (ret) + f2fs_err(sbi, "Fill up zone failed: %s (errno=%d)", + fdev->path, ret); + + return ret; } static struct f2fs_dev_info *get_target_zoned_dev(struct f2fs_sb_info *sbi,