All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Damien Le Moal <damien.lemoal@wdc.com>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH 3/5] f2fs-tools: Improve zoned model check
Date: Tue, 26 Mar 2019 11:24:32 -0700	[thread overview]
Message-ID: <20190326182432.GB85383@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <20190318063959.21369-4-damien.lemoal@wdc.com>

On 03/18, Damien Le Moal wrote:
> Return an error if an unknown zoned model is reported for a device.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  include/f2fs_fs.h   |  2 +-
>  lib/libf2fs.c       |  8 ++++++--
>  lib/libf2fs_zoned.c | 20 +++++++++++---------
>  3 files changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index e073723..97ad774 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -1257,7 +1257,7 @@ blk_zone_cond_str(struct blk_zone *blkz)
>  
>  #endif
>  
> -extern void f2fs_get_zoned_model(int);
> +extern int f2fs_get_zoned_model(int);
>  extern int f2fs_get_zone_blocks(int);
>  extern int f2fs_check_zones(int);
>  extern int f2fs_reset_zones(int);
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 60b84e0..5ca1bb0 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -925,8 +925,12 @@ int get_device_info(int i)
>  	}
>  
>  #if !defined(WITH_ANDROID) && defined(__linux__)
> -	if (S_ISBLK(stat_buf->st_mode))
> -		f2fs_get_zoned_model(i);
> +	if (S_ISBLK(stat_buf->st_mode)) {
> +		if (f2fs_get_zoned_model(i) < 0) {
> +			free(stat_buf);
> +			return -1;
> +                }
> +	}
>  
>  	if (dev->zoned_model != F2FS_ZONED_NONE) {
>  		if (dev->zoned_model == F2FS_ZONED_HM)
> diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
> index 6e32f32..1a6c5df 100644
> --- a/lib/libf2fs_zoned.c
> +++ b/lib/libf2fs_zoned.c
> @@ -24,39 +24,41 @@
>  
>  #ifdef HAVE_LINUX_BLKZONED_H
>  
> -void f2fs_get_zoned_model(int i)
> +int f2fs_get_zoned_model(int i)
>  {
>  	struct device_info *dev = c.devices + i;
>  	char str[128];
>  	FILE *file;
>  	int res;
>  
> +	/* Assume regular device */
> +	dev->zoned_model = F2FS_ZONED_NONE;
> +
>  	/* Check that this is a zoned block device */
>  	snprintf(str, sizeof(str),
>  		 "/sys/block/%s/queue/zoned",
>  		 basename(dev->path));
>  	file = fopen(str, "r");
>  	if (!file)
> -		goto not_zoned;
> +		return 0;
>  
>  	memset(str, 0, sizeof(str));
>  	res = fscanf(file, "%s", str);
>  	fclose(file);
>  
>  	if (res != 1)
> -		goto not_zoned;
> +		return 0;
>  
>  	if (strcmp(str, "host-aware") == 0) {
>  		dev->zoned_model = F2FS_ZONED_HA;
> -		return;
> -	}
> -	if (strcmp(str, "host-managed") == 0) {
> +	} else if (strcmp(str, "host-managed") == 0) {
>  		dev->zoned_model = F2FS_ZONED_HM;
> -		return;
> +	} else {

If "sys/block/%s/queue/zoned" reports "none", we can't format the device. :)

> +		MSG(0, "\tError: Unsupported device zoned model\n");
> +		return -1;
>  	}
>  
> -not_zoned:
> -	dev->zoned_model = F2FS_ZONED_NONE;
> +	return 0;
>  }
>  
>  int f2fs_get_zone_blocks(int i)
> -- 
> 2.20.1

  parent reply	other threads:[~2019-03-26 18:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18  6:39 [PATCH 0/5] Zoned block device support improvments Damien Le Moal
2019-03-18  6:39 ` [PATCH 1/5] f2fs-tools: Fix various compilation warnings Damien Le Moal
2019-03-21  6:29   ` Chao Yu
2019-03-18  6:39 ` [PATCH 2/5] f2fs-tools: Add f2fs_io to .gitignore Damien Le Moal
2019-03-21  6:29   ` Chao Yu
2019-03-18  6:39 ` [PATCH 3/5] f2fs-tools: Improve zoned model check Damien Le Moal
2019-03-21  6:32   ` Chao Yu
2019-03-26 18:24   ` Jaegeuk Kim [this message]
2019-03-26 22:58     ` Damien Le Moal
2019-03-18  6:39 ` [PATCH 4/5] f2fs-tools: Allow using host-aware devices as regular devices Damien Le Moal
2019-03-21  8:32   ` Chao Yu
2019-03-21  9:29     ` Damien Le Moal
2019-03-21 12:27       ` Chao Yu
2019-03-18  6:39 ` [PATCH 5/5] f2fs-tools: Fix multi-device format with zoned devices Damien Le Moal
2019-03-21  8:41   ` Chao Yu
2019-03-21  9:30     ` Damien Le Moal

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=20190326182432.GB85383@jaegeuk-macbookpro.roam.corp.google.com \
    --to=jaegeuk@kernel.org \
    --cc=damien.lemoal@wdc.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /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 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.