@@ -6975,7 +6975,6 @@ collect_vdev_prop(zpool_prop_t prop, uint64_t value, const char *str,
69756975
69766976/*
69776977 * print static default line per vdev
6978- * not compatible with '-o' <proplist> option
69796978 */
69806979static void
69816980collect_list_stats (zpool_handle_t * zhp , const char * name , nvlist_t * nv ,
@@ -7031,48 +7030,98 @@ collect_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
70317030 * 'toplevel' boolean value is passed to the print_one_column()
70327031 * to indicate that the value is valid.
70337032 */
7034- if (VDEV_STAT_VALID (vs_pspace , c ) && vs -> vs_pspace ) {
7035- collect_vdev_prop (ZPOOL_PROP_SIZE , vs -> vs_pspace , NULL ,
7036- scripted , B_TRUE , format , cb -> cb_json , props ,
7037- cb -> cb_json_as_int );
7038- } else {
7039- collect_vdev_prop (ZPOOL_PROP_SIZE , vs -> vs_space , NULL ,
7040- scripted , toplevel , format , cb -> cb_json , props ,
7041- cb -> cb_json_as_int );
7033+ for (zprop_list_t * pl = cb -> cb_proplist ; pl != NULL ;
7034+ pl = pl -> pl_next ) {
7035+ switch (pl -> pl_prop ) {
7036+ case ZPOOL_PROP_SIZE :
7037+ if (VDEV_STAT_VALID (vs_pspace , c ) &&
7038+ vs -> vs_pspace ) {
7039+ collect_vdev_prop (
7040+ ZPOOL_PROP_SIZE , vs -> vs_pspace ,
7041+ NULL , scripted , B_TRUE , format ,
7042+ cb -> cb_json , props ,
7043+ cb -> cb_json_as_int );
7044+ } else {
7045+ collect_vdev_prop (
7046+ ZPOOL_PROP_SIZE , vs -> vs_space , NULL ,
7047+ scripted , toplevel , format ,
7048+ cb -> cb_json , props ,
7049+ cb -> cb_json_as_int );
7050+ }
7051+ break ;
7052+ case ZPOOL_PROP_ALLOCATED :
7053+ collect_vdev_prop (ZPOOL_PROP_ALLOCATED ,
7054+ vs -> vs_alloc , NULL , scripted , toplevel ,
7055+ format , cb -> cb_json , props ,
7056+ cb -> cb_json_as_int );
7057+ break ;
7058+
7059+ case ZPOOL_PROP_FREE :
7060+ collect_vdev_prop (ZPOOL_PROP_FREE ,
7061+ vs -> vs_space - vs -> vs_alloc , NULL , scripted ,
7062+ toplevel , format , cb -> cb_json , props ,
7063+ cb -> cb_json_as_int );
7064+ break ;
7065+
7066+ case ZPOOL_PROP_CHECKPOINT :
7067+ collect_vdev_prop (ZPOOL_PROP_CHECKPOINT ,
7068+ vs -> vs_checkpoint_space , NULL , scripted ,
7069+ toplevel , format , cb -> cb_json , props ,
7070+ cb -> cb_json_as_int );
7071+ break ;
7072+
7073+ case ZPOOL_PROP_EXPANDSZ :
7074+ collect_vdev_prop (ZPOOL_PROP_EXPANDSZ ,
7075+ vs -> vs_esize , NULL , scripted , B_TRUE ,
7076+ format , cb -> cb_json , props ,
7077+ cb -> cb_json_as_int );
7078+ break ;
7079+
7080+ case ZPOOL_PROP_FRAGMENTATION :
7081+ collect_vdev_prop (
7082+ ZPOOL_PROP_FRAGMENTATION ,
7083+ vs -> vs_fragmentation , NULL , scripted ,
7084+ (vs -> vs_fragmentation != ZFS_FRAG_INVALID &&
7085+ toplevel ),
7086+ format , cb -> cb_json , props ,
7087+ cb -> cb_json_as_int );
7088+ break ;
7089+
7090+ case ZPOOL_PROP_CAPACITY :
7091+ cap = (vs -> vs_space == 0 ) ?
7092+ 0 : (vs -> vs_alloc * 10000 / vs -> vs_space );
7093+ collect_vdev_prop (ZPOOL_PROP_CAPACITY , cap ,
7094+ NULL , scripted , toplevel , format ,
7095+ cb -> cb_json , props , cb -> cb_json_as_int );
7096+ break ;
7097+
7098+ case ZPOOL_PROP_HEALTH :
7099+ state = zpool_state_to_name (vs -> vs_state ,
7100+ vs -> vs_aux );
7101+ if (isspare ) {
7102+ if (vs -> vs_aux == VDEV_AUX_SPARED )
7103+ state = "INUSE" ;
7104+ else if (vs -> vs_state ==
7105+ VDEV_STATE_HEALTHY )
7106+ state = "AVAIL" ;
7107+ }
7108+ collect_vdev_prop (ZPOOL_PROP_HEALTH , 0 , state ,
7109+ scripted , B_TRUE , format , cb -> cb_json ,
7110+ props , cb -> cb_json_as_int );
7111+ break ;
7112+
7113+ case ZPOOL_PROP_NAME :
7114+ break ;
7115+
7116+ default :
7117+ collect_vdev_prop (pl -> pl_prop , 0 ,
7118+ NULL , scripted , B_FALSE , format ,
7119+ cb -> cb_json , props , cb -> cb_json_as_int );
7120+
7121+ }
7122+
7123+
70427124 }
7043- collect_vdev_prop (ZPOOL_PROP_ALLOCATED , vs -> vs_alloc , NULL ,
7044- scripted , toplevel , format , cb -> cb_json , props ,
7045- cb -> cb_json_as_int );
7046- collect_vdev_prop (ZPOOL_PROP_FREE , vs -> vs_space - vs -> vs_alloc ,
7047- NULL , scripted , toplevel , format , cb -> cb_json , props ,
7048- cb -> cb_json_as_int );
7049- collect_vdev_prop (ZPOOL_PROP_CHECKPOINT ,
7050- vs -> vs_checkpoint_space , NULL , scripted , toplevel , format ,
7051- cb -> cb_json , props , cb -> cb_json_as_int );
7052- collect_vdev_prop (ZPOOL_PROP_EXPANDSZ , vs -> vs_esize , NULL ,
7053- scripted , B_TRUE , format , cb -> cb_json , props ,
7054- cb -> cb_json_as_int );
7055- collect_vdev_prop (ZPOOL_PROP_FRAGMENTATION ,
7056- vs -> vs_fragmentation , NULL , scripted ,
7057- (vs -> vs_fragmentation != ZFS_FRAG_INVALID && toplevel ),
7058- format , cb -> cb_json , props , cb -> cb_json_as_int );
7059- cap = (vs -> vs_space == 0 ) ? 0 :
7060- (vs -> vs_alloc * 10000 / vs -> vs_space );
7061- collect_vdev_prop (ZPOOL_PROP_CAPACITY , cap , NULL ,
7062- scripted , toplevel , format , cb -> cb_json , props ,
7063- cb -> cb_json_as_int );
7064- collect_vdev_prop (ZPOOL_PROP_DEDUPRATIO , 0 , NULL ,
7065- scripted , toplevel , format , cb -> cb_json , props ,
7066- cb -> cb_json_as_int );
7067- state = zpool_state_to_name (vs -> vs_state , vs -> vs_aux );
7068- if (isspare ) {
7069- if (vs -> vs_aux == VDEV_AUX_SPARED )
7070- state = "INUSE" ;
7071- else if (vs -> vs_state == VDEV_STATE_HEALTHY )
7072- state = "AVAIL" ;
7073- }
7074- collect_vdev_prop (ZPOOL_PROP_HEALTH , 0 , state , scripted ,
7075- B_TRUE , format , cb -> cb_json , props , cb -> cb_json_as_int );
70767125
70777126 if (cb -> cb_json ) {
70787127 fnvlist_add_nvlist (ent , "properties" , props );
0 commit comments