dm: Fix dm-stripe's "status" output format

As mentioned in "dm: Don't try to implement "status" as subset of "table"",
dm-stripe in NetBSD doesn't have correct "status" output format.
Implement ->info() to sync with Linux kernel.

Note that num_error for stripe device isn't implemented yet.

taken-from: DragonFlyBSD
This commit is contained in:
tkusumi 2019-12-21 16:00:29 +00:00
parent 4d754f38b3
commit c281327782
3 changed files with 49 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm.h,v 1.50 2019/12/21 11:59:03 tkusumi Exp $ */
/* $NetBSD: dm.h,v 1.51 2019/12/21 16:00:29 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -186,13 +186,14 @@ typedef struct dm_target {
* specific. When dm_table_status_ioctl is called with flag
* DM_STATUS_TABLE_FLAG I have to sent params string back.
*/
char *(*info)(void *);
char *(*table)(void *);
int (*strategy)(dm_table_entry_t *, struct buf *);
int (*upcall)(dm_table_entry_t *, struct buf *);
/*
* Optional routines.
*/
char *(*info)(void *);
int (*sync)(dm_table_entry_t *);
int (*secsize)(dm_table_entry_t *, unsigned int *);
@ -251,6 +252,7 @@ int dm_target_linear_secsize(dm_table_entry_t *, unsigned int *);
/* dm_target_stripe.c */
int dm_target_stripe_init(dm_table_entry_t *, int, char **);
char *dm_target_stripe_info(void *);
char *dm_target_stripe_table(void *);
int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *);
int dm_target_stripe_sync(dm_table_entry_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_target.c,v 1.35 2019/12/21 11:59:03 tkusumi Exp $ */
/* $NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.35 2019/12/21 11:59:03 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -331,6 +331,7 @@ dm_target_init(void)
dmt->version[1] = 0;
dmt->version[2] = 3;
dmt->init = &dm_target_stripe_init;
dmt->info = &dm_target_stripe_info;
dmt->table = &dm_target_stripe_table;
dmt->strategy = &dm_target_stripe_strategy;
dmt->sync = &dm_target_stripe_sync;

View File

@ -1,4 +1,4 @@
/*$NetBSD: dm_target_stripe.c,v 1.42 2019/12/21 11:59:03 tkusumi Exp $*/
/*$NetBSD: dm_target_stripe.c,v 1.43 2019/12/21 16:00:29 tkusumi Exp $*/
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.42 2019/12/21 11:59:03 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.43 2019/12/21 16:00:29 tkusumi Exp $");
/*
* This file implements initial version of device-mapper stripe target.
@ -80,6 +80,7 @@ dm_target_stripe_modcmd(modcmd_t cmd, void *arg)
dmt->version[1] = 0;
dmt->version[2] = 0;
dmt->init = &dm_target_stripe_init;
dmt->info = &dm_target_stripe_info;
dmt->table = &dm_target_stripe_table;
dmt->strategy = &dm_target_stripe_strategy;
dmt->sync = &dm_target_stripe_sync;
@ -179,6 +180,45 @@ dm_target_stripe_init(dm_table_entry_t *table_en, int argc, char **argv)
return 0;
}
/* Info routine called to get params string. */
char *
dm_target_stripe_info(void *target_config)
{
dm_target_linear_config_t *tlc;
dm_target_stripe_config_t *tsc;
char *params, *ptr, buf[256];
int ret, i = 0;
size_t len;
tsc = target_config;
len = DM_MAX_PARAMS_SIZE;
params = kmem_alloc(len, KM_SLEEP);
ptr = params;
ret = snprintf(ptr, len, "%d ", tsc->stripe_num);
ptr += ret;
len -= ret;
memset(buf, 0, sizeof(buf));
TAILQ_FOREACH(tlc, &tsc->stripe_devs, entries) {
ret = snprintf(ptr, len, "%s ", tlc->pdev->udev_name);
if (0 /*tlc->num_error*/)
buf[i] = 'D';
else
buf[i] = 'A';
i++;
ptr += ret;
len -= ret;
}
ret = snprintf(ptr, len, "1 %s", buf);
ptr += ret;
len -= ret;
return params;
}
/* Table routine called to get params string. */
char *
dm_target_stripe_table(void *target_config)