From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Masato Suzuki <masato.suzuki@wdc.com>
Cc: Chao Yu <yuchao0@huawei.com>,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/1] f2fs: Fix zoned block device support
Date: Mon, 27 Feb 2017 10:49:16 -0800 [thread overview]
Message-ID: <20170227184916.GB2296@jaegeuk.local> (raw)
In-Reply-To: <20170227115249.19556-1-masato.suzuki@wdc.com>
Hello,
On 02/27, Masato Suzuki wrote:
> The introduction of the multi-device feature partially broke the support
> for zoned block devices. In the function f2fs_scan_devices, sbi->devs
> allocation and initialization is skipped in the case of a single device
> mount. This result in no device information structure being allocated
> for the device. This is fine if the device is a regular device, but in
> the case of a zoned block device, the device zone type array is not
> initialized, which causes the function __f2fs_issue_discard_zone to fail
> as get_blkz_type is unable to determine the zone type of a section.
>
> Fix this by always allocating and initializing the sbi->devs device
> information array even in the case of a single device if that device is
> zoned. For this particular case, make sure to obtain a reference on the
> single device so that the call to blkdev_put() in destroy_device_list
> operates as expected.
>
> Signed-off-by: Masato Suzuki <masato.suzuki@wdc.com>
Thank you for the patch.
I've added:
Fixes: 3c62be17d4f562f4 ("f2fs: support multiple devices")
Cc: <stable@vger.kernel.org> # v4.10
Thanks,
> Acked-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
> fs/f2fs/super.c | 67 +++++++++++++++++++++++++++++++++++++--------------------
> 1 file changed, 44 insertions(+), 23 deletions(-)
>
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 46fd30d..287fcbd 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -1698,36 +1698,55 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
> static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
> {
> struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
> + unsigned int max_devices = MAX_DEVICES;
> int i;
>
> - for (i = 0; i < MAX_DEVICES; i++) {
> - if (!RDEV(i).path[0])
> + /* Initialize single device information */
> + if (!RDEV(0).path[0]) {
> + if (!bdev_is_zoned(sbi->sb->s_bdev))
> return 0;
> + max_devices = 1;
> + }
>
> - if (i == 0) {
> - sbi->devs = kzalloc(sizeof(struct f2fs_dev_info) *
> - MAX_DEVICES, GFP_KERNEL);
> - if (!sbi->devs)
> - return -ENOMEM;
> - }
> + /*
> + * Initialize multiple devices information, or single
> + * zoned block device information.
> + */
> + sbi->devs = kcalloc(max_devices, sizeof(struct f2fs_dev_info),
> + GFP_KERNEL);
> + if (!sbi->devs)
> + return -ENOMEM;
>
> - memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN);
> - FDEV(i).total_segments = le32_to_cpu(RDEV(i).total_segments);
> - if (i == 0) {
> - FDEV(i).start_blk = 0;
> - FDEV(i).end_blk = FDEV(i).start_blk +
> - (FDEV(i).total_segments <<
> - sbi->log_blocks_per_seg) - 1 +
> - le32_to_cpu(raw_super->segment0_blkaddr);
> - } else {
> - FDEV(i).start_blk = FDEV(i - 1).end_blk + 1;
> - FDEV(i).end_blk = FDEV(i).start_blk +
> - (FDEV(i).total_segments <<
> - sbi->log_blocks_per_seg) - 1;
> - }
> + for (i = 0; i < max_devices; i++) {
>
> - FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path,
> + if (i > 0 && !RDEV(i).path[0])
> + break;
> +
> + if (max_devices == 1) {
> + /* Single zoned block device mount */
> + FDEV(0).bdev =
> + blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev,
> sbi->sb->s_mode, sbi->sb->s_type);
> + } else {
> + /* Multi-device mount */
> + memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN);
> + FDEV(i).total_segments =
> + le32_to_cpu(RDEV(i).total_segments);
> + if (i == 0) {
> + FDEV(i).start_blk = 0;
> + FDEV(i).end_blk = FDEV(i).start_blk +
> + (FDEV(i).total_segments <<
> + sbi->log_blocks_per_seg) - 1 +
> + le32_to_cpu(raw_super->segment0_blkaddr);
> + } else {
> + FDEV(i).start_blk = FDEV(i - 1).end_blk + 1;
> + FDEV(i).end_blk = FDEV(i).start_blk +
> + (FDEV(i).total_segments <<
> + sbi->log_blocks_per_seg) - 1;
> + }
> + FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path,
> + sbi->sb->s_mode, sbi->sb->s_type);
> + }
> if (IS_ERR(FDEV(i).bdev))
> return PTR_ERR(FDEV(i).bdev);
>
> @@ -1747,6 +1766,8 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
> "Failed to initialize F2FS blkzone information");
> return -EINVAL;
> }
> + if (max_devices == 1)
> + break;
> f2fs_msg(sbi->sb, KERN_INFO,
> "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: %s)",
> i, FDEV(i).path,
> --
> 2.9.3
>
> Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer:
>
> This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.
prev parent reply other threads:[~2017-02-27 18:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-27 11:52 [PATCH 1/1] f2fs: Fix zoned block device support Masato Suzuki
2017-02-27 18:49 ` Jaegeuk Kim [this message]
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=20170227184916.GB2296@jaegeuk.local \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=masato.suzuki@wdc.com \
--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).