From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <yuchao0@huawei.com>,
linux-f2fs-devel@lists.sourceforge.net
Cc: Damien Le Moal <Damien.LeMoal@wdc.com>
Subject: [f2fs-dev] [PATCH 2/4] libf2fs_zoned: Introduce f2fs_reset_zone() function
Date: Mon, 19 Aug 2019 17:30:32 +0900 [thread overview]
Message-ID: <20190819083034.18218-3-shinichiro.kawasaki@wdc.com> (raw)
In-Reply-To: <20190819083034.18218-1-shinichiro.kawasaki@wdc.com>
To allow fsck to reset a zone with inconsistent write pointer, introduce
a helper function f2fs_reset_zone().
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
include/f2fs_fs.h | 1 +
lib/libf2fs_zoned.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 7d2cdda..ca6e7c2 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1299,6 +1299,7 @@ extern int f2fs_get_zone_blocks(int);
typedef int (report_zones_cb_t)(int i, struct blk_zone *blkz, void *opaque);
extern int f2fs_report_zones(int, report_zones_cb_t *, void *);
extern int f2fs_check_zones(int);
+int f2fs_reset_zone(struct device_info *dev, struct blk_zone *blkz);
extern int f2fs_reset_zones(int);
#define SIZE_ALIGN(val, size) ((val) + (size) - 1) / (size)
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index fc4974f..f56fa62 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -359,6 +359,24 @@ out:
return ret;
}
+int f2fs_reset_zone(struct device_info *dev, struct blk_zone *blkz)
+{
+ struct blk_zone_range range;
+ int ret;
+
+ if (!blk_zone_seq(blkz) || blk_zone_empty(blkz))
+ return 0;
+
+ /* Non empty sequential zone: reset */
+ range.sector = blk_zone_sector(blkz);
+ range.nr_sectors = blk_zone_length(blkz);
+ ret = ioctl(dev->fd, BLKRESETZONE, &range);
+ if (ret != 0)
+ ERR_MSG("ioctl BLKRESETZONE failed\n");
+
+ return ret;
+}
+
int f2fs_reset_zones(int j)
{
struct device_info *dev = c.devices + j;
@@ -456,6 +474,12 @@ int f2fs_check_zones(int i)
return -1;
}
+int f2fs_reset_zone(struct device_info *dev, struct blk_zone *blkz)
+{
+ ERR_MSG("%d: Zoned block devices are not supported\n", i);
+ return -1;
+}
+
int f2fs_reset_zones(int i)
{
ERR_MSG("%d: Zoned block devices are not supported\n", i);
--
2.21.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2019-08-19 8:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-19 8:30 [f2fs-dev] [PATCH 0/4] fsck: Check write pointers of zoned block devices Shin'ichiro Kawasaki
2019-08-19 8:30 ` [f2fs-dev] [PATCH 1/4] libf2fs_zoned: Introduce f2fs_report_zones() helper function Shin'ichiro Kawasaki
2019-08-19 8:30 ` Shin'ichiro Kawasaki [this message]
2019-08-19 8:30 ` [f2fs-dev] [PATCH 3/4] fsck.f2fs: Check write pointer consistency with current segments Shin'ichiro Kawasaki
2019-08-19 8:30 ` [f2fs-dev] [PATCH 4/4] fsck.f2fs: Check write pointer consistency with valid blocks count Shin'ichiro Kawasaki
2019-08-20 17:57 ` [f2fs-dev] [PATCH 0/4] fsck: Check write pointers of zoned block devices Jaegeuk Kim
2019-08-21 4:15 ` Shinichiro Kawasaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190819083034.18218-3-shinichiro.kawasaki@wdc.com \
--to=shinichiro.kawasaki@wdc.com \
--cc=Damien.LeMoal@wdc.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=yuchao0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).