annotate usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c @ 14074:cac17ab5e600

3862 stmf + kstat = kernel panic 3863 stmf_itl_task_start() must check for ilu->ilu_kstat_io is non-null 3864 memory leak in the iSCSI code Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Jeremy Jones <jeremy@delphix.com> Reviewed by: Sebastien Roy <sebastien.roy@delphix.com> Reviewed by: Dan McDonald <danmcd@nexenta.com> Reviewed by: Garrett D'Amore <garrett@damore.org> Reviewed by: Richard Elling <richard.elling@gmail.com> Approved by: Gordon Ross <gwr@nexenta.com>
author Jeff Biseda <jeff.biseda@delphix.com>
date Sun, 07 Jul 2013 18:18:37 -0800
parents e5bd6d1f1685
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1 /*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
2 * CDDL HEADER START
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
5 * Common Development and Distribution License (the "License").
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
6 * You may not use this file except in compliance with the License.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
7 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
10 * See the License for the specific language governing permissions
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
11 * and limitations under the License.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
12 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
18 *
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
19 * CDDL HEADER END
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
20 */
14042
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
21
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
22 /*
12202
f0a60953b83c 6935373 SC3.x/clustered SS7000 FC - Node/cluster panic'ing after takeover from 7000 cluster head
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 11773
diff changeset
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
14042
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
24 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
14074
cac17ab5e600 3862 stmf + kstat = kernel panic
Jeff Biseda <jeff.biseda@delphix.com>
parents: 14042
diff changeset
25 * Copyright (c) 2013 by Delphix. All rights reserved.
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
26 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
27
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
28 #include <sys/conf.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
29 #include <sys/file.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
30 #include <sys/ddi.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
31 #include <sys/sunddi.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
32 #include <sys/modctl.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
33 #include <sys/scsi/scsi.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
34 #include <sys/scsi/impl/scsi_reset_notify.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
35 #include <sys/disp.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
36 #include <sys/byteorder.h>
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
37 #include <sys/pathname.h>
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
38 #include <sys/atomic.h>
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
39 #include <sys/nvpair.h>
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
40 #include <sys/fs/zfs.h>
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
41 #include <sys/sdt.h>
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
42 #include <sys/dkio.h>
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
43 #include <sys/zfs_ioctl.h>
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
44
12571
05943d9c379f 6777077 COMSTAR drivers unnecessary NUL-terminate strings
Viswanathan Kannappan <Viswanathan.Kannappan@Sun.COM>
parents: 12499
diff changeset
45 #include <sys/stmf.h>
05943d9c379f 6777077 COMSTAR drivers unnecessary NUL-terminate strings
Viswanathan Kannappan <Viswanathan.Kannappan@Sun.COM>
parents: 12499
diff changeset
46 #include <sys/lpif.h>
05943d9c379f 6777077 COMSTAR drivers unnecessary NUL-terminate strings
Viswanathan Kannappan <Viswanathan.Kannappan@Sun.COM>
parents: 12499
diff changeset
47 #include <sys/stmf_ioctl.h>
05943d9c379f 6777077 COMSTAR drivers unnecessary NUL-terminate strings
Viswanathan Kannappan <Viswanathan.Kannappan@Sun.COM>
parents: 12499
diff changeset
48 #include <sys/stmf_sbd_ioctl.h>
05943d9c379f 6777077 COMSTAR drivers unnecessary NUL-terminate strings
Viswanathan Kannappan <Viswanathan.Kannappan@Sun.COM>
parents: 12499
diff changeset
49
05943d9c379f 6777077 COMSTAR drivers unnecessary NUL-terminate strings
Viswanathan Kannappan <Viswanathan.Kannappan@Sun.COM>
parents: 12499
diff changeset
50 #include "stmf_sbd.h"
05943d9c379f 6777077 COMSTAR drivers unnecessary NUL-terminate strings
Viswanathan Kannappan <Viswanathan.Kannappan@Sun.COM>
parents: 12499
diff changeset
51 #include "sbd_impl.h"
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
52
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
53 #define SBD_IS_ZVOL(zvol) (strncmp("/dev/zvol", zvol, 9))
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
54
9933
24d797986369 6852255 sbd_pgr_meta_write()/sbd_pgr_meta_load() infinite recursion
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9932
diff changeset
55 extern sbd_status_t sbd_pgr_meta_init(sbd_lu_t *sl);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
56 extern sbd_status_t sbd_pgr_meta_load(sbd_lu_t *sl);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
57 extern void sbd_pgr_reset(sbd_lu_t *sl);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
58
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
59 static int sbd_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
60 void **result);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
61 static int sbd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
62 static int sbd_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
63 static int sbd_open(dev_t *devp, int flag, int otype, cred_t *credp);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
64 static int sbd_close(dev_t dev, int flag, int otype, cred_t *credp);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
65 static int stmf_sbd_ioctl(dev_t dev, int cmd, intptr_t data, int mode,
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
66 cred_t *credp, int *rval);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
67 void sbd_lp_cb(stmf_lu_provider_t *lp, int cmd, void *arg, uint32_t flags);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
68 stmf_status_t sbd_proxy_reg_lu(uint8_t *luid, void *proxy_reg_arg,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
69 uint32_t proxy_reg_arg_len);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
70 stmf_status_t sbd_proxy_dereg_lu(uint8_t *luid, void *proxy_reg_arg,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
71 uint32_t proxy_reg_arg_len);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
72 stmf_status_t sbd_proxy_msg(uint8_t *luid, void *proxy_arg,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
73 uint32_t proxy_arg_len, uint32_t type);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
74 int sbd_create_register_lu(sbd_create_and_reg_lu_t *slu, int struct_sz,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
75 uint32_t *err_ret);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
76 int sbd_create_standby_lu(sbd_create_standby_lu_t *slu, uint32_t *err_ret);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
77 int sbd_set_lu_standby(sbd_set_lu_standby_t *stlu, uint32_t *err_ret);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
78 int sbd_import_lu(sbd_import_lu_t *ilu, int struct_sz, uint32_t *err_ret,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
79 int no_register, sbd_lu_t **slr);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
80 int sbd_import_active_lu(sbd_import_lu_t *ilu, sbd_lu_t *sl, uint32_t *err_ret);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
81 int sbd_delete_lu(sbd_delete_lu_t *dlu, int struct_sz, uint32_t *err_ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
82 int sbd_modify_lu(sbd_modify_lu_t *mlu, int struct_sz, uint32_t *err_ret);
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
83 int sbd_set_global_props(sbd_global_props_t *mlu, int struct_sz,
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
84 uint32_t *err_ret);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
85 int sbd_get_global_props(sbd_global_props_t *oslp, uint32_t oslp_sz,
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
86 uint32_t *err_ret);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
87 int sbd_get_lu_props(sbd_lu_props_t *islp, uint32_t islp_sz,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
88 sbd_lu_props_t *oslp, uint32_t oslp_sz, uint32_t *err_ret);
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
89 static char *sbd_get_zvol_name(sbd_lu_t *);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
90 static int sbd_get_unmap_props(sbd_unmap_props_t *sup, sbd_unmap_props_t *osup,
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
91 uint32_t *err_ret);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
92 sbd_status_t sbd_create_zfs_meta_object(sbd_lu_t *sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
93 sbd_status_t sbd_open_zfs_meta(sbd_lu_t *sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
94 sbd_status_t sbd_read_zfs_meta(sbd_lu_t *sl, uint8_t *buf, uint64_t sz,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
95 uint64_t off);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
96 sbd_status_t sbd_write_zfs_meta(sbd_lu_t *sl, uint8_t *buf, uint64_t sz,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
97 uint64_t off);
12499
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
98 sbd_status_t sbd_update_zfs_prop(sbd_lu_t *sl);
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
99 int sbd_is_zvol(char *path);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
100 int sbd_zvolget(char *zvol_name, char **comstarprop);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
101 int sbd_zvolset(char *zvol_name, char *comstarprop);
9857
a4f2eeb19b07 6837150 New COMSTAR SBD PGR code needs to handle the SRP transport ID format
Peter Cudhea - Sun Microsystems - Burlington, MA United States <Peter.Cudhea@Sun.COM>
parents: 9679
diff changeset
102 char sbd_ctoi(char c);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
103 void sbd_close_lu(sbd_lu_t *sl);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
104
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
105 static ldi_ident_t sbd_zfs_ident;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
106 static stmf_lu_provider_t *sbd_lp;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
107 static sbd_lu_t *sbd_lu_list = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
108 static kmutex_t sbd_lock;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
109 static dev_info_t *sbd_dip;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
110 static uint32_t sbd_lu_count = 0;
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
111
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
112 /* Global property settings for the logical unit */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
113 char sbd_vendor_id[] = "SUN ";
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
114 char sbd_product_id[] = "COMSTAR ";
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
115 char sbd_revision[] = "1.0 ";
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
116 char *sbd_mgmt_url = NULL;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
117 uint16_t sbd_mgmt_url_alloc_size = 0;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
118 krwlock_t sbd_global_prop_lock;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
119
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
120 static char sbd_name[] = "sbd";
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
121
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
122 static struct cb_ops sbd_cb_ops = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
123 sbd_open, /* open */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
124 sbd_close, /* close */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
125 nodev, /* strategy */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
126 nodev, /* print */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
127 nodev, /* dump */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
128 nodev, /* read */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
129 nodev, /* write */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
130 stmf_sbd_ioctl, /* ioctl */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
131 nodev, /* devmap */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
132 nodev, /* mmap */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
133 nodev, /* segmap */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
134 nochpoll, /* chpoll */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
135 ddi_prop_op, /* cb_prop_op */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
136 0, /* streamtab */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
137 D_NEW | D_MP, /* cb_flag */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
138 CB_REV, /* rev */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
139 nodev, /* aread */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
140 nodev /* awrite */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
141 };
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
142
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
143 static struct dev_ops sbd_ops = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
144 DEVO_REV,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
145 0,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
146 sbd_getinfo,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
147 nulldev, /* identify */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
148 nulldev, /* probe */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
149 sbd_attach,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
150 sbd_detach,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
151 nodev, /* reset */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
152 &sbd_cb_ops,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
153 NULL, /* bus_ops */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
154 NULL /* power */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
155 };
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
156
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
157 #define SBD_NAME "COMSTAR SBD"
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
158
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
159 static struct modldrv modldrv = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
160 &mod_driverops,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
161 SBD_NAME,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
162 &sbd_ops
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
163 };
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
164
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
165 static struct modlinkage modlinkage = {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
166 MODREV_1,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
167 &modldrv,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
168 NULL
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
169 };
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
170
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
171 int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
172 _init(void)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
173 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
174 int ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
175
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
176 ret = mod_install(&modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
177 if (ret)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
178 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
179 sbd_lp = (stmf_lu_provider_t *)stmf_alloc(STMF_STRUCT_LU_PROVIDER,
8818
72eb4c71537c 6749645 _init returning DDI_FAILURE
tim szeto <Tim.Szeto@Sun.COM>
parents: 7836
diff changeset
180 0, 0);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
181 sbd_lp->lp_lpif_rev = LPIF_REV_2;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
182 sbd_lp->lp_instance = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
183 sbd_lp->lp_name = sbd_name;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
184 sbd_lp->lp_cb = sbd_lp_cb;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
185 sbd_lp->lp_alua_support = 1;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
186 sbd_lp->lp_proxy_msg = sbd_proxy_msg;
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
187 sbd_zfs_ident = ldi_ident_from_anon();
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
188
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
189 if (stmf_register_lu_provider(sbd_lp) != STMF_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
190 (void) mod_remove(&modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
191 stmf_free(sbd_lp);
8818
72eb4c71537c 6749645 _init returning DDI_FAILURE
tim szeto <Tim.Szeto@Sun.COM>
parents: 7836
diff changeset
192 return (EINVAL);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
193 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
194 mutex_init(&sbd_lock, NULL, MUTEX_DRIVER, NULL);
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
195 rw_init(&sbd_global_prop_lock, NULL, RW_DRIVER, NULL);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
196 return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
197 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
198
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
199 int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
200 _fini(void)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
201 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
202 int ret;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
203
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
204 /*
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
205 * If we have registered lus, then make sure they are all offline
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
206 * if so then deregister them. This should drop the sbd_lu_count
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
207 * to zero.
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
208 */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
209 if (sbd_lu_count) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
210 sbd_lu_t *slu;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
211
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
212 /* See if all of them are offline */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
213 mutex_enter(&sbd_lock);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
214 for (slu = sbd_lu_list; slu != NULL; slu = slu->sl_next) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
215 if ((slu->sl_state != STMF_STATE_OFFLINE) ||
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
216 slu->sl_state_not_acked) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
217 mutex_exit(&sbd_lock);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
218 return (EBUSY);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
219 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
220 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
221 mutex_exit(&sbd_lock);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
222
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
223 #if 0
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
224 /* ok start deregistering them */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
225 while (sbd_lu_list) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
226 sbd_store_t *sst = sbd_lu_list->sl_sst;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
227 if (sst->sst_deregister_lu(sst) != STMF_SUCCESS)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
228 return (EBUSY);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
229 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
230 #endif
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
231 return (EBUSY);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
232 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
233 if (stmf_deregister_lu_provider(sbd_lp) != STMF_SUCCESS)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
234 return (EBUSY);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
235 ret = mod_remove(&modlinkage);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
236 if (ret != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
237 (void) stmf_register_lu_provider(sbd_lp);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
238 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
239 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
240 stmf_free(sbd_lp);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
241 mutex_destroy(&sbd_lock);
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
242 rw_destroy(&sbd_global_prop_lock);
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
243 ldi_ident_release(sbd_zfs_ident);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
244 return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
245 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
246
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
247 int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
248 _info(struct modinfo *modinfop)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
249 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
250 return (mod_info(&modlinkage, modinfop));
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
251 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
252
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
253 /* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
254 static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
255 sbd_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **result)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
256 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
257 switch (cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
258 case DDI_INFO_DEVT2DEVINFO:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
259 *result = sbd_dip;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
260 break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
261 case DDI_INFO_DEVT2INSTANCE:
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
262 *result = (void *)(uintptr_t)ddi_get_instance(sbd_dip);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
263 break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
264 default:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
265 return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
266 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
267
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
268 return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
269 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
270
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
271 static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
272 sbd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
273 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
274 switch (cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
275 case DDI_ATTACH:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
276 sbd_dip = dip;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
277
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
278 if (ddi_create_minor_node(dip, "admin", S_IFCHR, 0,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
279 DDI_NT_STMF_LP, 0) != DDI_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
280 break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
281 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
282 ddi_report_dev(dip);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
283 return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
284 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
285
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
286 return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
287 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
288
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
289 static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
290 sbd_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
291 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
292 switch (cmd) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
293 case DDI_DETACH:
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
294 ddi_remove_minor_node(dip, 0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
295 return (DDI_SUCCESS);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
296 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
297
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
298 return (DDI_FAILURE);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
299 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
300
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
301 /* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
302 static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
303 sbd_open(dev_t *devp, int flag, int otype, cred_t *credp)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
304 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
305 if (otype != OTYP_CHR)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
306 return (EINVAL);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
307 return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
308 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
309
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
310 /* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
311 static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
312 sbd_close(dev_t dev, int flag, int otype, cred_t *credp)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
313 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
314 return (0);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
315 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
316
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
317 /* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
318 static int
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
319 stmf_sbd_ioctl(dev_t dev, int cmd, intptr_t data, int mode,
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
320 cred_t *credp, int *rval)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
321 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
322 stmf_iocdata_t *iocd;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
323 void *ibuf = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
324 void *obuf = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
325 sbd_lu_t *nsl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
326 int i;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
327 int ret;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
328
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
329 if (drv_priv(credp) != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
330 return (EPERM);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
331 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
332
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
333 ret = stmf_copyin_iocdata(data, mode, &iocd, &ibuf, &obuf);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
334 if (ret)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
335 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
336 iocd->stmf_error = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
337
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
338 switch (cmd) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
339 case SBD_IOCTL_CREATE_AND_REGISTER_LU:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
340 if (iocd->stmf_ibuf_size <
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
341 (sizeof (sbd_create_and_reg_lu_t) - 8)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
342 ret = EFAULT;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
343 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
344 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
345 if ((iocd->stmf_obuf_size == 0) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
346 (iocd->stmf_obuf_size > iocd->stmf_ibuf_size)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
347 ret = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
348 break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
349 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
350 ret = sbd_create_register_lu((sbd_create_and_reg_lu_t *)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
351 ibuf, iocd->stmf_ibuf_size, &iocd->stmf_error);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
352 bcopy(ibuf, obuf, iocd->stmf_obuf_size);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
353 break;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
354 case SBD_IOCTL_SET_LU_STANDBY:
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
355 if (iocd->stmf_ibuf_size < sizeof (sbd_set_lu_standby_t)) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
356 ret = EFAULT;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
357 break;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
358 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
359 if (iocd->stmf_obuf_size) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
360 ret = EINVAL;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
361 break;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
362 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
363 ret = sbd_set_lu_standby((sbd_set_lu_standby_t *)ibuf,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
364 &iocd->stmf_error);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
365 break;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
366 case SBD_IOCTL_IMPORT_LU:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
367 if (iocd->stmf_ibuf_size <
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
368 (sizeof (sbd_import_lu_t) - 8)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
369 ret = EFAULT;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
370 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
371 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
372 if ((iocd->stmf_obuf_size == 0) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
373 (iocd->stmf_obuf_size > iocd->stmf_ibuf_size)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
374 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
375 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
376 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
377 ret = sbd_import_lu((sbd_import_lu_t *)ibuf,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
378 iocd->stmf_ibuf_size, &iocd->stmf_error, 0, NULL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
379 bcopy(ibuf, obuf, iocd->stmf_obuf_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
380 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
381 case SBD_IOCTL_DELETE_LU:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
382 if (iocd->stmf_ibuf_size < (sizeof (sbd_delete_lu_t) - 8)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
383 ret = EFAULT;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
384 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
385 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
386 if (iocd->stmf_obuf_size) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
387 ret = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
388 break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
389 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
390 ret = sbd_delete_lu((sbd_delete_lu_t *)ibuf,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
391 iocd->stmf_ibuf_size, &iocd->stmf_error);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
392 break;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
393 case SBD_IOCTL_MODIFY_LU:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
394 if (iocd->stmf_ibuf_size < (sizeof (sbd_modify_lu_t) - 8)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
395 ret = EFAULT;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
396 break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
397 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
398 if (iocd->stmf_obuf_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
399 ret = EINVAL;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
400 break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
401 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
402 ret = sbd_modify_lu((sbd_modify_lu_t *)ibuf,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
403 iocd->stmf_ibuf_size, &iocd->stmf_error);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
404 break;
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
405 case SBD_IOCTL_SET_GLOBAL_LU:
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
406 if (iocd->stmf_ibuf_size < (sizeof (sbd_global_props_t) - 8)) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
407 ret = EFAULT;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
408 break;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
409 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
410 if (iocd->stmf_obuf_size) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
411 ret = EINVAL;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
412 break;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
413 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
414 ret = sbd_set_global_props((sbd_global_props_t *)ibuf,
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
415 iocd->stmf_ibuf_size, &iocd->stmf_error);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
416 break;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
417 case SBD_IOCTL_GET_GLOBAL_LU:
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
418 if (iocd->stmf_ibuf_size) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
419 ret = EINVAL;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
420 break;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
421 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
422 if (iocd->stmf_obuf_size < sizeof (sbd_global_props_t)) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
423 ret = EINVAL;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
424 break;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
425 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
426 ret = sbd_get_global_props((sbd_global_props_t *)obuf,
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
427 iocd->stmf_obuf_size, &iocd->stmf_error);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
428 break;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
429 case SBD_IOCTL_GET_LU_PROPS:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
430 if (iocd->stmf_ibuf_size < (sizeof (sbd_lu_props_t) - 8)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
431 ret = EFAULT;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
432 break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
433 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
434 if (iocd->stmf_obuf_size < sizeof (sbd_lu_props_t)) {
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
435 ret = EINVAL;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
436 break;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
437 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
438 ret = sbd_get_lu_props((sbd_lu_props_t *)ibuf,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
439 iocd->stmf_ibuf_size, (sbd_lu_props_t *)obuf,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
440 iocd->stmf_obuf_size, &iocd->stmf_error);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
441 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
442 case SBD_IOCTL_GET_LU_LIST:
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
443 mutex_enter(&sbd_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
444 iocd->stmf_obuf_max_nentries = sbd_lu_count;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
445 iocd->stmf_obuf_nentries = min((iocd->stmf_obuf_size >> 4),
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
446 sbd_lu_count);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
447 for (nsl = sbd_lu_list, i = 0; nsl &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
448 (i < iocd->stmf_obuf_nentries); i++, nsl = nsl->sl_next) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
449 bcopy(nsl->sl_device_id + 4,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
450 &(((uint8_t *)obuf)[i << 4]), 16);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
451 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
452 mutex_exit(&sbd_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
453 ret = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
454 iocd->stmf_error = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
455 break;
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
456 case SBD_IOCTL_GET_UNMAP_PROPS:
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
457 if (iocd->stmf_ibuf_size < sizeof (sbd_unmap_props_t)) {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
458 ret = EFAULT;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
459 break;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
460 }
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
461 if (iocd->stmf_obuf_size < sizeof (sbd_unmap_props_t)) {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
462 ret = EINVAL;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
463 break;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
464 }
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
465 ret = sbd_get_unmap_props((sbd_unmap_props_t *)ibuf,
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
466 (sbd_unmap_props_t *)obuf, &iocd->stmf_error);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
467 break;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
468 default:
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
469 ret = ENOTTY;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
470 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
471
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
472 if (ret == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
473 ret = stmf_copyout_iocdata(data, mode, iocd, obuf);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
474 } else if (iocd->stmf_error) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
475 (void) stmf_copyout_iocdata(data, mode, iocd, obuf);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
476 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
477 if (obuf) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
478 kmem_free(obuf, iocd->stmf_obuf_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
479 obuf = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
480 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
481 if (ibuf) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
482 kmem_free(ibuf, iocd->stmf_ibuf_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
483 ibuf = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
484 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
485 kmem_free(iocd, sizeof (stmf_iocdata_t));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
486 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
487 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
488
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
489 /* ARGSUSED */
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
490 void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
491 sbd_lp_cb(stmf_lu_provider_t *lp, int cmd, void *arg, uint32_t flags)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
492 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
493 nvpair_t *np;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
494 char *s;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
495 sbd_import_lu_t *ilu;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
496 uint32_t ilu_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
497 uint32_t struct_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
498 uint32_t err_ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
499 int iret;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
500
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
501 if ((cmd != STMF_PROVIDER_DATA_UPDATED) || (arg == NULL)) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
502 return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
503 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
504
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
505 if ((flags & (STMF_PCB_STMF_ONLINING | STMF_PCB_PREG_COMPLETE)) == 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
506 return;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
507 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
508
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
509 np = NULL;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
510 ilu_sz = 1024;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
511 ilu = (sbd_import_lu_t *)kmem_zalloc(ilu_sz, KM_SLEEP);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
512 while ((np = nvlist_next_nvpair((nvlist_t *)arg, np)) != NULL) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
513 if (nvpair_type(np) != DATA_TYPE_STRING) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
514 continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
515 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
516 if (nvpair_value_string(np, &s) != 0) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
517 continue;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
518 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
519 struct_sz = max(8, strlen(s) + 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
520 struct_sz += sizeof (sbd_import_lu_t) - 8;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
521 if (struct_sz > ilu_sz) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
522 kmem_free(ilu, ilu_sz);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
523 ilu_sz = struct_sz + 32;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
524 ilu = (sbd_import_lu_t *)kmem_zalloc(ilu_sz, KM_SLEEP);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
525 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
526 ilu->ilu_struct_size = struct_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
527 (void) strcpy(ilu->ilu_meta_fname, s);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
528 iret = sbd_import_lu(ilu, struct_sz, &err_ret, 0, NULL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
529 if (iret) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
530 stmf_trace(0, "sbd_lp_cb: import_lu failed, ret = %d, "
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
531 "err_ret = %d", iret, err_ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
532 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
533 stmf_trace(0, "Imported the LU %s", nvpair_name(np));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
534 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
535 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
536
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
537 if (ilu) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
538 kmem_free(ilu, ilu_sz);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
539 ilu = NULL;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
540 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
541 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
542
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
543 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
544 sbd_link_lu(sbd_lu_t *sl)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
545 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
546 sbd_lu_t *nsl;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
547
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
548 mutex_enter(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
549 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
550 ASSERT(sl->sl_trans_op != SL_OP_NONE);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
551
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
552 if (sl->sl_flags & SL_LINKED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
553 mutex_exit(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
554 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
555 return (SBD_ALREADY);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
556 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
557 for (nsl = sbd_lu_list; nsl; nsl = nsl->sl_next) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
558 if (strcmp(nsl->sl_name, sl->sl_name) == 0)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
559 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
560 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
561 if (nsl) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
562 mutex_exit(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
563 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
564 return (SBD_ALREADY);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
565 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
566 sl->sl_next = sbd_lu_list;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
567 sbd_lu_list = sl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
568 sl->sl_flags |= SL_LINKED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
569 mutex_exit(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
570 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
571 return (SBD_SUCCESS);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
572 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
573
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
574 void
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
575 sbd_unlink_lu(sbd_lu_t *sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
576 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
577 sbd_lu_t **ppnsl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
578
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
579 mutex_enter(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
580 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
581 ASSERT(sl->sl_trans_op != SL_OP_NONE);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
582
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
583 ASSERT(sl->sl_flags & SL_LINKED);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
584 for (ppnsl = &sbd_lu_list; *ppnsl; ppnsl = &((*ppnsl)->sl_next)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
585 if (*ppnsl == sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
586 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
587 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
588 ASSERT(*ppnsl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
589 *ppnsl = (*ppnsl)->sl_next;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
590 sl->sl_flags &= ~SL_LINKED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
591 mutex_exit(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
592 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
593 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
594
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
595 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
596 sbd_find_and_lock_lu(uint8_t *guid, uint8_t *meta_name, uint8_t op,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
597 sbd_lu_t **ppsl)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
598 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
599 sbd_lu_t *sl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
600 int found = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
601 sbd_status_t sret;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
602
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
603 mutex_enter(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
604 for (sl = sbd_lu_list; sl; sl = sl->sl_next) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
605 if (guid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
606 found = bcmp(sl->sl_device_id + 4, guid, 16) == 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
607 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
608 found = strcmp(sl->sl_name, (char *)meta_name) == 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
609 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
610 if (found)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
611 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
612 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
613 if (!found) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
614 mutex_exit(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
615 return (SBD_NOT_FOUND);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
616 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
617 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
618 if (sl->sl_trans_op == SL_OP_NONE) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
619 sl->sl_trans_op = op;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
620 *ppsl = sl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
621 sret = SBD_SUCCESS;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
622 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
623 sret = SBD_BUSY;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
624 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
625 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
626 mutex_exit(&sbd_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
627 return (sret);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
628 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
629
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
630 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
631 sbd_read_meta(sbd_lu_t *sl, uint64_t offset, uint64_t size, uint8_t *buf)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
632 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
633 uint64_t meta_align;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
634 uint64_t starting_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
635 uint64_t data_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
636 uint64_t ending_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
637 uint64_t io_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
638 uint8_t *io_buf;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
639 vnode_t *vp;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
640 sbd_status_t ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
641 ssize_t resid;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
642 int vret;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
643
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
644 ASSERT(sl->sl_flags & SL_META_OPENED);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
645 if (sl->sl_flags & SL_SHARED_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
646 meta_align = (((uint64_t)1) << sl->sl_data_blocksize_shift) - 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
647 vp = sl->sl_data_vp;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
648 ASSERT(vp);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
649 } else {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
650 meta_align = (((uint64_t)1) << sl->sl_meta_blocksize_shift) - 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
651 if ((sl->sl_flags & SL_ZFS_META) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
652 vp = sl->sl_meta_vp;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
653 ASSERT(vp);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
654 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
655 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
656 starting_off = offset & ~(meta_align);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
657 data_off = offset & meta_align;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
658 ending_off = (offset + size + meta_align) & (~meta_align);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
659 if (ending_off > sl->sl_meta_size_used) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
660 bzero(buf, size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
661 if (starting_off >= sl->sl_meta_size_used) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
662 return (SBD_SUCCESS);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
663 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
664 ending_off = (sl->sl_meta_size_used + meta_align) &
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
665 (~meta_align);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
666 if (size > (ending_off - (starting_off + data_off))) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
667 size = ending_off - (starting_off + data_off);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
668 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
669 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
670 io_size = ending_off - starting_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
671 io_buf = (uint8_t *)kmem_zalloc(io_size, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
672 ASSERT((starting_off + io_size) <= sl->sl_total_meta_size);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
673
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
674 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
675 * Don't proceed if the device has been closed
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
676 * This can occur on an access state change to standby or
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
677 * a delete. The writer lock is acquired before closing the
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
678 * lu. If importing, reading the metadata is valid, hence
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
679 * the check on SL_OP_IMPORT_LU.
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
680 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
681 rw_enter(&sl->sl_access_state_lock, RW_READER);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
682 if ((sl->sl_flags & SL_MEDIA_LOADED) == 0 &&
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
683 sl->sl_trans_op != SL_OP_IMPORT_LU) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
684 rw_exit(&sl->sl_access_state_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
685 ret = SBD_FILEIO_FAILURE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
686 goto sbd_read_meta_failure;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
687 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
688 if (sl->sl_flags & SL_ZFS_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
689 if ((ret = sbd_read_zfs_meta(sl, io_buf, io_size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
690 starting_off)) != SBD_SUCCESS) {
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
691 rw_exit(&sl->sl_access_state_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
692 goto sbd_read_meta_failure;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
693 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
694 } else {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
695 vret = vn_rdwr(UIO_READ, vp, (caddr_t)io_buf, (ssize_t)io_size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
696 (offset_t)starting_off, UIO_SYSSPACE, FRSYNC,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
697 RLIM64_INFINITY, CRED(), &resid);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
698
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
699 if (vret || resid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
700 ret = SBD_FILEIO_FAILURE | vret;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
701 rw_exit(&sl->sl_access_state_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
702 goto sbd_read_meta_failure;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
703 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
704 }
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
705 rw_exit(&sl->sl_access_state_lock);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
706
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
707 bcopy(io_buf + data_off, buf, size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
708 ret = SBD_SUCCESS;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
709
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
710 sbd_read_meta_failure:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
711 kmem_free(io_buf, io_size);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
712 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
713 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
714
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
715 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
716 sbd_write_meta(sbd_lu_t *sl, uint64_t offset, uint64_t size, uint8_t *buf)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
717 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
718 uint64_t meta_align;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
719 uint64_t starting_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
720 uint64_t data_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
721 uint64_t ending_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
722 uint64_t io_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
723 uint8_t *io_buf;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
724 vnode_t *vp;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
725 sbd_status_t ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
726 ssize_t resid;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
727 int vret;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
728
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
729 ASSERT(sl->sl_flags & SL_META_OPENED);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
730 if (sl->sl_flags & SL_SHARED_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
731 meta_align = (((uint64_t)1) << sl->sl_data_blocksize_shift) - 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
732 vp = sl->sl_data_vp;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
733 ASSERT(vp);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
734 } else {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
735 meta_align = (((uint64_t)1) << sl->sl_meta_blocksize_shift) - 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
736 if ((sl->sl_flags & SL_ZFS_META) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
737 vp = sl->sl_meta_vp;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
738 ASSERT(vp);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
739 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
740 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
741 starting_off = offset & ~(meta_align);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
742 data_off = offset & meta_align;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
743 ending_off = (offset + size + meta_align) & (~meta_align);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
744 io_size = ending_off - starting_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
745 io_buf = (uint8_t *)kmem_zalloc(io_size, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
746 ret = sbd_read_meta(sl, starting_off, io_size, io_buf);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
747 if (ret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
748 goto sbd_write_meta_failure;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
749 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
750 bcopy(buf, io_buf + data_off, size);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
751 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
752 * Don't proceed if the device has been closed
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
753 * This can occur on an access state change to standby or
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
754 * a delete. The writer lock is acquired before closing the
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
755 * lu. If importing, reading the metadata is valid, hence
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
756 * the check on SL_OP_IMPORT_LU.
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
757 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
758 rw_enter(&sl->sl_access_state_lock, RW_READER);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
759 if ((sl->sl_flags & SL_MEDIA_LOADED) == 0 &&
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
760 sl->sl_trans_op != SL_OP_IMPORT_LU) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
761 rw_exit(&sl->sl_access_state_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
762 ret = SBD_FILEIO_FAILURE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
763 goto sbd_write_meta_failure;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
764 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
765 if (sl->sl_flags & SL_ZFS_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
766 if ((ret = sbd_write_zfs_meta(sl, io_buf, io_size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
767 starting_off)) != SBD_SUCCESS) {
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
768 rw_exit(&sl->sl_access_state_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
769 goto sbd_write_meta_failure;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
770 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
771 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
772 vret = vn_rdwr(UIO_WRITE, vp, (caddr_t)io_buf, (ssize_t)io_size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
773 (offset_t)starting_off, UIO_SYSSPACE, FDSYNC,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
774 RLIM64_INFINITY, CRED(), &resid);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
775
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
776 if (vret || resid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
777 ret = SBD_FILEIO_FAILURE | vret;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
778 rw_exit(&sl->sl_access_state_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
779 goto sbd_write_meta_failure;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
780 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
781 }
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
782 rw_exit(&sl->sl_access_state_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
783
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
784 ret = SBD_SUCCESS;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
785
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
786 sbd_write_meta_failure:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
787 kmem_free(io_buf, io_size);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
788 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
789 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
790
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
791 uint8_t
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
792 sbd_calc_sum(uint8_t *buf, int size)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
793 {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
794 uint8_t s = 0;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
795
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
796 while (size > 0)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
797 s += buf[--size];
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
798
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
799 return (s);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
800 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
801
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
802 uint8_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
803 sbd_calc_section_sum(sm_section_hdr_t *sm, uint32_t sz)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
804 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
805 uint8_t s, o;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
806
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
807 o = sm->sms_chksum;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
808 sm->sms_chksum = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
809 s = sbd_calc_sum((uint8_t *)sm, sz);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
810 sm->sms_chksum = o;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
811
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
812 return (s);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
813 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
814
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
815 uint32_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
816 sbd_strlen(char *str, uint32_t maxlen)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
817 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
818 uint32_t i;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
819
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
820 for (i = 0; i < maxlen; i++) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
821 if (str[i] == 0)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
822 return (i);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
823 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
824 return (i);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
825 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
826
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
827 void
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
828 sbd_swap_meta_start(sbd_meta_start_t *sm)
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
829 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
830 if (sm->sm_magic == SBD_MAGIC)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
831 return;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
832 sm->sm_magic = BSWAP_64(sm->sm_magic);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
833 sm->sm_meta_size = BSWAP_64(sm->sm_meta_size);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
834 sm->sm_meta_size_used = BSWAP_64(sm->sm_meta_size_used);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
835 sm->sm_ver_major = BSWAP_16(sm->sm_ver_major);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
836 sm->sm_ver_minor = BSWAP_16(sm->sm_ver_minor);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
837 sm->sm_ver_subminor = BSWAP_16(sm->sm_ver_subminor);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
838 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
839
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
840 void
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
841 sbd_swap_section_hdr(sm_section_hdr_t *sm)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
842 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
843 if (sm->sms_data_order == SMS_DATA_ORDER)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
844 return;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
845 sm->sms_offset = BSWAP_64(sm->sms_offset);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
846 sm->sms_size = BSWAP_32(sm->sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
847 sm->sms_id = BSWAP_16(sm->sms_id);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
848 sm->sms_chksum += SMS_DATA_ORDER - sm->sms_data_order;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
849 sm->sms_data_order = SMS_DATA_ORDER;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
850 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
851
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
852 void
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
853 sbd_swap_lu_info_1_0(sbd_lu_info_1_0_t *sli)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
854 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
855 sbd_swap_section_hdr(&sli->sli_sms_header);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
856 if (sli->sli_data_order == SMS_DATA_ORDER)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
857 return;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
858 sli->sli_sms_header.sms_chksum += SMS_DATA_ORDER - sli->sli_data_order;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
859 sli->sli_data_order = SMS_DATA_ORDER;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
860 sli->sli_total_store_size = BSWAP_64(sli->sli_total_store_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
861 sli->sli_total_meta_size = BSWAP_64(sli->sli_total_meta_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
862 sli->sli_lu_data_offset = BSWAP_64(sli->sli_lu_data_offset);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
863 sli->sli_lu_data_size = BSWAP_64(sli->sli_lu_data_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
864 sli->sli_flags = BSWAP_32(sli->sli_flags);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
865 sli->sli_blocksize = BSWAP_16(sli->sli_blocksize);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
866 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
867
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
868 void
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
869 sbd_swap_lu_info_1_1(sbd_lu_info_1_1_t *sli)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
870 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
871 sbd_swap_section_hdr(&sli->sli_sms_header);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
872 if (sli->sli_data_order == SMS_DATA_ORDER)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
873 return;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
874 sli->sli_sms_header.sms_chksum += SMS_DATA_ORDER - sli->sli_data_order;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
875 sli->sli_data_order = SMS_DATA_ORDER;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
876 sli->sli_flags = BSWAP_32(sli->sli_flags);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
877 sli->sli_lu_size = BSWAP_64(sli->sli_lu_size);
10114
023993413f11 6845064 SUNWstmfu package dependency on dynamically linked libs not captured
tim szeto <Tim.Szeto@Sun.COM>
parents: 10113
diff changeset
878 sli->sli_meta_fname_offset = BSWAP_64(sli->sli_meta_fname_offset);
10365
17f1ffe79b9e 6862457 sbd_swap_lu_info_1_1 uses BSWAP_16 when BSWAP_64 is required
srivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>
parents: 10114
diff changeset
879 sli->sli_data_fname_offset = BSWAP_64(sli->sli_data_fname_offset);
17f1ffe79b9e 6862457 sbd_swap_lu_info_1_1 uses BSWAP_16 when BSWAP_64 is required
srivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>
parents: 10114
diff changeset
880 sli->sli_serial_offset = BSWAP_64(sli->sli_serial_offset);
17f1ffe79b9e 6862457 sbd_swap_lu_info_1_1 uses BSWAP_16 when BSWAP_64 is required
srivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>
parents: 10114
diff changeset
881 sli->sli_alias_offset = BSWAP_64(sli->sli_alias_offset);
10962
6e86215199ca 6873154 sli_mgmt_url_offset needs to be swapped in sbd_swap_lu_info_1_1
tim szeto <Tim.Szeto@Sun.COM>
parents: 10765
diff changeset
882 sli->sli_mgmt_url_offset = BSWAP_64(sli->sli_mgmt_url_offset);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
883 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
884
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
885 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
886 sbd_load_section_hdr(sbd_lu_t *sl, sm_section_hdr_t *sms)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
887 {
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
888 sm_section_hdr_t h;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
889 uint64_t st;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
890 sbd_status_t ret;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
891
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
892 for (st = sl->sl_meta_offset + sizeof (sbd_meta_start_t);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
893 st < sl->sl_meta_size_used; st += h.sms_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
894 if ((ret = sbd_read_meta(sl, st, sizeof (sm_section_hdr_t),
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
895 (uint8_t *)&h)) != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
896 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
897 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
898 if (h.sms_data_order != SMS_DATA_ORDER) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
899 sbd_swap_section_hdr(&h);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
900 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
901 if ((h.sms_data_order != SMS_DATA_ORDER) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
902 (h.sms_offset != st) || (h.sms_size < sizeof (h)) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
903 ((st + h.sms_size) > sl->sl_meta_size_used)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
904 return (SBD_META_CORRUPTED);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
905 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
906 if (h.sms_id == sms->sms_id) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
907 bcopy(&h, sms, sizeof (h));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
908 return (SBD_SUCCESS);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
909 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
910 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
911
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
912 return (SBD_NOT_FOUND);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
913 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
914
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
915 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
916 sbd_load_meta_start(sbd_lu_t *sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
917 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
918 sbd_meta_start_t *sm;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
919 sbd_status_t ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
920
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
921 /* Fake meta params initially */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
922 sl->sl_total_meta_size = (uint64_t)-1;
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
923 sl->sl_meta_size_used = sl->sl_meta_offset + sizeof (sbd_meta_start_t);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
924
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
925 sm = kmem_zalloc(sizeof (*sm), KM_SLEEP);
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
926 ret = sbd_read_meta(sl, sl->sl_meta_offset, sizeof (*sm),
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
927 (uint8_t *)sm);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
928 if (ret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
929 goto load_meta_start_failed;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
930 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
931
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
932 if (sm->sm_magic != SBD_MAGIC) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
933 sbd_swap_meta_start(sm);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
934 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
935
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
936 if ((sm->sm_magic != SBD_MAGIC) || (sbd_calc_sum((uint8_t *)sm,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
937 sizeof (*sm) - 1) != sm->sm_chksum)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
938 ret = SBD_META_CORRUPTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
939 goto load_meta_start_failed;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
940 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
941
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
942 if (sm->sm_ver_major != SBD_VER_MAJOR) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
943 ret = SBD_NOT_SUPPORTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
944 goto load_meta_start_failed;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
945 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
946
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
947 sl->sl_total_meta_size = sm->sm_meta_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
948 sl->sl_meta_size_used = sm->sm_meta_size_used;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
949 ret = SBD_SUCCESS;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
950
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
951 load_meta_start_failed:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
952 kmem_free(sm, sizeof (*sm));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
953 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
954 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
955
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
956 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
957 sbd_write_meta_start(sbd_lu_t *sl, uint64_t meta_size, uint64_t meta_size_used)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
958 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
959 sbd_meta_start_t *sm;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
960 sbd_status_t ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
961
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
962 sm = (sbd_meta_start_t *)kmem_zalloc(sizeof (sbd_meta_start_t),
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
963 KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
964
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
965 sm->sm_magic = SBD_MAGIC;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
966 sm->sm_meta_size = meta_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
967 sm->sm_meta_size_used = meta_size_used;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
968 sm->sm_ver_major = SBD_VER_MAJOR;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
969 sm->sm_ver_minor = SBD_VER_MINOR;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
970 sm->sm_ver_subminor = SBD_VER_SUBMINOR;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
971 sm->sm_chksum = sbd_calc_sum((uint8_t *)sm, sizeof (*sm) - 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
972
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
973 ret = sbd_write_meta(sl, sl->sl_meta_offset, sizeof (*sm),
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
974 (uint8_t *)sm);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
975 kmem_free(sm, sizeof (*sm));
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
976
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
977 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
978 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
979
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
980 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
981 sbd_read_meta_section(sbd_lu_t *sl, sm_section_hdr_t **ppsms, uint16_t sms_id)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
982 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
983 sbd_status_t ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
984 sm_section_hdr_t sms;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
985 int alloced = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
986
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
987 mutex_enter(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
988 if (((*ppsms) == NULL) || ((*ppsms)->sms_offset == 0)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
989 bzero(&sms, sizeof (sm_section_hdr_t));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
990 sms.sms_id = sms_id;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
991 if ((ret = sbd_load_section_hdr(sl, &sms)) != SBD_SUCCESS) {
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
992 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
993 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
994 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
995 if ((*ppsms) == NULL) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
996 *ppsms = (sm_section_hdr_t *)kmem_zalloc(
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
997 sms.sms_size, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
998 alloced = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
999 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1000 bcopy(&sms, *ppsms, sizeof (sm_section_hdr_t));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1001 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1002 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1003
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1004 ret = sbd_read_meta(sl, (*ppsms)->sms_offset, (*ppsms)->sms_size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1005 (uint8_t *)(*ppsms));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1006 if (ret == SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1007 uint8_t s;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1008 if ((*ppsms)->sms_data_order != SMS_DATA_ORDER)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1009 sbd_swap_section_hdr(*ppsms);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1010 if ((*ppsms)->sms_id != SMS_ID_UNUSED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1011 s = sbd_calc_section_sum(*ppsms, (*ppsms)->sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1012 if (s != (*ppsms)->sms_chksum)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1013 ret = SBD_META_CORRUPTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1014 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1015 }
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1016 mutex_exit(&sl->sl_metadata_lock);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1017
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1018 if ((ret != SBD_SUCCESS) && alloced)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1019 kmem_free(*ppsms, sms.sms_size);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1020 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1021 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1022
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1023 sbd_status_t
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1024 sbd_load_section_hdr_unbuffered(sbd_lu_t *sl, sm_section_hdr_t *sms)
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1025 {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1026 sbd_status_t ret;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1027
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1028 /*
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1029 * Bypass buffering and re-read the meta data from permanent storage.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1030 */
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1031 if (sl->sl_flags & SL_ZFS_META) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1032 if ((ret = sbd_open_zfs_meta(sl)) != SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1033 return (ret);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1034 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1035 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1036 /* Re-get the meta sizes into sl */
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1037 if ((ret = sbd_load_meta_start(sl)) != SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1038 return (ret);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1039 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1040 return (sbd_load_section_hdr(sl, sms));
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1041 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1042
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1043 sbd_status_t
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1044 sbd_write_meta_section(sbd_lu_t *sl, sm_section_hdr_t *sms)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1045 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1046 sm_section_hdr_t t;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1047 uint64_t off, s;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1048 uint64_t unused_start;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1049 sbd_status_t ret;
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1050 sbd_status_t write_meta_ret = SBD_SUCCESS;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1051 uint8_t *cb;
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1052 int meta_size_changed = 0;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1053 sm_section_hdr_t sms_before_unused = {0};
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1054
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1055 mutex_enter(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1056 write_meta_section_again:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1057 if (sms->sms_offset) {
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1058 /*
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1059 * If the section already exists and the size is the
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1060 * same as this new data then overwrite in place. If
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1061 * the sizes are different then mark the existing as
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1062 * unused and look for free space.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1063 */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1064 ret = sbd_read_meta(sl, sms->sms_offset, sizeof (t),
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1065 (uint8_t *)&t);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1066 if (ret != SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1067 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1068 return (ret);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1069 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1070 if (t.sms_data_order != SMS_DATA_ORDER) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1071 sbd_swap_section_hdr(&t);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1072 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1073 if (t.sms_id != sms->sms_id) {
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1074 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1075 return (SBD_INVALID_ARG);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1076 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1077 if (t.sms_size == sms->sms_size) {
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1078 ret = sbd_write_meta(sl, sms->sms_offset,
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1079 sms->sms_size, (uint8_t *)sms);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1080 mutex_exit(&sl->sl_metadata_lock);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1081 return (ret);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1082 }
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1083 sms_before_unused = t;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1084
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1085 t.sms_id = SMS_ID_UNUSED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1086 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1087 * For unused sections we only use chksum of the header. for
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1088 * all other sections, the chksum is for the entire section.
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1089 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1090 t.sms_chksum = sbd_calc_section_sum(&t, sizeof (t));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1091 ret = sbd_write_meta(sl, t.sms_offset, sizeof (t),
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1092 (uint8_t *)&t);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1093 if (ret != SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1094 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1095 return (ret);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1096 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1097 sms->sms_offset = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1098 } else {
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1099 /* Section location is unknown, search for it. */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1100 t.sms_id = sms->sms_id;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1101 t.sms_data_order = SMS_DATA_ORDER;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1102 ret = sbd_load_section_hdr(sl, &t);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1103 if (ret == SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1104 sms->sms_offset = t.sms_offset;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1105 sms->sms_chksum =
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1106 sbd_calc_section_sum(sms, sms->sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1107 goto write_meta_section_again;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1108 } else if (ret != SBD_NOT_FOUND) {
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1109 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1110 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1111 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1112 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1113
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1114 /*
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1115 * At this point we know that section does not already exist.
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1116 * Find space large enough to hold the section or grow meta if
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1117 * possible.
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1118 */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1119 unused_start = 0;
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1120 s = 0; /* size of space found */
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1121
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1122 /*
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1123 * Search all sections for unused space of sufficient size.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1124 * The first one found is taken. Contiguous unused sections
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1125 * will be combined.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1126 */
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1127 for (off = sl->sl_meta_offset + sizeof (sbd_meta_start_t);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1128 off < sl->sl_meta_size_used; off += t.sms_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1129 ret = sbd_read_meta(sl, off, sizeof (t), (uint8_t *)&t);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1130 if (ret != SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1131 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1132 return (ret);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1133 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1134 if (t.sms_data_order != SMS_DATA_ORDER)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1135 sbd_swap_section_hdr(&t);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1136 if (t.sms_size == 0) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1137 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1138 return (SBD_META_CORRUPTED);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1139 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1140 if (t.sms_id == SMS_ID_UNUSED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1141 if (unused_start == 0)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1142 unused_start = off;
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1143 /*
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1144 * Calculate size of the unused space, break out
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1145 * if it satisfies the requirement.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1146 */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1147 s = t.sms_size - unused_start + off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1148 if ((s == sms->sms_size) || (s >= (sms->sms_size +
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1149 sizeof (t)))) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1150 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1151 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1152 s = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1153 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1154 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1155 unused_start = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1156 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1157 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1158
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1159 off = (unused_start == 0) ? sl->sl_meta_size_used : unused_start;
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1160 /*
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1161 * If none found, how much room is at the end?
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1162 * See if the data can be expanded.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1163 */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1164 if (s == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1165 s = sl->sl_total_meta_size - off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1166 if (s >= sms->sms_size || !(sl->sl_flags & SL_SHARED_META)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1167 s = sms->sms_size;
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1168 meta_size_changed = 1;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1169 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1170 s = 0;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1171 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1172 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1173
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1174 if (s == 0) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1175 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1176 return (SBD_ALLOC_FAILURE);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1177 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1178
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1179 sms->sms_offset = off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1180 sms->sms_chksum = sbd_calc_section_sum(sms, sms->sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1181 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1182 * Since we may have to write more than one section (current +
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1183 * any unused), use a combined buffer.
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1184 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1185 cb = kmem_zalloc(s, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1186 bcopy(sms, cb, sms->sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1187 if (s > sms->sms_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1188 t.sms_offset = off + sms->sms_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1189 t.sms_size = s - sms->sms_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1190 t.sms_id = SMS_ID_UNUSED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1191 t.sms_data_order = SMS_DATA_ORDER;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1192 t.sms_chksum = sbd_calc_section_sum(&t, sizeof (t));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1193 bcopy(&t, cb + sms->sms_size, sizeof (t));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1194 }
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1195 /*
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1196 * Two write events & statuses take place. Failure writing the
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1197 * meta section takes precedence, can possibly be rolled back,
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1198 * & gets reported. Else return status from writing the meta start.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1199 */
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1200 ret = SBD_SUCCESS; /* Set a default, it's not always loaded below. */
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1201 if (meta_size_changed) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1202 uint64_t old_meta_size;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1203 uint64_t old_sz_used = sl->sl_meta_size_used; /* save a copy */
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1204 old_meta_size = sl->sl_total_meta_size; /* save a copy */
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1205
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1206 write_meta_ret = sbd_write_meta(sl, off, s, cb);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1207 if (write_meta_ret == SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1208 sl->sl_meta_size_used = off + s;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1209 if (sl->sl_total_meta_size < sl->sl_meta_size_used) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1210 uint64_t meta_align =
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1211 (((uint64_t)1) <<
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1212 sl->sl_meta_blocksize_shift) - 1;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1213 sl->sl_total_meta_size =
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1214 (sl->sl_meta_size_used + meta_align) &
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1215 (~meta_align);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1216 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1217 ret = sbd_write_meta_start(sl, sl->sl_total_meta_size,
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1218 sl->sl_meta_size_used);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1219 if (ret != SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1220 sl->sl_meta_size_used = old_sz_used;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1221 sl->sl_total_meta_size = old_meta_size;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1222 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1223 } else {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1224 sl->sl_meta_size_used = old_sz_used;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1225 sl->sl_total_meta_size = old_meta_size;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1226 }
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1227 } else {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1228 write_meta_ret = sbd_write_meta(sl, off, s, cb);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1229 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1230 if ((write_meta_ret != SBD_SUCCESS) &&
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1231 (sms_before_unused.sms_offset != 0)) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1232 sm_section_hdr_t new_sms;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1233 sm_section_hdr_t *unused_sms;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1234 /*
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1235 * On failure writing the meta section attempt to undo
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1236 * the change to unused.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1237 * Re-read the meta data from permanent storage.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1238 * The section id can't exist for undo to be possible.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1239 * Read what should be the entire old section data and
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1240 * insure the old data's still present by validating
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1241 * against it's old checksum.
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1242 */
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1243 new_sms.sms_id = sms->sms_id;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1244 new_sms.sms_data_order = SMS_DATA_ORDER;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1245 if (sbd_load_section_hdr_unbuffered(sl, &new_sms) !=
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1246 SBD_NOT_FOUND) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1247 goto done;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1248 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1249 unused_sms = kmem_zalloc(sms_before_unused.sms_size, KM_SLEEP);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1250 if (sbd_read_meta(sl, sms_before_unused.sms_offset,
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1251 sms_before_unused.sms_size,
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1252 (uint8_t *)unused_sms) != SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1253 goto done;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1254 }
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1255 if (unused_sms->sms_data_order != SMS_DATA_ORDER) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1256 sbd_swap_section_hdr(unused_sms);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1257 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1258 if (unused_sms->sms_id != SMS_ID_UNUSED) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1259 goto done;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1260 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1261 if (unused_sms->sms_offset != sms_before_unused.sms_offset) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1262 goto done;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1263 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1264 if (unused_sms->sms_size != sms_before_unused.sms_size) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1265 goto done;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1266 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1267 unused_sms->sms_id = sms_before_unused.sms_id;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1268 if (sbd_calc_section_sum(unused_sms,
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1269 sizeof (sm_section_hdr_t)) !=
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1270 sbd_calc_section_sum(&sms_before_unused,
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1271 sizeof (sm_section_hdr_t))) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1272 goto done;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1273 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1274 unused_sms->sms_chksum =
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1275 sbd_calc_section_sum(unused_sms, unused_sms->sms_size);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1276 if (unused_sms->sms_chksum != sms_before_unused.sms_chksum) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1277 goto done;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1278 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1279 (void) sbd_write_meta(sl, unused_sms->sms_offset,
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1280 sizeof (sm_section_hdr_t), (uint8_t *)unused_sms);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1281 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1282 done:
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1283 mutex_exit(&sl->sl_metadata_lock);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1284 kmem_free(cb, s);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1285 if (write_meta_ret != SBD_SUCCESS) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1286 return (write_meta_ret);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1287 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1288 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1289 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1290
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1291 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1292 sbd_write_lu_info(sbd_lu_t *sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1293 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1294 sbd_lu_info_1_1_t *sli;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1295 int s;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1296 uint8_t *p;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1297 char *zvol_name = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1298 sbd_status_t ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1299
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1300 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1301
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1302 s = sl->sl_serial_no_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1303 if ((sl->sl_flags & (SL_SHARED_META | SL_ZFS_META)) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1304 if (sl->sl_data_filename) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1305 s += strlen(sl->sl_data_filename) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1306 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1307 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1308 if (sl->sl_flags & SL_ZFS_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1309 zvol_name = sbd_get_zvol_name(sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1310 s += strlen(zvol_name) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1311 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1312 if (sl->sl_alias) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1313 s += strlen(sl->sl_alias) + 1;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1314 }
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1315 if (sl->sl_mgmt_url) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1316 s += strlen(sl->sl_mgmt_url) + 1;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1317 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1318 sli = (sbd_lu_info_1_1_t *)kmem_zalloc(sizeof (*sli) + s, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1319 p = sli->sli_buf;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1320 if ((sl->sl_flags & (SL_SHARED_META | SL_ZFS_META)) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1321 sli->sli_flags |= SLI_SEPARATE_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1322 (void) strcpy((char *)p, sl->sl_data_filename);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1323 sli->sli_data_fname_offset =
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1324 (uintptr_t)p - (uintptr_t)sli->sli_buf;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1325 sli->sli_flags |= SLI_DATA_FNAME_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1326 p += strlen(sl->sl_data_filename) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1327 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1328 if (sl->sl_flags & SL_ZFS_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1329 (void) strcpy((char *)p, zvol_name);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1330 sli->sli_meta_fname_offset =
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1331 (uintptr_t)p - (uintptr_t)sli->sli_buf;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1332 sli->sli_flags |= SLI_META_FNAME_VALID | SLI_ZFS_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1333 p += strlen(zvol_name) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1334 kmem_free(zvol_name, strlen(zvol_name) + 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1335 zvol_name = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1336 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1337 if (sl->sl_alias) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1338 (void) strcpy((char *)p, sl->sl_alias);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1339 sli->sli_alias_offset =
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1340 (uintptr_t)p - (uintptr_t)sli->sli_buf;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1341 sli->sli_flags |= SLI_ALIAS_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1342 p += strlen(sl->sl_alias) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1343 }
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1344 if (sl->sl_mgmt_url) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1345 (void) strcpy((char *)p, sl->sl_mgmt_url);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1346 sli->sli_mgmt_url_offset =
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1347 (uintptr_t)p - (uintptr_t)sli->sli_buf;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1348 sli->sli_flags |= SLI_MGMT_URL_VALID;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1349 p += strlen(sl->sl_mgmt_url) + 1;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1350 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1351 if (sl->sl_flags & SL_WRITE_PROTECTED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1352 sli->sli_flags |= SLI_WRITE_PROTECTED;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1353 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1354 if (sl->sl_flags & SL_SAVED_WRITE_CACHE_DISABLE) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1355 sli->sli_flags |= SLI_WRITEBACK_CACHE_DISABLE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1356 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1357 if (sl->sl_flags & SL_VID_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1358 bcopy(sl->sl_vendor_id, sli->sli_vid, 8);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1359 sli->sli_flags |= SLI_VID_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1360 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1361 if (sl->sl_flags & SL_PID_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1362 bcopy(sl->sl_product_id, sli->sli_pid, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1363 sli->sli_flags |= SLI_PID_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1364 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1365 if (sl->sl_flags & SL_REV_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1366 bcopy(sl->sl_revision, sli->sli_rev, 4);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1367 sli->sli_flags |= SLI_REV_VALID;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1368 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1369 if (sl->sl_serial_no_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1370 bcopy(sl->sl_serial_no, p, sl->sl_serial_no_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1371 sli->sli_serial_size = sl->sl_serial_no_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1372 sli->sli_serial_offset =
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1373 (uintptr_t)p - (uintptr_t)sli->sli_buf;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1374 sli->sli_flags |= SLI_SERIAL_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1375 p += sli->sli_serial_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1376 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1377 sli->sli_lu_size = sl->sl_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1378 sli->sli_data_blocksize_shift = sl->sl_data_blocksize_shift;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1379 sli->sli_data_order = SMS_DATA_ORDER;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1380 bcopy(sl->sl_device_id, sli->sli_device_id, 20);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1381
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1382 sli->sli_sms_header.sms_size = sizeof (*sli) + s;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1383 sli->sli_sms_header.sms_id = SMS_ID_LU_INFO_1_1;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1384 sli->sli_sms_header.sms_data_order = SMS_DATA_ORDER;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1385
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1386 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1387 ret = sbd_write_meta_section(sl, (sm_section_hdr_t *)sli);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1388 kmem_free(sli, sizeof (*sli) + s);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1389 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1390 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1391
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1392 /*
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1393 * Will scribble SL_UNMAP_ENABLED into sl_flags if we succeed.
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1394 */
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1395 static void
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1396 do_unmap_setup(sbd_lu_t *sl)
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1397 {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1398 ASSERT((sl->sl_flags & SL_UNMAP_ENABLED) == 0);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1399
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1400 if ((sl->sl_flags & SL_ZFS_META) == 0)
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1401 return; /* No UNMAP for you. */
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1402
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1403 sl->sl_flags |= SL_UNMAP_ENABLED;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1404 }
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1405
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1406 int
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1407 sbd_populate_and_register_lu(sbd_lu_t *sl, uint32_t *err_ret)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1408 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1409 stmf_lu_t *lu = sl->sl_lu;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1410 stmf_status_t ret;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1411
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1412 do_unmap_setup(sl);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
1413
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1414 lu->lu_id = (scsi_devid_desc_t *)sl->sl_device_id;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1415 if (sl->sl_alias) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1416 lu->lu_alias = sl->sl_alias;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1417 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1418 lu->lu_alias = sl->sl_name;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1419 }
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1420 if (sl->sl_access_state == SBD_LU_STANDBY) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1421 /* call set access state */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1422 ret = stmf_set_lu_access(lu, STMF_LU_STANDBY);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1423 if (ret != STMF_SUCCESS) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1424 *err_ret = SBD_RET_ACCESS_STATE_FAILED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1425 return (EIO);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1426 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1427 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1428 /* set proxy_reg_cb_arg to meta filename */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1429 if (sl->sl_meta_filename) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1430 lu->lu_proxy_reg_arg = sl->sl_meta_filename;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1431 lu->lu_proxy_reg_arg_len = strlen(sl->sl_meta_filename) + 1;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1432 } else {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1433 lu->lu_proxy_reg_arg = sl->sl_data_filename;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1434 lu->lu_proxy_reg_arg_len = strlen(sl->sl_data_filename) + 1;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1435 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1436 lu->lu_lp = sbd_lp;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1437 lu->lu_task_alloc = sbd_task_alloc;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1438 lu->lu_new_task = sbd_new_task;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1439 lu->lu_dbuf_xfer_done = sbd_dbuf_xfer_done;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1440 lu->lu_send_status_done = sbd_send_status_done;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1441 lu->lu_task_free = sbd_task_free;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1442 lu->lu_abort = sbd_abort;
12314
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1443 lu->lu_dbuf_free = sbd_dbuf_free;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1444 lu->lu_ctl = sbd_ctl;
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1445 lu->lu_info = sbd_info;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1446 sl->sl_state = STMF_STATE_OFFLINE;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1447
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1448 if ((ret = stmf_register_lu(lu)) != STMF_SUCCESS) {
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1449 stmf_trace(0, "Failed to register with framework, ret=%llx",
8818
72eb4c71537c 6749645 _init returning DDI_FAILURE
tim szeto <Tim.Szeto@Sun.COM>
parents: 7836
diff changeset
1450 ret);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1451 if (ret == STMF_ALREADY) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1452 *err_ret = SBD_RET_GUID_ALREADY_REGISTERED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1453 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1454 return (EIO);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1455 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1456
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1457 *err_ret = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1458 return (0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1459 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1460
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1461 int
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1462 sbd_open_data_file(sbd_lu_t *sl, uint32_t *err_ret, int lu_size_valid,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1463 int vp_valid, int keep_open)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1464 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1465 int ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1466 int flag;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1467 ulong_t nbits;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1468 uint64_t supported_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1469 vattr_t vattr;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1470 enum vtype vt;
12314
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1471 struct dk_cinfo dki;
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1472 int unused;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1473
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1474 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1475 if (vp_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1476 goto odf_over_open;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1477 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1478 if (sl->sl_data_filename[0] != '/') {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1479 *err_ret = SBD_RET_DATA_PATH_NOT_ABSOLUTE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1480 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1481 return (EINVAL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1482 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1483 if ((ret = lookupname(sl->sl_data_filename, UIO_SYSSPACE, FOLLOW,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1484 NULLVPP, &sl->sl_data_vp)) != 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1485 *err_ret = SBD_RET_DATA_FILE_LOOKUP_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1486 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1487 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1488 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1489 sl->sl_data_vtype = vt = sl->sl_data_vp->v_type;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1490 VN_RELE(sl->sl_data_vp);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1491 if ((vt != VREG) && (vt != VCHR) && (vt != VBLK)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1492 *err_ret = SBD_RET_WRONG_DATA_FILE_TYPE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1493 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1494 return (EINVAL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1495 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1496 if (sl->sl_flags & SL_WRITE_PROTECTED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1497 flag = FREAD | FOFFMAX;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1498 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1499 flag = FREAD | FWRITE | FOFFMAX | FEXCL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1500 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1501 if ((ret = vn_open(sl->sl_data_filename, UIO_SYSSPACE, flag, 0,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1502 &sl->sl_data_vp, 0, 0)) != 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1503 *err_ret = SBD_RET_DATA_FILE_OPEN_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1504 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1505 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1506 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1507 odf_over_open:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1508 vattr.va_mask = AT_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1509 if ((ret = VOP_GETATTR(sl->sl_data_vp, &vattr, 0, CRED(), NULL)) != 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1510 *err_ret = SBD_RET_DATA_FILE_GETATTR_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1511 goto odf_close_data_and_exit;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1512 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1513 if ((vt != VREG) && (vattr.va_size == 0)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1514 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1515 * Its a zero byte block or char device. This cannot be
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1516 * a raw disk.
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1517 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1518 *err_ret = SBD_RET_WRONG_DATA_FILE_TYPE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1519 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1520 goto odf_close_data_and_exit;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1521 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1522 /* sl_data_readable size includes any metadata. */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1523 sl->sl_data_readable_size = vattr.va_size;
12314
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1524
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1525 if (VOP_PATHCONF(sl->sl_data_vp, _PC_FILESIZEBITS, &nbits,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1526 CRED(), NULL) != 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1527 nbits = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1528 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1529 /* nbits cannot be greater than 64 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1530 sl->sl_data_fs_nbits = (uint8_t)nbits;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1531 if (lu_size_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1532 sl->sl_total_data_size = sl->sl_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1533 if (sl->sl_flags & SL_SHARED_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1534 sl->sl_total_data_size += SHARED_META_DATA_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1535 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1536 if ((nbits > 0) && (nbits < 64)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1537 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1538 * The expression below is correct only if nbits is
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1539 * positive and less than 64.
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1540 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1541 supported_size = (((uint64_t)1) << nbits) - 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1542 if (sl->sl_total_data_size > supported_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1543 *err_ret = SBD_RET_SIZE_NOT_SUPPORTED_BY_FS;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1544 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1545 goto odf_close_data_and_exit;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1546 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1547 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1548 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1549 sl->sl_total_data_size = vattr.va_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1550 if (sl->sl_flags & SL_SHARED_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1551 if (vattr.va_size > SHARED_META_DATA_SIZE) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1552 sl->sl_lu_size = vattr.va_size -
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1553 SHARED_META_DATA_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1554 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1555 *err_ret = SBD_RET_FILE_SIZE_ERROR;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1556 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1557 goto odf_close_data_and_exit;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1558 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1559 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1560 sl->sl_lu_size = vattr.va_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1561 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1562 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1563 if (sl->sl_lu_size < SBD_MIN_LU_SIZE) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1564 *err_ret = SBD_RET_FILE_SIZE_ERROR;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1565 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1566 goto odf_close_data_and_exit;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1567 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1568 if (sl->sl_lu_size &
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1569 ((((uint64_t)1) << sl->sl_data_blocksize_shift) - 1)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1570 *err_ret = SBD_RET_FILE_ALIGN_ERROR;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1571 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1572 goto odf_close_data_and_exit;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1573 }
12314
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1574 /*
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1575 * Get the minor device for direct zvol access
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1576 */
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1577 if (sl->sl_flags & SL_ZFS_META) {
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1578 if ((ret = VOP_IOCTL(sl->sl_data_vp, DKIOCINFO, (intptr_t)&dki,
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1579 FKIOCTL, kcred, &unused, NULL)) != 0) {
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1580 cmn_err(CE_WARN, "ioctl(DKIOCINFO) failed %d", ret);
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1581 /* zvol reserves 0, so this would fail later */
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1582 sl->sl_zvol_minor = 0;
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1583 } else {
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1584 sl->sl_zvol_minor = dki.dki_unit;
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1585 if (sbd_zvol_get_volume_params(sl) == 0)
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1586 sl->sl_flags |= SL_CALL_ZVOL;
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1587 }
0ed71edeac88 6909809 COMSTAR should avoid extra data copy to zvol-based backing store
James Moore <James.Moore@Sun.COM>
parents: 12202
diff changeset
1588 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1589 sl->sl_flags |= SL_MEDIA_LOADED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1590 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1591 return (0);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1592
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1593 odf_close_data_and_exit:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1594 if (!keep_open) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1595 (void) VOP_CLOSE(sl->sl_data_vp, flag, 1, 0, CRED(), NULL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1596 VN_RELE(sl->sl_data_vp);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1597 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1598 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1599 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1600 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1601
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1602 void
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1603 sbd_close_lu(sbd_lu_t *sl)
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1604 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1605 int flag;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1606
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1607 if (((sl->sl_flags & SL_SHARED_META) == 0) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1608 (sl->sl_flags & SL_META_OPENED)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1609 if (sl->sl_flags & SL_ZFS_META) {
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1610 rw_destroy(&sl->sl_zfs_meta_lock);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1611 if (sl->sl_zfs_meta) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1612 kmem_free(sl->sl_zfs_meta, ZAP_MAXVALUELEN / 2);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1613 sl->sl_zfs_meta = NULL;
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1614 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1615 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1616 flag = FREAD | FWRITE | FOFFMAX | FEXCL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1617 (void) VOP_CLOSE(sl->sl_meta_vp, flag, 1, 0,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1618 CRED(), NULL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1619 VN_RELE(sl->sl_meta_vp);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1620 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1621 sl->sl_flags &= ~SL_META_OPENED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1622 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1623 if (sl->sl_flags & SL_MEDIA_LOADED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1624 if (sl->sl_flags & SL_WRITE_PROTECTED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1625 flag = FREAD | FOFFMAX;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1626 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1627 flag = FREAD | FWRITE | FOFFMAX | FEXCL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1628 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1629 (void) VOP_CLOSE(sl->sl_data_vp, flag, 1, 0, CRED(), NULL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1630 VN_RELE(sl->sl_data_vp);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1631 sl->sl_flags &= ~SL_MEDIA_LOADED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1632 if (sl->sl_flags & SL_SHARED_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1633 sl->sl_flags &= ~SL_META_OPENED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1634 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1635 }
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1636 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1637
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1638 int
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1639 sbd_set_lu_standby(sbd_set_lu_standby_t *stlu, uint32_t *err_ret)
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1640 {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1641 sbd_lu_t *sl;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1642 sbd_status_t sret;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1643 stmf_status_t stret;
12202
f0a60953b83c 6935373 SC3.x/clustered SS7000 FC - Node/cluster panic'ing after takeover from 7000 cluster head
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 11773
diff changeset
1644 uint8_t old_access_state;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1645
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1646 sret = sbd_find_and_lock_lu(stlu->stlu_guid, NULL,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1647 SL_OP_MODIFY_LU, &sl);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1648 if (sret != SBD_SUCCESS) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1649 if (sret == SBD_BUSY) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1650 *err_ret = SBD_RET_LU_BUSY;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1651 return (EBUSY);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1652 } else if (sret == SBD_NOT_FOUND) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1653 *err_ret = SBD_RET_NOT_FOUND;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1654 return (ENOENT);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1655 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1656 *err_ret = SBD_RET_ACCESS_STATE_FAILED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1657 return (EIO);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1658 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1659
12202
f0a60953b83c 6935373 SC3.x/clustered SS7000 FC - Node/cluster panic'ing after takeover from 7000 cluster head
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 11773
diff changeset
1660 old_access_state = sl->sl_access_state;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1661 sl->sl_access_state = SBD_LU_TRANSITION_TO_STANDBY;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1662 stret = stmf_set_lu_access((stmf_lu_t *)sl->sl_lu, STMF_LU_STANDBY);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1663 if (stret != STMF_SUCCESS) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1664 sl->sl_trans_op = SL_OP_NONE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1665 *err_ret = SBD_RET_ACCESS_STATE_FAILED;
12202
f0a60953b83c 6935373 SC3.x/clustered SS7000 FC - Node/cluster panic'ing after takeover from 7000 cluster head
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 11773
diff changeset
1666 sl->sl_access_state = old_access_state;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1667 return (EIO);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1668 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1669
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1670 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1671 * acquire the writer lock here to ensure we're not pulling
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1672 * the rug from the vn_rdwr to the backing store
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1673 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1674 rw_enter(&sl->sl_access_state_lock, RW_WRITER);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1675 sbd_close_lu(sl);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1676 rw_exit(&sl->sl_access_state_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1677
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1678 sl->sl_trans_op = SL_OP_NONE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1679 return (0);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1680 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1681
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1682 int
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1683 sbd_close_delete_lu(sbd_lu_t *sl, int ret)
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1684 {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1685
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1686 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1687 * acquire the writer lock here to ensure we're not pulling
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1688 * the rug from the vn_rdwr to the backing store
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1689 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1690 rw_enter(&sl->sl_access_state_lock, RW_WRITER);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1691 sbd_close_lu(sl);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1692 rw_exit(&sl->sl_access_state_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1693
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1694 if (sl->sl_flags & SL_LINKED)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1695 sbd_unlink_lu(sl);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1696 mutex_destroy(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1697 mutex_destroy(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1698 rw_destroy(&sl->sl_pgr->pgr_lock);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1699 rw_destroy(&sl->sl_access_state_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1700 if (sl->sl_serial_no_alloc_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1701 kmem_free(sl->sl_serial_no, sl->sl_serial_no_alloc_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1702 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1703 if (sl->sl_data_fname_alloc_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1704 kmem_free(sl->sl_data_filename, sl->sl_data_fname_alloc_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1705 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1706 if (sl->sl_alias_alloc_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1707 kmem_free(sl->sl_alias, sl->sl_alias_alloc_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1708 }
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1709 if (sl->sl_mgmt_url_alloc_size) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1710 kmem_free(sl->sl_mgmt_url, sl->sl_mgmt_url_alloc_size);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1711 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1712 stmf_free(sl->sl_lu);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1713 return (ret);
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1714 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1715
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1716 int
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1717 sbd_create_register_lu(sbd_create_and_reg_lu_t *slu, int struct_sz,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1718 uint32_t *err_ret)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1719 {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1720 char *namebuf;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1721 sbd_lu_t *sl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1722 stmf_lu_t *lu;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1723 char *p;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1724 int sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1725 int alloc_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1726 int ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1727 int flag;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1728 int wcd = 0;
10765
7ae75584baf6 6861519 stmfCreateLu() should allow caller to specify host id
John Forte <John.Forte@Sun.COM>
parents: 10725
diff changeset
1729 uint32_t hid = 0;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1730 enum vtype vt;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1731
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1732 sz = struct_sz - sizeof (sbd_create_and_reg_lu_t) + 8 + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1733
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1734 *err_ret = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1735
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1736 /* Lets validate various offsets */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1737 if (((slu->slu_meta_fname_valid) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1738 (slu->slu_meta_fname_off >= sz)) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1739 (slu->slu_data_fname_off >= sz) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1740 ((slu->slu_alias_valid) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1741 (slu->slu_alias_off >= sz)) ||
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1742 ((slu->slu_mgmt_url_valid) &&
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1743 (slu->slu_mgmt_url_off >= sz)) ||
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1744 ((slu->slu_serial_valid) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1745 ((slu->slu_serial_off + slu->slu_serial_size) >= sz))) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1746 return (EINVAL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1747 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1748
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1749 namebuf = kmem_zalloc(sz, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1750 bcopy(slu->slu_buf, namebuf, sz - 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1751 namebuf[sz - 1] = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1752
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1753 alloc_sz = sizeof (sbd_lu_t) + sizeof (sbd_pgr_t);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1754 if (slu->slu_meta_fname_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1755 alloc_sz += strlen(namebuf + slu->slu_meta_fname_off) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1756 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1757 alloc_sz += strlen(namebuf + slu->slu_data_fname_off) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1758 if (slu->slu_alias_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1759 alloc_sz += strlen(namebuf + slu->slu_alias_off) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1760 }
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1761 if (slu->slu_mgmt_url_valid) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1762 alloc_sz += strlen(namebuf + slu->slu_mgmt_url_off) + 1;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1763 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1764 if (slu->slu_serial_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1765 alloc_sz += slu->slu_serial_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1766 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1767
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1768 lu = (stmf_lu_t *)stmf_alloc(STMF_STRUCT_STMF_LU, alloc_sz, 0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1769 if (lu == NULL) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1770 kmem_free(namebuf, sz);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1771 return (ENOMEM);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1772 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1773 sl = (sbd_lu_t *)lu->lu_provider_private;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1774 bzero(sl, alloc_sz);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1775 sl->sl_lu = lu;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1776 sl->sl_alloc_size = alloc_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1777 sl->sl_pgr = (sbd_pgr_t *)(sl + 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1778 rw_init(&sl->sl_pgr->pgr_lock, NULL, RW_DRIVER, NULL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1779 mutex_init(&sl->sl_lock, NULL, MUTEX_DRIVER, NULL);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1780 mutex_init(&sl->sl_metadata_lock, NULL, MUTEX_DRIVER, NULL);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1781 rw_init(&sl->sl_access_state_lock, NULL, RW_DRIVER, NULL);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1782 p = ((char *)sl) + sizeof (sbd_lu_t) + sizeof (sbd_pgr_t);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1783 sl->sl_data_filename = p;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1784 (void) strcpy(sl->sl_data_filename, namebuf + slu->slu_data_fname_off);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1785 p += strlen(sl->sl_data_filename) + 1;
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1786 sl->sl_meta_offset = SBD_META_OFFSET;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
1787 sl->sl_access_state = SBD_LU_ACTIVE;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1788 if (slu->slu_meta_fname_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1789 sl->sl_alias = sl->sl_name = sl->sl_meta_filename = p;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1790 (void) strcpy(sl->sl_meta_filename, namebuf +
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1791 slu->slu_meta_fname_off);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1792 p += strlen(sl->sl_meta_filename) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1793 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1794 sl->sl_alias = sl->sl_name = sl->sl_data_filename;
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1795 if (sbd_is_zvol(sl->sl_data_filename)) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1796 sl->sl_flags |= SL_ZFS_META;
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1797 sl->sl_meta_offset = 0;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1798 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1799 sl->sl_flags |= SL_SHARED_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1800 sl->sl_data_offset = SHARED_META_DATA_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1801 sl->sl_total_meta_size = SHARED_META_DATA_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1802 sl->sl_meta_size_used = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1803 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1804 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1805 if (slu->slu_alias_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1806 sl->sl_alias = p;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1807 (void) strcpy(p, namebuf + slu->slu_alias_off);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1808 p += strlen(sl->sl_alias) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1809 }
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1810 if (slu->slu_mgmt_url_valid) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1811 sl->sl_mgmt_url = p;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1812 (void) strcpy(p, namebuf + slu->slu_mgmt_url_off);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1813 p += strlen(sl->sl_mgmt_url) + 1;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
1814 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1815 if (slu->slu_serial_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1816 sl->sl_serial_no = (uint8_t *)p;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1817 bcopy(namebuf + slu->slu_serial_off, sl->sl_serial_no,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1818 slu->slu_serial_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1819 sl->sl_serial_no_size = slu->slu_serial_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1820 p += slu->slu_serial_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1821 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1822 kmem_free(namebuf, sz);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1823 if (slu->slu_vid_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1824 bcopy(slu->slu_vid, sl->sl_vendor_id, 8);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1825 sl->sl_flags |= SL_VID_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1826 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1827 if (slu->slu_pid_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1828 bcopy(slu->slu_pid, sl->sl_product_id, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1829 sl->sl_flags |= SL_PID_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1830 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1831 if (slu->slu_rev_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1832 bcopy(slu->slu_rev, sl->sl_revision, 4);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1833 sl->sl_flags |= SL_REV_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1834 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1835 if (slu->slu_write_protected) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1836 sl->sl_flags |= SL_WRITE_PROTECTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1837 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1838 if (slu->slu_blksize_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1839 if ((slu->slu_blksize & (slu->slu_blksize - 1)) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1840 (slu->slu_blksize > (32 * 1024)) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1841 (slu->slu_blksize == 0)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1842 *err_ret = SBD_RET_INVALID_BLKSIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1843 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1844 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1845 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1846 while ((1 << sl->sl_data_blocksize_shift) != slu->slu_blksize) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1847 sl->sl_data_blocksize_shift++;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1848 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1849 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1850 sl->sl_data_blocksize_shift = 9; /* 512 by default */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1851 slu->slu_blksize = 512;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1852 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1853
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1854 /* Now lets start creating meta */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1855 sl->sl_trans_op = SL_OP_CREATE_REGISTER_LU;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1856 if (sbd_link_lu(sl) != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1857 *err_ret = SBD_RET_FILE_ALREADY_REGISTERED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1858 ret = EALREADY;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1859 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1860 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
1861
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1862 /* 1st focus on the data store */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1863 if (slu->slu_lu_size_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1864 sl->sl_lu_size = slu->slu_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1865 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1866 ret = sbd_open_data_file(sl, err_ret, slu->slu_lu_size_valid, 0, 0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1867 slu->slu_ret_filesize_nbits = sl->sl_data_fs_nbits;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1868 slu->slu_lu_size = sl->sl_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1869 if (ret) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1870 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1871 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1872
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1873 /*
14042
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1874 * Check if we were explicitly asked to disable/enable write
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1875 * cache on the device, otherwise get current device setting.
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1876 */
14042
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1877 if (slu->slu_writeback_cache_disable_valid) {
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1878 if (slu->slu_writeback_cache_disable) {
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1879 /*
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1880 * Set write cache disable on the device. If it fails,
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1881 * we'll support it using sync/flush.
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1882 */
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1883 (void) sbd_wcd_set(1, sl);
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1884 wcd = 1;
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1885 } else {
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1886 /*
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1887 * Set write cache enable on the device. If it fails,
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1888 * return an error.
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1889 */
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1890 if (sbd_wcd_set(0, sl) != SBD_SUCCESS) {
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1891 *err_ret = SBD_RET_WRITE_CACHE_SET_FAILED;
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1892 ret = EFAULT;
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1893 goto scm_err_out;
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1894 }
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1895 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1896 } else {
14042
e5bd6d1f1685 3505 Creating LU unconditionally enables write cache on backing store device
Yuri Pankov <yuri.pankov@nexenta.com>
parents: 13297
diff changeset
1897 sbd_wcd_get(&wcd, sl);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1898 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1899
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1900 if (wcd) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1901 sl->sl_flags |= SL_WRITEBACK_CACHE_DISABLE |
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1902 SL_SAVED_WRITE_CACHE_DISABLE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1903 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1904
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1905 if (sl->sl_flags & SL_SHARED_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1906 goto over_meta_open;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1907 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1908 if (sl->sl_flags & SL_ZFS_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1909 if (sbd_create_zfs_meta_object(sl) != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1910 *err_ret = SBD_RET_ZFS_META_CREATE_FAILED;
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1911 ret = ENOMEM;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1912 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1913 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1914 sl->sl_meta_blocksize_shift = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1915 goto over_meta_create;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1916 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1917 if ((ret = lookupname(sl->sl_meta_filename, UIO_SYSSPACE, FOLLOW,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1918 NULLVPP, &sl->sl_meta_vp)) != 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1919 *err_ret = SBD_RET_META_FILE_LOOKUP_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1920 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1921 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1922 sl->sl_meta_vtype = vt = sl->sl_meta_vp->v_type;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1923 VN_RELE(sl->sl_meta_vp);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1924 if ((vt != VREG) && (vt != VCHR) && (vt != VBLK)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1925 *err_ret = SBD_RET_WRONG_META_FILE_TYPE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1926 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1927 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1928 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1929 if (vt == VREG) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1930 sl->sl_meta_blocksize_shift = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1931 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1932 sl->sl_meta_blocksize_shift = 9;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1933 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1934 flag = FREAD | FWRITE | FOFFMAX | FEXCL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1935 if ((ret = vn_open(sl->sl_meta_filename, UIO_SYSSPACE, flag, 0,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1936 &sl->sl_meta_vp, 0, 0)) != 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1937 *err_ret = SBD_RET_META_FILE_OPEN_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1938 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1939 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1940 over_meta_create:
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1941 sl->sl_total_meta_size = sl->sl_meta_offset + sizeof (sbd_meta_start_t);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1942 sl->sl_total_meta_size +=
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1943 (((uint64_t)1) << sl->sl_meta_blocksize_shift) - 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1944 sl->sl_total_meta_size &=
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1945 ~((((uint64_t)1) << sl->sl_meta_blocksize_shift) - 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1946 sl->sl_meta_size_used = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1947 over_meta_open:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1948 sl->sl_flags |= SL_META_OPENED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1949
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1950 sl->sl_device_id[3] = 16;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1951 if (slu->slu_guid_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1952 sl->sl_device_id[0] = 0xf1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1953 sl->sl_device_id[1] = 3;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1954 sl->sl_device_id[2] = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1955 bcopy(slu->slu_guid, sl->sl_device_id + 4, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1956 } else {
10765
7ae75584baf6 6861519 stmfCreateLu() should allow caller to specify host id
John Forte <John.Forte@Sun.COM>
parents: 10725
diff changeset
1957 if (slu->slu_host_id_valid)
7ae75584baf6 6861519 stmfCreateLu() should allow caller to specify host id
John Forte <John.Forte@Sun.COM>
parents: 10725
diff changeset
1958 hid = slu->slu_host_id;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1959 if (!slu->slu_company_id_valid)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1960 slu->slu_company_id = COMPANY_ID_SUN;
10765
7ae75584baf6 6861519 stmfCreateLu() should allow caller to specify host id
John Forte <John.Forte@Sun.COM>
parents: 10725
diff changeset
1961 if (stmf_scsilib_uniq_lu_id2(slu->slu_company_id, hid,
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1962 (scsi_devid_desc_t *)&sl->sl_device_id[0]) !=
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1963 STMF_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1964 *err_ret = SBD_RET_META_CREATION_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1965 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1966 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1967 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1968 bcopy(sl->sl_device_id + 4, slu->slu_guid, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1969 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1970
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1971 /* Lets create the meta now */
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1972 mutex_enter(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1973 if (sbd_write_meta_start(sl, sl->sl_total_meta_size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1974 sizeof (sbd_meta_start_t)) != SBD_SUCCESS) {
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1975 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1976 *err_ret = SBD_RET_META_CREATION_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1977 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1978 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1979 }
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
1980 mutex_exit(&sl->sl_metadata_lock);
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
1981 sl->sl_meta_size_used = sl->sl_meta_offset + sizeof (sbd_meta_start_t);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1982
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1983 if (sbd_write_lu_info(sl) != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1984 *err_ret = SBD_RET_META_CREATION_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1985 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1986 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1987 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1988
9933
24d797986369 6852255 sbd_pgr_meta_write()/sbd_pgr_meta_load() infinite recursion
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9932
diff changeset
1989 if (sbd_pgr_meta_init(sl) != SBD_SUCCESS) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1990 *err_ret = SBD_RET_META_CREATION_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1991 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1992 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1993 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
1994
12499
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
1995 /*
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
1996 * Update the zvol separately as this need only be called upon
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
1997 * completion of the metadata initialization.
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
1998 */
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
1999 if (sl->sl_flags & SL_ZFS_META) {
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
2000 if (sbd_update_zfs_prop(sl) != SBD_SUCCESS) {
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
2001 *err_ret = SBD_RET_META_CREATION_FAILED;
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
2002 ret = EIO;
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
2003 goto scm_err_out;
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
2004 }
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
2005 }
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
2006
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2007 ret = sbd_populate_and_register_lu(sl, err_ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2008 if (ret) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2009 goto scm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2010 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2011
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2012 sl->sl_trans_op = SL_OP_NONE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2013 atomic_add_32(&sbd_lu_count, 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2014 return (0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2015
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2016 scm_err_out:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2017 return (sbd_close_delete_lu(sl, ret));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2018 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2019
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2020 stmf_status_t
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2021 sbd_proxy_msg(uint8_t *luid, void *proxy_arg, uint32_t proxy_arg_len,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2022 uint32_t type)
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2023 {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2024 switch (type) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2025 case STMF_MSG_LU_ACTIVE:
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2026 return (sbd_proxy_reg_lu(luid, proxy_arg,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2027 proxy_arg_len));
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2028 case STMF_MSG_LU_REGISTER:
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2029 return (sbd_proxy_reg_lu(luid, proxy_arg,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2030 proxy_arg_len));
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2031 case STMF_MSG_LU_DEREGISTER:
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2032 return (sbd_proxy_dereg_lu(luid, proxy_arg,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2033 proxy_arg_len));
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2034 default:
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2035 return (STMF_INVALID_ARG);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2036 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2037 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2038
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2039
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2040 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2041 * register a standby logical unit
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2042 * proxy_reg_arg contains the meta filename
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2043 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2044 stmf_status_t
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2045 sbd_proxy_reg_lu(uint8_t *luid, void *proxy_reg_arg, uint32_t proxy_reg_arg_len)
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2046 {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2047 sbd_lu_t *sl;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2048 sbd_status_t sret;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2049 sbd_create_standby_lu_t *stlu;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2050 int alloc_sz;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2051 uint32_t err_ret = 0;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2052 stmf_status_t stret = STMF_SUCCESS;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2053
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2054 if (luid == NULL) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2055 return (STMF_INVALID_ARG);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2056 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2057
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2058 do {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2059 sret = sbd_find_and_lock_lu(luid, NULL, SL_OP_MODIFY_LU, &sl);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2060 } while (sret == SBD_BUSY);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2061
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2062 if (sret == SBD_NOT_FOUND) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2063 alloc_sz = sizeof (*stlu) + proxy_reg_arg_len - 8;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2064 stlu = (sbd_create_standby_lu_t *)kmem_zalloc(alloc_sz,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2065 KM_SLEEP);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2066 bcopy(luid, stlu->stlu_guid, 16);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2067 if (proxy_reg_arg_len) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2068 bcopy(proxy_reg_arg, stlu->stlu_meta_fname,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2069 proxy_reg_arg_len);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2070 stlu->stlu_meta_fname_size = proxy_reg_arg_len;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2071 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2072 if (sbd_create_standby_lu(stlu, &err_ret) != 0) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2073 cmn_err(CE_WARN,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2074 "Unable to create standby logical unit for %s",
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2075 stlu->stlu_meta_fname);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2076 stret = STMF_FAILURE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2077 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2078 kmem_free(stlu, alloc_sz);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2079 return (stret);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2080 } else if (sret == SBD_SUCCESS) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2081 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2082 * if the lu is already registered, then the lu should now
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2083 * be in standby mode
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2084 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2085 sbd_it_data_t *it;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2086 if (sl->sl_access_state != SBD_LU_STANDBY) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2087 mutex_enter(&sl->sl_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2088 sl->sl_access_state = SBD_LU_STANDBY;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2089 for (it = sl->sl_it_list; it != NULL;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2090 it = it->sbd_it_next) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2091 it->sbd_it_ua_conditions |=
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2092 SBD_UA_ASYMMETRIC_ACCESS_CHANGED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2093 it->sbd_it_flags &=
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2094 ~SBD_IT_HAS_SCSI2_RESERVATION;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2095 sl->sl_flags &= ~SL_LU_HAS_SCSI2_RESERVATION;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2096 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2097 mutex_exit(&sl->sl_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2098 sbd_pgr_reset(sl);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2099 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2100 sl->sl_trans_op = SL_OP_NONE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2101 } else {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2102 cmn_err(CE_WARN, "could not find and lock logical unit");
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2103 stret = STMF_FAILURE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2104 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2105 out:
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2106 return (stret);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2107 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2108
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2109 /* ARGSUSED */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2110 stmf_status_t
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2111 sbd_proxy_dereg_lu(uint8_t *luid, void *proxy_reg_arg,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2112 uint32_t proxy_reg_arg_len)
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2113 {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2114 sbd_delete_lu_t dlu = {0};
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2115 uint32_t err_ret;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2116
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2117 if (luid == NULL) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2118 cmn_err(CE_WARN, "de-register lu request had null luid");
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2119 return (STMF_INVALID_ARG);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2120 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2121
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2122 bcopy(luid, &dlu.dlu_guid, 16);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2123
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2124 if (sbd_delete_lu(&dlu, (int)sizeof (dlu), &err_ret) != 0) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2125 cmn_err(CE_WARN, "failed to delete de-register lu request");
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2126 return (STMF_FAILURE);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2127 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2128
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2129 return (STMF_SUCCESS);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2130 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2131
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2132 int
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2133 sbd_create_standby_lu(sbd_create_standby_lu_t *slu, uint32_t *err_ret)
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2134 {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2135 sbd_lu_t *sl;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2136 stmf_lu_t *lu;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2137 int ret = EIO;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2138 int alloc_sz;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2139
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2140 alloc_sz = sizeof (sbd_lu_t) + sizeof (sbd_pgr_t) +
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2141 slu->stlu_meta_fname_size;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2142 lu = (stmf_lu_t *)stmf_alloc(STMF_STRUCT_STMF_LU, alloc_sz, 0);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2143 if (lu == NULL) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2144 return (ENOMEM);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2145 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2146 sl = (sbd_lu_t *)lu->lu_provider_private;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2147 bzero(sl, alloc_sz);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2148 sl->sl_lu = lu;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2149 sl->sl_alloc_size = alloc_sz;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2150
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2151 sl->sl_pgr = (sbd_pgr_t *)(sl + 1);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2152 sl->sl_meta_filename = ((char *)sl) + sizeof (sbd_lu_t) +
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2153 sizeof (sbd_pgr_t);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2154
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2155 if (slu->stlu_meta_fname_size > 0) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2156 (void) strcpy(sl->sl_meta_filename, slu->stlu_meta_fname);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2157 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2158 sl->sl_name = sl->sl_meta_filename;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2159
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2160 sl->sl_device_id[3] = 16;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2161 sl->sl_device_id[0] = 0xf1;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2162 sl->sl_device_id[1] = 3;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2163 sl->sl_device_id[2] = 0;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2164 bcopy(slu->stlu_guid, sl->sl_device_id + 4, 16);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2165 lu->lu_id = (scsi_devid_desc_t *)sl->sl_device_id;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2166 sl->sl_access_state = SBD_LU_STANDBY;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2167
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2168 rw_init(&sl->sl_pgr->pgr_lock, NULL, RW_DRIVER, NULL);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2169 mutex_init(&sl->sl_lock, NULL, MUTEX_DRIVER, NULL);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2170 mutex_init(&sl->sl_metadata_lock, NULL, MUTEX_DRIVER, NULL);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2171 rw_init(&sl->sl_access_state_lock, NULL, RW_DRIVER, NULL);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2172
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2173 sl->sl_trans_op = SL_OP_CREATE_REGISTER_LU;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2174
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2175 if (sbd_link_lu(sl) != SBD_SUCCESS) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2176 *err_ret = SBD_RET_FILE_ALREADY_REGISTERED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2177 ret = EALREADY;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2178 goto scs_err_out;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2179 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2180
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2181 ret = sbd_populate_and_register_lu(sl, err_ret);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2182 if (ret) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2183 goto scs_err_out;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2184 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2185
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2186 sl->sl_trans_op = SL_OP_NONE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2187 atomic_add_32(&sbd_lu_count, 1);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2188 return (0);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2189
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2190 scs_err_out:
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2191 return (sbd_close_delete_lu(sl, ret));
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2192 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2193
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2194 int
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2195 sbd_load_sli_1_0(sbd_lu_t *sl, uint32_t *err_ret)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2196 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2197 sbd_lu_info_1_0_t *sli = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2198 sbd_status_t sret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2199
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2200 sret = sbd_read_meta_section(sl, (sm_section_hdr_t **)&sli,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2201 SMS_ID_LU_INFO_1_0);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
2202
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2203 if (sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2204 *err_ret = SBD_RET_NO_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2205 return (EIO);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2206 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2207 if (sli->sli_data_order != SMS_DATA_ORDER) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2208 sbd_swap_lu_info_1_0(sli);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2209 if (sli->sli_data_order != SMS_DATA_ORDER) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2210 kmem_free(sli, sli->sli_sms_header.sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2211 *err_ret = SBD_RET_NO_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2212 return (EIO);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2213 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2214 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2215
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2216 sl->sl_flags |= SL_SHARED_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2217 sl->sl_data_blocksize_shift = 9;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2218 sl->sl_data_offset = SHARED_META_DATA_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2219 sl->sl_lu_size = sli->sli_total_store_size - SHARED_META_DATA_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2220 sl->sl_total_data_size = SHARED_META_DATA_SIZE + sl->sl_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2221 bcopy(sli->sli_lu_devid, sl->sl_device_id, 20);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2222
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2223 kmem_free(sli, sli->sli_sms_header.sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2224 return (0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2225 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2226
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2227 int
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2228 sbd_import_lu(sbd_import_lu_t *ilu, int struct_sz, uint32_t *err_ret,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2229 int no_register, sbd_lu_t **slr)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2230 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2231 stmf_lu_t *lu;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2232 sbd_lu_t *sl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2233 sbd_lu_info_1_1_t *sli = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2234 int asz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2235 int ret = 0;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2236 stmf_status_t stret;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2237 int flag;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2238 int wcd = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2239 int data_opened;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2240 uint16_t sli_buf_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2241 uint8_t *sli_buf_copy = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2242 enum vtype vt;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2243 int standby = 0;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2244 sbd_status_t sret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2245
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2246 if (no_register && slr == NULL) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2247 return (EINVAL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2248 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2249 ilu->ilu_meta_fname[struct_sz - sizeof (*ilu) + 8 - 1] = 0;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2250 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2251 * check whether logical unit is already registered ALUA
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2252 * For a standby logical unit, the meta filename is set. Use
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2253 * that to search for an existing logical unit.
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2254 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2255 sret = sbd_find_and_lock_lu(NULL, (uint8_t *)&(ilu->ilu_meta_fname),
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2256 SL_OP_IMPORT_LU, &sl);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2257
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2258 if (sret == SBD_SUCCESS) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2259 if (sl->sl_access_state != SBD_LU_ACTIVE) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2260 no_register = 1;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2261 standby = 1;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2262 lu = sl->sl_lu;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2263 if (sl->sl_alias_alloc_size) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2264 kmem_free(sl->sl_alias,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2265 sl->sl_alias_alloc_size);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2266 sl->sl_alias_alloc_size = 0;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2267 sl->sl_alias = NULL;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2268 lu->lu_alias = NULL;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2269 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2270 if (sl->sl_meta_filename == NULL) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2271 sl->sl_meta_filename = sl->sl_data_filename;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2272 } else if (sl->sl_data_fname_alloc_size) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2273 kmem_free(sl->sl_data_filename,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2274 sl->sl_data_fname_alloc_size);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2275 sl->sl_data_fname_alloc_size = 0;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2276 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2277 if (sl->sl_serial_no_alloc_size) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2278 kmem_free(sl->sl_serial_no,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2279 sl->sl_serial_no_alloc_size);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2280 sl->sl_serial_no_alloc_size = 0;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2281 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2282 if (sl->sl_mgmt_url_alloc_size) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2283 kmem_free(sl->sl_mgmt_url,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2284 sl->sl_mgmt_url_alloc_size);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2285 sl->sl_mgmt_url_alloc_size = 0;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2286 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2287 } else {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2288 *err_ret = SBD_RET_FILE_ALREADY_REGISTERED;
12591
cdf3cc28b713 6940963 stmfImportLu() should populate luGuid when error STMF_ERROR_FILE_IN_USE is returned
srivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>
parents: 12571
diff changeset
2289 bcopy(sl->sl_device_id + 4, ilu->ilu_ret_guid, 16);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2290 sl->sl_trans_op = SL_OP_NONE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2291 return (EALREADY);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2292 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2293 } else if (sret == SBD_NOT_FOUND) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2294 asz = strlen(ilu->ilu_meta_fname) + 1;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2295
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2296 lu = (stmf_lu_t *)stmf_alloc(STMF_STRUCT_STMF_LU,
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2297 sizeof (sbd_lu_t) + sizeof (sbd_pgr_t) + asz, 0);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2298 if (lu == NULL) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2299 return (ENOMEM);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2300 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2301 sl = (sbd_lu_t *)lu->lu_provider_private;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2302 bzero(sl, sizeof (*sl));
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2303 sl->sl_lu = lu;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2304 sl->sl_pgr = (sbd_pgr_t *)(sl + 1);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2305 sl->sl_meta_filename = ((char *)sl) + sizeof (*sl) +
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2306 sizeof (sbd_pgr_t);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2307 (void) strcpy(sl->sl_meta_filename, ilu->ilu_meta_fname);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2308 sl->sl_name = sl->sl_meta_filename;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2309 rw_init(&sl->sl_pgr->pgr_lock, NULL, RW_DRIVER, NULL);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2310 rw_init(&sl->sl_access_state_lock, NULL, RW_DRIVER, NULL);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2311 mutex_init(&sl->sl_lock, NULL, MUTEX_DRIVER, NULL);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2312 mutex_init(&sl->sl_metadata_lock, NULL, MUTEX_DRIVER, NULL);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2313 sl->sl_trans_op = SL_OP_IMPORT_LU;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2314 } else {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2315 *err_ret = SBD_RET_META_FILE_LOOKUP_FAILED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2316 return (EIO);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2317 }
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2318
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2319 /* we're only loading the metadata */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2320 if (!no_register) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2321 if (sbd_link_lu(sl) != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2322 *err_ret = SBD_RET_FILE_ALREADY_REGISTERED;
12591
cdf3cc28b713 6940963 stmfImportLu() should populate luGuid when error STMF_ERROR_FILE_IN_USE is returned
srivijitha dugganapalli <Srivijitha.Dugganapalli@Sun.COM>
parents: 12571
diff changeset
2323 bcopy(sl->sl_device_id + 4, ilu->ilu_ret_guid, 16);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2324 ret = EALREADY;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2325 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2326 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2327 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2328 if ((ret = lookupname(sl->sl_meta_filename, UIO_SYSSPACE, FOLLOW,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2329 NULLVPP, &sl->sl_meta_vp)) != 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2330 *err_ret = SBD_RET_META_FILE_LOOKUP_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2331 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2332 }
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
2333 if (sbd_is_zvol(sl->sl_meta_filename)) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2334 sl->sl_flags |= SL_ZFS_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2335 sl->sl_data_filename = sl->sl_meta_filename;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2336 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2337 sl->sl_meta_vtype = vt = sl->sl_meta_vp->v_type;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2338 VN_RELE(sl->sl_meta_vp);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2339 if ((vt != VREG) && (vt != VCHR) && (vt != VBLK)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2340 *err_ret = SBD_RET_WRONG_META_FILE_TYPE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2341 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2342 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2343 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2344 if (sl->sl_flags & SL_ZFS_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2345 if (sbd_open_zfs_meta(sl) != SBD_SUCCESS) {
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
2346 /* let see if metadata is in the 64k block */
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
2347 sl->sl_flags &= ~SL_ZFS_META;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2348 }
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
2349 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
2350 if (!(sl->sl_flags & SL_ZFS_META)) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2351 /* metadata is always writable */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2352 flag = FREAD | FWRITE | FOFFMAX | FEXCL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2353 if ((ret = vn_open(sl->sl_meta_filename, UIO_SYSSPACE, flag, 0,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2354 &sl->sl_meta_vp, 0, 0)) != 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2355 *err_ret = SBD_RET_META_FILE_OPEN_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2356 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2357 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2358 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2359 if ((sl->sl_flags & SL_ZFS_META) || (vt == VREG)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2360 sl->sl_meta_blocksize_shift = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2361 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2362 sl->sl_meta_blocksize_shift = 9;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2363 }
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
2364 sl->sl_meta_offset = (sl->sl_flags & SL_ZFS_META) ? 0 : SBD_META_OFFSET;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2365 sl->sl_flags |= SL_META_OPENED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2366
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
2367 mutex_enter(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2368 sret = sbd_load_meta_start(sl);
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
2369 mutex_exit(&sl->sl_metadata_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2370 if (sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2371 if (sret == SBD_META_CORRUPTED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2372 *err_ret = SBD_RET_NO_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2373 } else if (sret == SBD_NOT_SUPPORTED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2374 *err_ret = SBD_RET_VERSION_NOT_SUPPORTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2375 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2376 *err_ret = SBD_RET_NO_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2377 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2378 ret = EINVAL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2379 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2380 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
2381
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2382 /* Now lets see if we can read the most recent LU info */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2383 sret = sbd_read_meta_section(sl, (sm_section_hdr_t **)&sli,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2384 SMS_ID_LU_INFO_1_1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2385 if ((sret == SBD_NOT_FOUND) && ((sl->sl_flags & SL_ZFS_META) == 0)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2386 ret = sbd_load_sli_1_0(sl, err_ret);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2387 if (ret) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2388 goto sim_err_out;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2389 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2390 goto sim_sli_loaded;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2391 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2392 if (sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2393 *err_ret = SBD_RET_NO_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2394 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2395 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2396 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2397 /* load sli 1.1 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2398 if (sli->sli_data_order != SMS_DATA_ORDER) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2399 sbd_swap_lu_info_1_1(sli);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2400 if (sli->sli_data_order != SMS_DATA_ORDER) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2401 *err_ret = SBD_RET_NO_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2402 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2403 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2404 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2405 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2406
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2407 sli_buf_sz = sli->sli_sms_header.sms_size -
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2408 sizeof (sbd_lu_info_1_1_t) + 8;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2409 sli_buf_copy = kmem_alloc(sli_buf_sz + 1, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2410 bcopy(sli->sli_buf, sli_buf_copy, sli_buf_sz);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2411 sli_buf_copy[sli_buf_sz] = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2412
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2413 /* Make sure all the offsets are within limits */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2414 if (((sli->sli_flags & SLI_META_FNAME_VALID) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2415 (sli->sli_meta_fname_offset > sli_buf_sz)) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2416 ((sli->sli_flags & SLI_DATA_FNAME_VALID) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2417 (sli->sli_data_fname_offset > sli_buf_sz)) ||
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2418 ((sli->sli_flags & SLI_MGMT_URL_VALID) &&
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2419 (sli->sli_mgmt_url_offset > sli_buf_sz)) ||
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2420 ((sli->sli_flags & SLI_SERIAL_VALID) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2421 ((sli->sli_serial_offset + sli->sli_serial_size) > sli_buf_sz)) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2422 ((sli->sli_flags & SLI_ALIAS_VALID) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2423 (sli->sli_alias_offset > sli_buf_sz))) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2424 *err_ret = SBD_RET_NO_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2425 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2426 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2427 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2428
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2429 sl->sl_lu_size = sli->sli_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2430 sl->sl_data_blocksize_shift = sli->sli_data_blocksize_shift;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2431 bcopy(sli->sli_device_id, sl->sl_device_id, 20);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2432 if (sli->sli_flags & SLI_SERIAL_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2433 sl->sl_serial_no_size = sl->sl_serial_no_alloc_size =
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2434 sli->sli_serial_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2435 sl->sl_serial_no = kmem_zalloc(sli->sli_serial_size, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2436 bcopy(sli_buf_copy + sli->sli_serial_offset, sl->sl_serial_no,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2437 sl->sl_serial_no_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2438 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2439 if (sli->sli_flags & SLI_SEPARATE_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2440 sl->sl_total_data_size = sl->sl_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2441 if (sli->sli_flags & SLI_DATA_FNAME_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2442 sl->sl_data_fname_alloc_size = strlen((char *)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2443 sli_buf_copy + sli->sli_data_fname_offset) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2444 sl->sl_data_filename = kmem_zalloc(
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2445 sl->sl_data_fname_alloc_size, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2446 (void) strcpy(sl->sl_data_filename,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2447 (char *)sli_buf_copy + sli->sli_data_fname_offset);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2448 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2449 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2450 if (sl->sl_flags & SL_ZFS_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2451 sl->sl_total_data_size = sl->sl_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2452 sl->sl_data_offset = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2453 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2454 sl->sl_total_data_size =
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2455 sl->sl_lu_size + SHARED_META_DATA_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2456 sl->sl_data_offset = SHARED_META_DATA_SIZE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2457 sl->sl_flags |= SL_SHARED_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2458 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2459 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2460 if (sli->sli_flags & SLI_ALIAS_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2461 sl->sl_alias_alloc_size = strlen((char *)sli_buf_copy +
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2462 sli->sli_alias_offset) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2463 sl->sl_alias = kmem_alloc(sl->sl_alias_alloc_size, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2464 (void) strcpy(sl->sl_alias, (char *)sli_buf_copy +
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2465 sli->sli_alias_offset);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2466 }
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2467 if (sli->sli_flags & SLI_MGMT_URL_VALID) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2468 sl->sl_mgmt_url_alloc_size = strlen((char *)sli_buf_copy +
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2469 sli->sli_mgmt_url_offset) + 1;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2470 sl->sl_mgmt_url = kmem_alloc(sl->sl_mgmt_url_alloc_size,
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2471 KM_SLEEP);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2472 (void) strcpy(sl->sl_mgmt_url, (char *)sli_buf_copy +
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2473 sli->sli_mgmt_url_offset);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2474 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2475 if (sli->sli_flags & SLI_WRITE_PROTECTED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2476 sl->sl_flags |= SL_WRITE_PROTECTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2477 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2478 if (sli->sli_flags & SLI_VID_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2479 sl->sl_flags |= SL_VID_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2480 bcopy(sli->sli_vid, sl->sl_vendor_id, 8);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2481 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2482 if (sli->sli_flags & SLI_PID_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2483 sl->sl_flags |= SL_PID_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2484 bcopy(sli->sli_pid, sl->sl_product_id, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2485 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2486 if (sli->sli_flags & SLI_REV_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2487 sl->sl_flags |= SL_REV_VALID;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2488 bcopy(sli->sli_rev, sl->sl_revision, 4);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2489 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2490 if (sli->sli_flags & SLI_WRITEBACK_CACHE_DISABLE) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2491 sl->sl_flags |= SL_WRITEBACK_CACHE_DISABLE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2492 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2493 sim_sli_loaded:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2494 if ((sl->sl_flags & SL_SHARED_META) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2495 data_opened = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2496 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2497 data_opened = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2498 sl->sl_data_filename = sl->sl_meta_filename;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2499 sl->sl_data_vp = sl->sl_meta_vp;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2500 sl->sl_data_vtype = sl->sl_meta_vtype;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2501 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2502
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2503 sret = sbd_pgr_meta_load(sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2504 if (sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2505 *err_ret = SBD_RET_NO_META;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2506 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2507 goto sim_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2508 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2509
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2510 ret = sbd_open_data_file(sl, err_ret, 1, data_opened, 0);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2511 if (ret) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2512 goto sim_err_out;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2513 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2514
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2515 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2516 * set write cache disable on the device
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2517 * Note: this shouldn't fail on import unless the cache capabilities
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2518 * of the device changed. If that happened, modify will need to
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2519 * be used to set the cache flag appropriately after import is done.
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2520 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2521 if (sl->sl_flags & SL_WRITEBACK_CACHE_DISABLE) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2522 (void) sbd_wcd_set(1, sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2523 wcd = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2524 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2525 * if not explicitly set, attempt to set it to enable, if that fails
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2526 * get the current setting and use that
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2527 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2528 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2529 sret = sbd_wcd_set(0, sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2530 if (sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2531 sbd_wcd_get(&wcd, sl);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
2532 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
2533 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2534
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2535 if (wcd) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2536 sl->sl_flags |= SL_WRITEBACK_CACHE_DISABLE |
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2537 SL_SAVED_WRITE_CACHE_DISABLE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2538 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2539
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2540 /* we're only loading the metadata */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2541 if (!no_register) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2542 ret = sbd_populate_and_register_lu(sl, err_ret);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2543 if (ret) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2544 goto sim_err_out;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2545 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2546 atomic_add_32(&sbd_lu_count, 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2547 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2548
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2549 bcopy(sl->sl_device_id + 4, ilu->ilu_ret_guid, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2550 sl->sl_trans_op = SL_OP_NONE;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2551
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2552 if (sli) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2553 kmem_free(sli, sli->sli_sms_header.sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2554 sli = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2555 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2556 if (sli_buf_copy) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2557 kmem_free(sli_buf_copy, sli_buf_sz + 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2558 sli_buf_copy = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2559 }
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2560 if (no_register && !standby) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2561 *slr = sl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2562 }
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2563
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2564 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2565 * if this was imported from standby, set the access state
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2566 * to active.
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2567 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2568 if (standby) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2569 sbd_it_data_t *it;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2570 mutex_enter(&sl->sl_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2571 sl->sl_access_state = SBD_LU_ACTIVE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2572 for (it = sl->sl_it_list; it != NULL;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2573 it = it->sbd_it_next) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2574 it->sbd_it_ua_conditions |=
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2575 SBD_UA_ASYMMETRIC_ACCESS_CHANGED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2576 it->sbd_it_ua_conditions |= SBD_UA_POR;
12202
f0a60953b83c 6935373 SC3.x/clustered SS7000 FC - Node/cluster panic'ing after takeover from 7000 cluster head
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 11773
diff changeset
2577 it->sbd_it_flags |= SBD_IT_PGR_CHECK_FLAG;
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2578 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2579 mutex_exit(&sl->sl_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2580 /* call set access state */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2581 stret = stmf_set_lu_access(lu, STMF_LU_ACTIVE);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2582 if (stret != STMF_SUCCESS) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2583 *err_ret = SBD_RET_ACCESS_STATE_FAILED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2584 sl->sl_access_state = SBD_LU_STANDBY;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2585 goto sim_err_out;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2586 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2587 if (sl->sl_alias) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2588 lu->lu_alias = sl->sl_alias;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2589 } else {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2590 lu->lu_alias = sl->sl_name;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2591 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2592 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2593 sl->sl_access_state = SBD_LU_ACTIVE;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2594 return (0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2595
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2596 sim_err_out:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2597 if (sli) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2598 kmem_free(sli, sli->sli_sms_header.sms_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2599 sli = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2600 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2601 if (sli_buf_copy) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2602 kmem_free(sli_buf_copy, sli_buf_sz + 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2603 sli_buf_copy = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2604 }
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2605
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2606 if (standby) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2607 *err_ret = SBD_RET_ACCESS_STATE_FAILED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2608 sl->sl_trans_op = SL_OP_NONE;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2609 return (EIO);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2610 } else {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2611 return (sbd_close_delete_lu(sl, ret));
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2612 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2613 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2614
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2615 int
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2616 sbd_modify_lu(sbd_modify_lu_t *mlu, int struct_sz, uint32_t *err_ret)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2617 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2618 sbd_lu_t *sl = NULL;
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2619 uint16_t alias_sz;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2620 int ret = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2621 sbd_it_data_t *it;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2622 sbd_status_t sret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2623 uint64_t old_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2624 int modify_unregistered = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2625 int ua = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2626 sbd_import_lu_t *ilu;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2627 stmf_lu_t *lu;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2628 uint32_t ilu_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2629 uint32_t sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2630
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2631 sz = struct_sz - sizeof (*mlu) + 8 + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2632
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2633 /* if there is data in the buf, null terminate it */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2634 if (struct_sz > sizeof (*mlu)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2635 mlu->mlu_buf[struct_sz - sizeof (*mlu) + 8 - 1] = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2636 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2637
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2638 *err_ret = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2639
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2640 /* Lets validate offsets */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2641 if (((mlu->mlu_alias_valid) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2642 (mlu->mlu_alias_off >= sz)) ||
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2643 ((mlu->mlu_mgmt_url_valid) &&
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2644 (mlu->mlu_mgmt_url_off >= sz)) ||
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2645 (mlu->mlu_by_fname) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2646 (mlu->mlu_fname_off >= sz)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2647 return (EINVAL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2648 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2649
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2650 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2651 * We'll look for the device but if we don't find it registered,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2652 * we'll still try to modify the unregistered device.
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2653 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2654 if (mlu->mlu_by_guid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2655 sret = sbd_find_and_lock_lu(mlu->mlu_input_guid, NULL,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2656 SL_OP_MODIFY_LU, &sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2657 } else if (mlu->mlu_by_fname) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2658 sret = sbd_find_and_lock_lu(NULL,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2659 (uint8_t *)&(mlu->mlu_buf[mlu->mlu_fname_off]),
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2660 SL_OP_MODIFY_LU, &sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2661 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2662 return (EINVAL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2663 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2664
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2665
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2666 if (sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2667 if (sret == SBD_BUSY) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2668 *err_ret = SBD_RET_LU_BUSY;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2669 return (EBUSY);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2670 } else if (sret != SBD_NOT_FOUND) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2671 return (EIO);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2672 } else if (!mlu->mlu_by_fname) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2673 return (EINVAL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2674 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2675 /* Okay, try to import the device */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2676 struct_sz = max(8, strlen(&(mlu->mlu_buf[mlu->mlu_fname_off]))
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2677 + 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2678 struct_sz += sizeof (sbd_import_lu_t) - 8;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2679 ilu_sz = struct_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2680 ilu = (sbd_import_lu_t *)kmem_zalloc(ilu_sz, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2681 ilu->ilu_struct_size = struct_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2682 (void) strcpy(ilu->ilu_meta_fname,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2683 &(mlu->mlu_buf[mlu->mlu_fname_off]));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2684 ret = sbd_import_lu(ilu, struct_sz, err_ret, 1, &sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2685 kmem_free(ilu, ilu_sz);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2686 if (ret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2687 return (ENOENT);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2688 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2689 modify_unregistered = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2690 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2691
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2692 if (sl->sl_access_state != SBD_LU_ACTIVE) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2693 *err_ret = SBD_RET_ACCESS_STATE_FAILED;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2694 ret = EINVAL;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2695 goto smm_err_out;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2696 }
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
2697
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2698 /* check for write cache change */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2699 if (mlu->mlu_writeback_cache_disable_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2700 /* set wce on device */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2701 sret = sbd_wcd_set(mlu->mlu_writeback_cache_disable, sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2702 if (!mlu->mlu_writeback_cache_disable && sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2703 *err_ret = SBD_RET_WRITE_CACHE_SET_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2704 ret = EFAULT;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2705 goto smm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2706 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2707 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2708 if (!mlu->mlu_writeback_cache_disable) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2709 if (sl->sl_flags & SL_WRITEBACK_CACHE_DISABLE) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2710 ua = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2711 sl->sl_flags &= ~SL_WRITEBACK_CACHE_DISABLE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2712 sl->sl_flags &= ~SL_SAVED_WRITE_CACHE_DISABLE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2713 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2714 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2715 if ((sl->sl_flags & SL_WRITEBACK_CACHE_DISABLE) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2716 ua = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2717 sl->sl_flags |= SL_WRITEBACK_CACHE_DISABLE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2718 sl->sl_flags |= SL_SAVED_WRITE_CACHE_DISABLE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2719 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2720 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2721 for (it = sl->sl_it_list; ua && it != NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2722 it = it->sbd_it_next) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2723 it->sbd_it_ua_conditions |=
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2724 SBD_UA_MODE_PARAMETERS_CHANGED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2725 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2726 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2727 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2728 ua = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2729
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2730 if (mlu->mlu_alias_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2731 alias_sz = strlen((char *)mlu->mlu_buf +
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2732 mlu->mlu_alias_off) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2733 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2734 * Use the allocated buffer or alloc a new one.
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2735 * Don't copy into sl_alias if sl_alias_alloc_size is 0
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2736 * otherwise or you'll be writing over the data/metadata
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2737 * filename.
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2738 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2739 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2740 if (sl->sl_alias_alloc_size > 0 &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2741 sl->sl_alias_alloc_size < alias_sz) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2742 kmem_free(sl->sl_alias,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2743 sl->sl_alias_alloc_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2744 sl->sl_alias_alloc_size = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2745 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2746 if (sl->sl_alias_alloc_size == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2747 sl->sl_alias = kmem_alloc(alias_sz, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2748 sl->sl_alias_alloc_size = alias_sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2749 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2750 (void) strcpy(sl->sl_alias, (char *)mlu->mlu_buf +
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2751 mlu->mlu_alias_off);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2752 lu = sl->sl_lu;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2753 lu->lu_alias = sl->sl_alias;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2754 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2755 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2756
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2757 if (mlu->mlu_mgmt_url_valid) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2758 uint16_t url_sz;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2759
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2760 url_sz = strlen((char *)mlu->mlu_buf + mlu->mlu_mgmt_url_off);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2761 if (url_sz > 0)
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2762 url_sz++;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2763
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2764 mutex_enter(&sl->sl_lock);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2765 if (sl->sl_mgmt_url_alloc_size > 0 &&
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2766 (url_sz == 0 || sl->sl_mgmt_url_alloc_size < url_sz)) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2767 kmem_free(sl->sl_mgmt_url, sl->sl_mgmt_url_alloc_size);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2768 sl->sl_mgmt_url = NULL;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2769 sl->sl_mgmt_url_alloc_size = 0;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2770 }
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2771 if (url_sz > 0) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2772 if (sl->sl_mgmt_url_alloc_size == 0) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2773 sl->sl_mgmt_url = kmem_alloc(url_sz, KM_SLEEP);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2774 sl->sl_mgmt_url_alloc_size = url_sz;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2775 }
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2776 (void) strcpy(sl->sl_mgmt_url, (char *)mlu->mlu_buf +
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2777 mlu->mlu_mgmt_url_off);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2778 }
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2779 for (it = sl->sl_it_list; it != NULL;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2780 it = it->sbd_it_next) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2781 it->sbd_it_ua_conditions |=
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2782 SBD_UA_MODE_PARAMETERS_CHANGED;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2783 }
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2784 mutex_exit(&sl->sl_lock);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
2785 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2786
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2787 if (mlu->mlu_write_protected_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2788 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2789 if (mlu->mlu_write_protected) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2790 if ((sl->sl_flags & SL_WRITE_PROTECTED) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2791 ua = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2792 sl->sl_flags |= SL_WRITE_PROTECTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2793 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2794 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2795 if (sl->sl_flags & SL_WRITE_PROTECTED) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2796 ua = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2797 sl->sl_flags &= ~SL_WRITE_PROTECTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2798 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2799 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2800 for (it = sl->sl_it_list; ua && it != NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2801 it = it->sbd_it_next) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2802 it->sbd_it_ua_conditions |=
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2803 SBD_UA_MODE_PARAMETERS_CHANGED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2804 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2805 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2806 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2807
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2808 if (mlu->mlu_lu_size_valid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2809 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2810 * validate lu size and set
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2811 * For open file only (registered lu)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2812 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2813 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2814 old_size = sl->sl_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2815 sl->sl_lu_size = mlu->mlu_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2816 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2817 ret = sbd_open_data_file(sl, err_ret, 1, 1, 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2818 if (ret) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2819 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2820 sl->sl_lu_size = old_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2821 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2822 goto smm_err_out;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2823 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2824 if (old_size != mlu->mlu_lu_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2825 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2826 for (it = sl->sl_it_list; it != NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2827 it = it->sbd_it_next) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2828 it->sbd_it_ua_conditions |=
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2829 SBD_UA_CAPACITY_CHANGED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2830 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2831 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2832 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2833 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2834
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2835 if (sbd_write_lu_info(sl) != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2836 *err_ret = SBD_RET_META_CREATION_FAILED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2837 ret = EIO;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2838 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2839
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2840 smm_err_out:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2841 if (modify_unregistered) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2842 (void) sbd_close_delete_lu(sl, 0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2843 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2844 sl->sl_trans_op = SL_OP_NONE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2845 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2846 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2847 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2848
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2849 int
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2850 sbd_set_global_props(sbd_global_props_t *mlu, int struct_sz,
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2851 uint32_t *err_ret)
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2852 {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2853 sbd_lu_t *sl = NULL;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2854 int ret = 0;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2855 sbd_it_data_t *it;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2856 uint32_t sz;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2857
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2858 sz = struct_sz - sizeof (*mlu) + 8 + 1;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2859
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2860 /* if there is data in the buf, null terminate it */
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2861 if (struct_sz > sizeof (*mlu)) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2862 mlu->mlu_buf[struct_sz - sizeof (*mlu) + 8 - 1] = 0;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2863 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2864
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2865 *err_ret = 0;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2866
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2867 /* Lets validate offsets */
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2868 if (((mlu->mlu_mgmt_url_valid) &&
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2869 (mlu->mlu_mgmt_url_off >= sz))) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2870 return (EINVAL);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2871 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2872
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2873 if (mlu->mlu_mgmt_url_valid) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2874 uint16_t url_sz;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2875
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2876 url_sz = strlen((char *)mlu->mlu_buf + mlu->mlu_mgmt_url_off);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2877 if (url_sz > 0)
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2878 url_sz++;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2879
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2880 rw_enter(&sbd_global_prop_lock, RW_WRITER);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2881 if (sbd_mgmt_url_alloc_size > 0 &&
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2882 (url_sz == 0 || sbd_mgmt_url_alloc_size < url_sz)) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2883 kmem_free(sbd_mgmt_url, sbd_mgmt_url_alloc_size);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2884 sbd_mgmt_url = NULL;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2885 sbd_mgmt_url_alloc_size = 0;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2886 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2887 if (url_sz > 0) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2888 if (sbd_mgmt_url_alloc_size == 0) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2889 sbd_mgmt_url = kmem_alloc(url_sz, KM_SLEEP);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2890 sbd_mgmt_url_alloc_size = url_sz;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2891 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2892 (void) strcpy(sbd_mgmt_url, (char *)mlu->mlu_buf +
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2893 mlu->mlu_mgmt_url_off);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2894 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2895 /*
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2896 * check each lu to determine whether a UA is needed.
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2897 */
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2898 mutex_enter(&sbd_lock);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2899 for (sl = sbd_lu_list; sl; sl = sl->sl_next) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2900 if (sl->sl_mgmt_url) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2901 continue;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2902 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2903 mutex_enter(&sl->sl_lock);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2904 for (it = sl->sl_it_list; it != NULL;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2905 it = it->sbd_it_next) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2906 it->sbd_it_ua_conditions |=
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2907 SBD_UA_MODE_PARAMETERS_CHANGED;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2908 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2909 mutex_exit(&sl->sl_lock);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2910 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2911 mutex_exit(&sbd_lock);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2912 rw_exit(&sbd_global_prop_lock);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2913 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2914 return (ret);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2915 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
2916
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2917 /* ARGSUSED */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2918 int
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2919 sbd_delete_locked_lu(sbd_lu_t *sl, uint32_t *err_ret,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2920 stmf_state_change_info_t *ssi)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2921 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2922 int i;
11107
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2923 stmf_status_t ret;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2924
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2925 if ((sl->sl_state == STMF_STATE_OFFLINE) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2926 !sl->sl_state_not_acked) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2927 goto sdl_do_dereg;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2928 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2929
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2930 if ((sl->sl_state != STMF_STATE_ONLINE) ||
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2931 sl->sl_state_not_acked) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2932 return (EBUSY);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2933 }
11107
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2934
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2935 ret = stmf_ctl(STMF_CMD_LU_OFFLINE, sl->sl_lu, ssi);
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2936 if ((ret != STMF_SUCCESS) && (ret != STMF_ALREADY)) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2937 return (EBUSY);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2938 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2939
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2940 for (i = 0; i < 500; i++) {
11107
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2941 if ((sl->sl_state == STMF_STATE_OFFLINE) &&
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2942 !sl->sl_state_not_acked) {
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2943 goto sdl_do_dereg;
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2944 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2945 delay(drv_usectohz(10000));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2946 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2947 return (EBUSY);
11107
580f46f0734f 6897630 sbd_delete_locked_lu returns EBUSY more than needed
Wayne Ihde <Wayne.Ihde@Sun.COM>
parents: 11103
diff changeset
2948
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2949 sdl_do_dereg:;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2950 if (stmf_deregister_lu(sl->sl_lu) != STMF_SUCCESS)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2951 return (EBUSY);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2952 atomic_add_32(&sbd_lu_count, -1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2953
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2954 return (sbd_close_delete_lu(sl, 0));
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2955 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2956
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2957 int
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2958 sbd_delete_lu(sbd_delete_lu_t *dlu, int struct_sz, uint32_t *err_ret)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2959 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2960 sbd_lu_t *sl;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2961 sbd_status_t sret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2962 stmf_state_change_info_t ssi;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2963 int ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2964
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2965 if (dlu->dlu_by_meta_name) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2966 ((char *)dlu)[struct_sz - 1] = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2967 sret = sbd_find_and_lock_lu(NULL, dlu->dlu_meta_name,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2968 SL_OP_DELETE_LU, &sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2969 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2970 sret = sbd_find_and_lock_lu(dlu->dlu_guid, NULL,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2971 SL_OP_DELETE_LU, &sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2972 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2973 if (sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2974 if (sret == SBD_BUSY) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2975 *err_ret = SBD_RET_LU_BUSY;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2976 return (EBUSY);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2977 } else if (sret == SBD_NOT_FOUND) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2978 *err_ret = SBD_RET_NOT_FOUND;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2979 return (ENOENT);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2980 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2981 return (EIO);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2982 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2983
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2984 ssi.st_rflags = STMF_RFLAG_USER_REQUEST;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2985 ssi.st_additional_info = "sbd_delete_lu call (ioctl)";
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2986 ret = sbd_delete_locked_lu(sl, err_ret, &ssi);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2987
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2988 if (ret) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2989 /* Once its locked, no need to grab mutex again */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2990 sl->sl_trans_op = SL_OP_NONE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2991 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2992 return (ret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2993 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2994
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2995 sbd_status_t
11773
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
2996 sbd_data_read(sbd_lu_t *sl, struct scsi_task *task,
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
2997 uint64_t offset, uint64_t size, uint8_t *buf)
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2998 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
2999 int ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3000 long resid;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3001
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3002 if ((offset + size) > sl->sl_lu_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3003 return (SBD_IO_PAST_EOF);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3004 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3005
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3006 offset += sl->sl_data_offset;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3007
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3008 if ((offset + size) > sl->sl_data_readable_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3009 uint64_t store_end;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3010 if (offset > sl->sl_data_readable_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3011 bzero(buf, size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3012 return (SBD_SUCCESS);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3013 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3014 store_end = sl->sl_data_readable_size - offset;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3015 bzero(buf + store_end, size - store_end);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3016 size = store_end;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3017 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3018
11773
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3019 DTRACE_PROBE5(backing__store__read__start, sbd_lu_t *, sl,
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3020 uint8_t *, buf, uint64_t, size, uint64_t, offset,
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3021 scsi_task_t *, task);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3022
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3023 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3024 * Don't proceed if the device has been closed
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3025 * This can occur on an access state change to standby or
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3026 * a delete. The writer lock is acquired before closing the
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3027 * lu.
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3028 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3029 rw_enter(&sl->sl_access_state_lock, RW_READER);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3030 if ((sl->sl_flags & SL_MEDIA_LOADED) == 0) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3031 rw_exit(&sl->sl_access_state_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3032 return (SBD_FAILURE);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3033 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3034 ret = vn_rdwr(UIO_READ, sl->sl_data_vp, (caddr_t)buf, (ssize_t)size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3035 (offset_t)offset, UIO_SYSSPACE, 0, RLIM64_INFINITY, CRED(),
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3036 &resid);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3037 rw_exit(&sl->sl_access_state_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3038
11773
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3039 DTRACE_PROBE6(backing__store__read__end, sbd_lu_t *, sl,
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3040 uint8_t *, buf, uint64_t, size, uint64_t, offset,
11773
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3041 int, ret, scsi_task_t *, task);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3042
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3043 over_sl_data_read:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3044 if (ret || resid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3045 stmf_trace(0, "UIO_READ failed, ret = %d, resid = %d", ret,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3046 resid);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3047 return (SBD_FAILURE);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3048 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3049
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3050 return (SBD_SUCCESS);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3051 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3052
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3053 sbd_status_t
11773
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3054 sbd_data_write(sbd_lu_t *sl, struct scsi_task *task,
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3055 uint64_t offset, uint64_t size, uint8_t *buf)
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3056 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3057 int ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3058 long resid;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3059 sbd_status_t sret = SBD_SUCCESS;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3060 int ioflag;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3061
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3062 if ((offset + size) > sl->sl_lu_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3063 return (SBD_IO_PAST_EOF);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3064 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3065
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3066 offset += sl->sl_data_offset;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3067
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3068 if ((sl->sl_flags & SL_WRITEBACK_CACHE_DISABLE) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3069 (sl->sl_flags & SL_FLUSH_ON_DISABLED_WRITECACHE)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3070 ioflag = FSYNC;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3071 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3072 ioflag = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3073 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3074
11773
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3075 DTRACE_PROBE5(backing__store__write__start, sbd_lu_t *, sl,
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3076 uint8_t *, buf, uint64_t, size, uint64_t, offset,
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3077 scsi_task_t *, task);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3078
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3079 /*
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3080 * Don't proceed if the device has been closed
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3081 * This can occur on an access state change to standby or
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3082 * a delete. The writer lock is acquired before closing the
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3083 * lu.
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3084 */
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3085 rw_enter(&sl->sl_access_state_lock, RW_READER);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3086 if ((sl->sl_flags & SL_MEDIA_LOADED) == 0) {
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3087 rw_exit(&sl->sl_access_state_lock);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3088 return (SBD_FAILURE);
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3089 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3090 ret = vn_rdwr(UIO_WRITE, sl->sl_data_vp, (caddr_t)buf, (ssize_t)size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3091 (offset_t)offset, UIO_SYSSPACE, ioflag, RLIM64_INFINITY, CRED(),
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3092 &resid);
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3093 rw_exit(&sl->sl_access_state_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3094
11773
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3095 DTRACE_PROBE6(backing__store__write__end, sbd_lu_t *, sl,
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3096 uint8_t *, buf, uint64_t, size, uint64_t, offset,
11773
189ba22b9863 6889694 COMSTAR kstat to track IO statistics at the ITL
tim szeto <Tim.Szeto@Sun.COM>
parents: 11107
diff changeset
3097 int, ret, scsi_task_t *, task);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3098
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3099 if ((ret == 0) && (resid == 0) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3100 (sl->sl_flags & SL_WRITEBACK_CACHE_DISABLE) &&
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3101 (sl->sl_flags & SL_FLUSH_ON_DISABLED_WRITECACHE)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3102 sret = sbd_flush_data_cache(sl, 1);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3103 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3104 over_sl_data_write:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3105
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3106 if ((ret || resid) || (sret != SBD_SUCCESS)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3107 return (SBD_FAILURE);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3108 } else if ((offset + size) > sl->sl_data_readable_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3109 uint64_t old_size, new_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3110
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3111 do {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3112 old_size = sl->sl_data_readable_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3113 if ((offset + size) <= old_size)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3114 break;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3115 new_size = offset + size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3116 } while (atomic_cas_64(&sl->sl_data_readable_size, old_size,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3117 new_size) != old_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3118 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3119
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3120 return (SBD_SUCCESS);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3121 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3122
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3123 int
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3124 sbd_get_global_props(sbd_global_props_t *oslp, uint32_t oslp_sz,
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3125 uint32_t *err_ret)
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3126 {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3127 uint32_t sz = 0;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3128 uint16_t off;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3129
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3130 rw_enter(&sbd_global_prop_lock, RW_READER);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3131 if (sbd_mgmt_url) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3132 sz += strlen(sbd_mgmt_url) + 1;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3133 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3134 bzero(oslp, sizeof (*oslp) - 8);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3135 oslp->mlu_buf_size_needed = sz;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3136
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3137 if (sz > (oslp_sz - sizeof (*oslp) + 8)) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3138 *err_ret = SBD_RET_INSUFFICIENT_BUF_SPACE;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3139 rw_exit(&sbd_global_prop_lock);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3140 return (ENOMEM);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3141 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3142
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3143 off = 0;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3144 if (sbd_mgmt_url) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3145 oslp->mlu_mgmt_url_valid = 1;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3146 oslp->mlu_mgmt_url_off = off;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3147 (void) strcpy((char *)&oslp->mlu_buf[off], sbd_mgmt_url);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3148 off += strlen(sbd_mgmt_url) + 1;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3149 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3150
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3151 rw_exit(&sbd_global_prop_lock);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3152 return (0);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3153 }
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3154
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3155 static int
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3156 sbd_get_unmap_props(sbd_unmap_props_t *sup,
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3157 sbd_unmap_props_t *osup, uint32_t *err_ret)
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3158 {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3159 sbd_status_t sret;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3160 sbd_lu_t *sl = NULL;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3161
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3162 if (sup->sup_guid_valid) {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3163 sret = sbd_find_and_lock_lu(sup->sup_guid,
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3164 NULL, SL_OP_LU_PROPS, &sl);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3165 } else {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3166 sret = sbd_find_and_lock_lu(NULL,
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3167 (uint8_t *)sup->sup_zvol_path, SL_OP_LU_PROPS,
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3168 &sl);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3169 }
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3170 if (sret != SBD_SUCCESS) {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3171 if (sret == SBD_BUSY) {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3172 *err_ret = SBD_RET_LU_BUSY;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3173 return (EBUSY);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3174 } else if (sret == SBD_NOT_FOUND) {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3175 *err_ret = SBD_RET_NOT_FOUND;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3176 return (ENOENT);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3177 }
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3178 return (EIO);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3179 }
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3180
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3181 sup->sup_found_lu = 1;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3182 sup->sup_guid_valid = 1;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3183 bcopy(sl->sl_device_id + 4, sup->sup_guid, 16);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3184 if (sl->sl_flags & SL_UNMAP_ENABLED)
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3185 sup->sup_unmap_enabled = 1;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3186 else
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3187 sup->sup_unmap_enabled = 0;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3188
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3189 *osup = *sup;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3190 sl->sl_trans_op = SL_OP_NONE;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3191
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3192 return (0);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3193 }
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3194
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3195 int
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3196 sbd_get_lu_props(sbd_lu_props_t *islp, uint32_t islp_sz,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3197 sbd_lu_props_t *oslp, uint32_t oslp_sz, uint32_t *err_ret)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3198 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3199 sbd_status_t sret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3200 sbd_lu_t *sl = NULL;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3201 uint32_t sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3202 uint16_t off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3203
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3204 if (islp->slp_input_guid) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3205 sret = sbd_find_and_lock_lu(islp->slp_guid, NULL,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3206 SL_OP_LU_PROPS, &sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3207 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3208 ((char *)islp)[islp_sz - 1] = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3209 sret = sbd_find_and_lock_lu(NULL, islp->slp_buf,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3210 SL_OP_LU_PROPS, &sl);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3211 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3212 if (sret != SBD_SUCCESS) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3213 if (sret == SBD_BUSY) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3214 *err_ret = SBD_RET_LU_BUSY;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3215 return (EBUSY);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3216 } else if (sret == SBD_NOT_FOUND) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3217 *err_ret = SBD_RET_NOT_FOUND;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3218 return (ENOENT);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3219 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3220 return (EIO);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3221 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3222
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3223 sz = strlen(sl->sl_name) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3224 if ((sl->sl_flags & (SL_ZFS_META | SL_SHARED_META)) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3225 if (sl->sl_data_filename) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3226 sz += strlen(sl->sl_data_filename) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3227 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3228 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3229 sz += sl->sl_serial_no_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3230 if (sl->sl_alias) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3231 sz += strlen(sl->sl_alias) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3232 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3233
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3234 rw_enter(&sbd_global_prop_lock, RW_READER);
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3235 if (sl->sl_mgmt_url) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3236 sz += strlen(sl->sl_mgmt_url) + 1;
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3237 } else if (sbd_mgmt_url) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3238 sz += strlen(sbd_mgmt_url) + 1;
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3239 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3240 bzero(oslp, sizeof (*oslp) - 8);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3241 oslp->slp_buf_size_needed = sz;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3242
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3243 if (sz > (oslp_sz - sizeof (*oslp) + 8)) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3244 sl->sl_trans_op = SL_OP_NONE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3245 *err_ret = SBD_RET_INSUFFICIENT_BUF_SPACE;
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3246 rw_exit(&sbd_global_prop_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3247 return (ENOMEM);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3248 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3249
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3250 off = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3251 (void) strcpy((char *)oslp->slp_buf, sl->sl_name);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3252 oslp->slp_meta_fname_off = off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3253 off += strlen(sl->sl_name) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3254 if ((sl->sl_flags & (SL_ZFS_META | SL_SHARED_META)) == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3255 oslp->slp_meta_fname_valid = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3256 oslp->slp_separate_meta = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3257 if (sl->sl_data_filename) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3258 oslp->slp_data_fname_valid = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3259 oslp->slp_data_fname_off = off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3260 (void) strcpy((char *)&oslp->slp_buf[off],
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3261 sl->sl_data_filename);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3262 off += strlen(sl->sl_data_filename) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3263 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3264 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3265 oslp->slp_data_fname_valid = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3266 oslp->slp_data_fname_off = oslp->slp_meta_fname_off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3267 if (sl->sl_flags & SL_ZFS_META) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3268 oslp->slp_zfs_meta = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3269 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3270 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3271 if (sl->sl_alias) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3272 oslp->slp_alias_valid = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3273 oslp->slp_alias_off = off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3274 (void) strcpy((char *)&oslp->slp_buf[off], sl->sl_alias);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3275 off += strlen(sl->sl_alias) + 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3276 }
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3277 if (sl->sl_mgmt_url) {
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3278 oslp->slp_mgmt_url_valid = 1;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3279 oslp->slp_mgmt_url_off = off;
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3280 (void) strcpy((char *)&oslp->slp_buf[off], sl->sl_mgmt_url);
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3281 off += strlen(sl->sl_mgmt_url) + 1;
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3282 } else if (sbd_mgmt_url) {
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3283 oslp->slp_mgmt_url_valid = 1;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3284 oslp->slp_mgmt_url_off = off;
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3285 (void) strcpy((char *)&oslp->slp_buf[off], sbd_mgmt_url);
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3286 off += strlen(sbd_mgmt_url) + 1;
10113
045148591643 6812611 Add Management Network Address VPD (85h) support to sbd
Nattuvetty Bhavyan <Nattuvetty.Bhavyan@Sun.COM>
parents: 9933
diff changeset
3287 }
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3288 if (sl->sl_serial_no_size) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3289 oslp->slp_serial_off = off;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3290 bcopy(sl->sl_serial_no, &oslp->slp_buf[off],
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3291 sl->sl_serial_no_size);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3292 oslp->slp_serial_size = sl->sl_serial_no_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3293 oslp->slp_serial_valid = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3294 off += sl->sl_serial_no_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3295 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3296
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3297 oslp->slp_lu_size = sl->sl_lu_size;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3298 oslp->slp_blksize = ((uint16_t)1) << sl->sl_data_blocksize_shift;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3299
10725
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3300 oslp->slp_access_state = sl->sl_access_state;
cd144ed668c5 PSARC/2009/465 COMSTAR ALUA active/standby support
John Forte <John.Forte@Sun.COM>
parents: 10572
diff changeset
3301
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3302 if (sl->sl_flags & SL_VID_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3303 oslp->slp_lu_vid = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3304 bcopy(sl->sl_vendor_id, oslp->slp_vid, 8);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3305 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3306 bcopy(sbd_vendor_id, oslp->slp_vid, 8);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3307 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3308 if (sl->sl_flags & SL_PID_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3309 oslp->slp_lu_pid = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3310 bcopy(sl->sl_product_id, oslp->slp_pid, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3311 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3312 bcopy(sbd_product_id, oslp->slp_pid, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3313 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3314 if (sl->sl_flags & SL_REV_VALID) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3315 oslp->slp_lu_rev = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3316 bcopy(sl->sl_revision, oslp->slp_rev, 4);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3317 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3318 bcopy(sbd_revision, oslp->slp_rev, 4);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3319 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3320 bcopy(sl->sl_device_id + 4, oslp->slp_guid, 16);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3321
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3322 if (sl->sl_flags & SL_WRITEBACK_CACHE_DISABLE)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3323 oslp->slp_writeback_cache_disable_cur = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3324 if (sl->sl_flags & SL_SAVED_WRITE_CACHE_DISABLE)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3325 oslp->slp_writeback_cache_disable_saved = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3326 if (sl->sl_flags & SL_WRITE_PROTECTED)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3327 oslp->slp_write_protected = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3328
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3329 sl->sl_trans_op = SL_OP_NONE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3330
11103
3b3f33a37cab 6894418 set interface for global logical unit property
John Forte <John.Forte@Sun.COM>
parents: 10962
diff changeset
3331 rw_exit(&sbd_global_prop_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3332 return (0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3333 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3334
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3335 /*
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3336 * Returns an allocated string with the "<pool>/..." form of the zvol name.
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3337 */
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3338 static char *
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3339 sbd_get_zvol_name(sbd_lu_t *sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3340 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3341 char *src;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3342 char *p;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3343
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3344 if (sl->sl_data_filename)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3345 src = sl->sl_data_filename;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3346 else
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3347 src = sl->sl_meta_filename;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3348 /* There has to be a better way */
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3349 if (SBD_IS_ZVOL(src) != 0) {
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3350 ASSERT(0);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3351 }
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3352 src += 14; /* Past /dev/zvol/dsk/ */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3353 if (*src == '/')
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3354 src++; /* or /dev/zvol/rdsk/ */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3355 p = (char *)kmem_alloc(strlen(src) + 1, KM_SLEEP);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3356 (void) strcpy(p, src);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3357 return (p);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3358 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3359
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3360 /*
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3361 * this function creates a local metadata zvol property
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3362 */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3363 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3364 sbd_create_zfs_meta_object(sbd_lu_t *sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3365 {
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3366 /*
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3367 * -allocate 1/2 the property size, the zfs property
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3368 * is 8k in size and stored as ascii hex string, all
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3369 * we needed is 4k buffer to store the binary data.
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3370 * -initialize reader/write lock
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3371 */
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3372 if ((sl->sl_zfs_meta = kmem_zalloc(ZAP_MAXVALUELEN / 2, KM_SLEEP))
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3373 == NULL)
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3374 return (SBD_FAILURE);
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3375 rw_init(&sl->sl_zfs_meta_lock, NULL, RW_DRIVER, NULL);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3376 return (SBD_SUCCESS);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3377 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3378
9857
a4f2eeb19b07 6837150 New COMSTAR SBD PGR code needs to handle the SRP transport ID format
Peter Cudhea - Sun Microsystems - Burlington, MA United States <Peter.Cudhea@Sun.COM>
parents: 9679
diff changeset
3379 char
a4f2eeb19b07 6837150 New COMSTAR SBD PGR code needs to handle the SRP transport ID format
Peter Cudhea - Sun Microsystems - Burlington, MA United States <Peter.Cudhea@Sun.COM>
parents: 9679
diff changeset
3380 sbd_ctoi(char c)
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3381 {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3382 if ((c >= '0') && (c <= '9'))
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3383 c -= '0';
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3384 else if ((c >= 'A') && (c <= 'F'))
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3385 c = c - 'A' + 10;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3386 else if ((c >= 'a') && (c <= 'f'))
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3387 c = c - 'a' + 10;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3388 else
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3389 c = -1;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3390 return (c);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3391 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3392
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3393 /*
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3394 * read zvol property and convert to binary
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3395 */
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3396 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3397 sbd_open_zfs_meta(sbd_lu_t *sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3398 {
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3399 char *meta = NULL, cl, ch;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3400 int i;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3401 char *tmp, *ptr;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3402 uint64_t rc = SBD_SUCCESS;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3403 int len;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3404 char *file;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3405
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3406 if (sl->sl_zfs_meta == NULL) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3407 if (sbd_create_zfs_meta_object(sl) == SBD_FAILURE)
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3408 return (SBD_FAILURE);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3409 } else {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3410 bzero(sl->sl_zfs_meta, (ZAP_MAXVALUELEN / 2));
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3411 }
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3412
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3413 rw_enter(&sl->sl_zfs_meta_lock, RW_WRITER);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3414 file = sbd_get_zvol_name(sl);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3415 if (sbd_zvolget(file, &meta)) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3416 rc = SBD_FAILURE;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3417 goto done;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3418 }
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3419 tmp = meta;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3420 /* convert ascii hex to binary meta */
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3421 len = strlen(meta);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3422 ptr = sl->sl_zfs_meta;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3423 for (i = 0; i < len; i += 2) {
9857
a4f2eeb19b07 6837150 New COMSTAR SBD PGR code needs to handle the SRP transport ID format
Peter Cudhea - Sun Microsystems - Burlington, MA United States <Peter.Cudhea@Sun.COM>
parents: 9679
diff changeset
3424 ch = sbd_ctoi(*tmp++);
a4f2eeb19b07 6837150 New COMSTAR SBD PGR code needs to handle the SRP transport ID format
Peter Cudhea - Sun Microsystems - Burlington, MA United States <Peter.Cudhea@Sun.COM>
parents: 9679
diff changeset
3425 cl = sbd_ctoi(*tmp++);
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3426 if (ch == -1 || cl == -1) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3427 rc = SBD_FAILURE;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3428 break;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3429 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3430 *ptr++ = (ch << 4) + cl;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3431 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3432 done:
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3433 rw_exit(&sl->sl_zfs_meta_lock);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3434 if (meta)
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3435 kmem_free(meta, len + 1);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3436 kmem_free(file, strlen(file) + 1);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3437 return (rc);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3438 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3439
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3440 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3441 sbd_read_zfs_meta(sbd_lu_t *sl, uint8_t *buf, uint64_t sz, uint64_t off)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3442 {
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3443 ASSERT(sl->sl_zfs_meta);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3444 rw_enter(&sl->sl_zfs_meta_lock, RW_READER);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3445 bcopy(&sl->sl_zfs_meta[off], buf, sz);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3446 rw_exit(&sl->sl_zfs_meta_lock);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3447 return (SBD_SUCCESS);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3448 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3449
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3450 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3451 sbd_write_zfs_meta(sbd_lu_t *sl, uint8_t *buf, uint64_t sz, uint64_t off)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3452 {
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3453 ASSERT(sl->sl_zfs_meta);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3454 if ((off + sz) > (ZAP_MAXVALUELEN / 2 - 1)) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3455 return (SBD_META_CORRUPTED);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3456 }
10526
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3457 if ((off + sz) > sl->sl_meta_size_used) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3458 sl->sl_meta_size_used = off + sz;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3459 if (sl->sl_total_meta_size < sl->sl_meta_size_used) {
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3460 uint64_t meta_align =
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3461 (((uint64_t)1) << sl->sl_meta_blocksize_shift) - 1;
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3462 sl->sl_total_meta_size = (sl->sl_meta_size_used +
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3463 meta_align) & (~meta_align);
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3464 }
a1c57e83a4db 6870528 writing comstar property larger than 1k disk pool size incorrectly modifies property data
tim szeto <Tim.Szeto@Sun.COM>
parents: 10421
diff changeset
3465 }
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3466 rw_enter(&sl->sl_zfs_meta_lock, RW_WRITER);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3467 bcopy(buf, &sl->sl_zfs_meta[off], sz);
12499
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3468 rw_exit(&sl->sl_zfs_meta_lock);
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3469 /*
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3470 * During creation of a logical unit, sbd_update_zfs_prop will be
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3471 * called separately to avoid multiple calls as each meta section
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3472 * create/update will result in a call to sbd_write_zfs_meta().
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3473 * We only need to update the zvol once during create.
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3474 */
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3475 mutex_enter(&sl->sl_lock);
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3476 if (sl->sl_trans_op != SL_OP_CREATE_REGISTER_LU) {
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3477 mutex_exit(&sl->sl_lock);
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3478 return (sbd_update_zfs_prop(sl));
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3479 }
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3480 mutex_exit(&sl->sl_lock);
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3481 return (SBD_SUCCESS);
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3482 }
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3483
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3484 sbd_status_t
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3485 sbd_update_zfs_prop(sbd_lu_t *sl)
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3486 {
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3487 char *ptr, *ah_meta;
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3488 char *dp = NULL;
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3489 int i, num;
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3490 char *file;
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3491 sbd_status_t ret = SBD_SUCCESS;
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3492
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3493 ASSERT(sl->sl_zfs_meta);
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3494 ptr = ah_meta = kmem_zalloc(ZAP_MAXVALUELEN, KM_SLEEP);
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3495 rw_enter(&sl->sl_zfs_meta_lock, RW_READER);
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3496 /* convert local copy to ascii hex */
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3497 dp = sl->sl_zfs_meta;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3498 for (i = 0; i < sl->sl_total_meta_size; i++, dp++) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3499 num = ((*dp) >> 4) & 0xF;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3500 *ah_meta++ = (num < 10) ? (num + '0') : (num + ('a' - 10));
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3501 num = (*dp) & 0xF;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3502 *ah_meta++ = (num < 10) ? (num + '0') : (num + ('a' - 10));
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3503 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3504 *ah_meta = NULL;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3505 file = sbd_get_zvol_name(sl);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3506 if (sbd_zvolset(file, (char *)ptr)) {
12499
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3507 ret = SBD_META_CORRUPTED;
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3508 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3509 rw_exit(&sl->sl_zfs_meta_lock);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3510 kmem_free(ptr, ZAP_MAXVALUELEN);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3511 kmem_free(file, strlen(file) + 1);
12499
4cfeb544af1d 6953601 improve logical unit creation time for zvol backed logical units
John Forte <John.Forte@Sun.COM>
parents: 12314
diff changeset
3512 return (ret);
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3513 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3514
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3515 int
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3516 sbd_is_zvol(char *path)
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3517 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3518 int is_zfs = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3519
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3520 if (SBD_IS_ZVOL(path) == 0)
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3521 is_zfs = 1;
9585
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3522
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3523 return (is_zfs);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3524 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3525
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3526 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3527 * set write cache disable
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3528 * wcd - 1 = disable, 0 = enable
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3529 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3530 sbd_status_t
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3531 sbd_wcd_set(int wcd, sbd_lu_t *sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3532 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3533 /* translate to wce bit */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3534 int wce = wcd ? 0 : 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3535 int ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3536 sbd_status_t sret = SBD_SUCCESS;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3537
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3538 mutex_enter(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3539 sl->sl_flags &= ~SL_WRITEBACK_CACHE_SET_UNSUPPORTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3540
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3541 if (sl->sl_data_vp->v_type == VREG) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3542 sl->sl_flags |= SL_FLUSH_ON_DISABLED_WRITECACHE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3543 goto done;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3544 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3545
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3546 ret = VOP_IOCTL(sl->sl_data_vp, DKIOCSETWCE, (intptr_t)&wce, FKIOCTL,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3547 kcred, NULL, NULL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3548 if (ret == 0) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3549 sl->sl_flags &= ~SL_WRITEBACK_CACHE_SET_UNSUPPORTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3550 sl->sl_flags &= ~SL_FLUSH_ON_DISABLED_WRITECACHE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3551 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3552 sl->sl_flags |= SL_WRITEBACK_CACHE_SET_UNSUPPORTED;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3553 sl->sl_flags |= SL_FLUSH_ON_DISABLED_WRITECACHE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3554 sret = SBD_FAILURE;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3555 goto done;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3556 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3557
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3558 done:
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3559 mutex_exit(&sl->sl_lock);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3560 return (sret);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3561 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3562
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3563 /*
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3564 * get write cache disable
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3565 * wcd - 1 = disable, 0 = enable
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3566 */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3567 void
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3568 sbd_wcd_get(int *wcd, sbd_lu_t *sl)
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3569 {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3570 int wce;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3571 int ret;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3572
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3573 if (sl->sl_data_vp->v_type == VREG) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3574 *wcd = 0;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3575 return;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3576 }
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3577
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3578 ret = VOP_IOCTL(sl->sl_data_vp, DKIOCGETWCE, (intptr_t)&wce, FKIOCTL,
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3579 kcred, NULL, NULL);
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3580 /* if write cache get failed, assume disabled */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3581 if (ret) {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3582 *wcd = 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3583 } else {
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3584 /* translate to wcd bit */
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3585 *wcd = wce ? 0 : 1;
bf09620212ab 6795089 COMSTAR sbd lun provider should support PGR
tim szeto <Tim.Szeto@Sun.COM>
parents: 8818
diff changeset
3586 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3587 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3588
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3589 int
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3590 sbd_zvolget(char *zvol_name, char **comstarprop)
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3591 {
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3592 ldi_handle_t zfs_lh;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3593 nvlist_t *nv = NULL, *nv2;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3594 zfs_cmd_t *zc;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3595 char *ptr;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3596 int size = 1024;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3597 int unused;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3598 int rc;
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3599
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3600 if ((rc = ldi_open_by_name("/dev/zfs", FREAD | FWRITE, kcred,
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3601 &zfs_lh, sbd_zfs_ident)) != 0) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3602 cmn_err(CE_WARN, "ldi_open %d", rc);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3603 return (ENXIO);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3604 }
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3605
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3606 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3607 (void) strlcpy(zc->zc_name, zvol_name, sizeof (zc->zc_name));
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3608 again:
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3609 zc->zc_nvlist_dst = (uint64_t)(intptr_t)kmem_alloc(size,
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3610 KM_SLEEP);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3611 zc->zc_nvlist_dst_size = size;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3612 rc = ldi_ioctl(zfs_lh, ZFS_IOC_OBJSET_STATS, (intptr_t)zc,
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3613 FKIOCTL, kcred, &unused);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3614 /*
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3615 * ENOMEM means the list is larger than what we've allocated
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3616 * ldi_ioctl will fail with ENOMEM only once
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3617 */
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3618 if (rc == ENOMEM) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3619 int newsize;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3620 newsize = zc->zc_nvlist_dst_size;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3621 kmem_free((void *)(uintptr_t)zc->zc_nvlist_dst, size);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3622 size = newsize;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3623 goto again;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3624 } else if (rc != 0) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3625 goto out;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3626 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3627 rc = nvlist_unpack((char *)(uintptr_t)zc->zc_nvlist_dst,
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3628 zc->zc_nvlist_dst_size, &nv, 0);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3629 ASSERT(rc == 0); /* nvlist_unpack should not fail */
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3630 if ((rc = nvlist_lookup_nvlist(nv, "stmf_sbd_lu", &nv2)) == 0) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3631 rc = nvlist_lookup_string(nv2, ZPROP_VALUE, &ptr);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3632 if (rc != 0) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3633 cmn_err(CE_WARN, "couldn't get value");
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3634 } else {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3635 *comstarprop = kmem_alloc(strlen(ptr) + 1,
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3636 KM_SLEEP);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3637 (void) strcpy(*comstarprop, ptr);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3638 }
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3639 }
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3640 out:
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3641 if (nv != NULL)
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3642 nvlist_free(nv);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3643 kmem_free((void *)(uintptr_t)zc->zc_nvlist_dst, size);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3644 kmem_free(zc, sizeof (zfs_cmd_t));
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3645 (void) ldi_close(zfs_lh, FREAD|FWRITE, kcred);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3646
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3647 return (rc);
7836
4e95154b5b7a 6745433 Merge NWS consolidation into OS/Net consolidation
John Forte <John.Forte@Sun.COM>
parents:
diff changeset
3648 }
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3649
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3650 int
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3651 sbd_zvolset(char *zvol_name, char *comstarprop)
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3652 {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3653 ldi_handle_t zfs_lh;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3654 nvlist_t *nv;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3655 char *packed = NULL;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3656 size_t len;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3657 zfs_cmd_t *zc;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3658 int unused;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3659 int rc;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3660
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3661 if ((rc = ldi_open_by_name("/dev/zfs", FREAD | FWRITE, kcred,
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3662 &zfs_lh, sbd_zfs_ident)) != 0) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3663 cmn_err(CE_WARN, "ldi_open %d", rc);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3664 return (ENXIO);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3665 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3666 (void) nvlist_alloc(&nv, NV_UNIQUE_NAME, KM_SLEEP);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3667 (void) nvlist_add_string(nv, "stmf_sbd_lu", comstarprop);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3668 if ((rc = nvlist_pack(nv, &packed, &len, NV_ENCODE_NATIVE, KM_SLEEP))) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3669 goto out;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3670 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3671
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3672 zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3673 (void) strlcpy(zc->zc_name, zvol_name, sizeof (zc->zc_name));
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3674 zc->zc_nvlist_src = (uint64_t)(intptr_t)packed;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3675 zc->zc_nvlist_src_size = len;
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3676 rc = ldi_ioctl(zfs_lh, ZFS_IOC_SET_PROP, (intptr_t)zc,
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3677 FKIOCTL, kcred, &unused);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3678 if (rc != 0) {
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3679 cmn_err(CE_NOTE, "ioctl failed %d", rc);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3680 }
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3681 kmem_free(zc, sizeof (zfs_cmd_t));
10572
e1b76e0de5ea 6879698 COMSTAR - Find memory leaks after creating several LUs
tim szeto <Tim.Szeto@Sun.COM>
parents: 10526
diff changeset
3682 if (packed)
e1b76e0de5ea 6879698 COMSTAR - Find memory leaks after creating several LUs
tim szeto <Tim.Szeto@Sun.COM>
parents: 10526
diff changeset
3683 kmem_free(packed, len);
9679
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3684 out:
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3685 nvlist_free(nv);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3686 (void) ldi_close(zfs_lh, FREAD|FWRITE, kcred);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3687 return (rc);
02840839dd81 6701531 When possible SBD should not write its metadata directly on the backing store
tim szeto <Tim.Szeto@Sun.COM>
parents: 9585
diff changeset
3688 }
13297
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3689
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3690 /*
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3691 * Unmap a region in a volume. Currently only supported for zvols.
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3692 */
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3693 int
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3694 sbd_unmap(sbd_lu_t *sl, uint64_t offset, uint64_t length)
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3695 {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3696 vnode_t *vp;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3697 int unused;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3698 dkioc_free_t df;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3699
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3700 /* Right now, we only support UNMAP on zvols. */
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3701 if (!(sl->sl_flags & SL_ZFS_META))
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3702 return (EIO);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3703
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3704 df.df_flags = (sl->sl_flags & SL_WRITEBACK_CACHE_DISABLE) ?
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3705 DF_WAIT_SYNC : 0;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3706 df.df_start = offset;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3707 df.df_length = length;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3708
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3709 /* Use the data vnode we have to send a fop_ioctl(). */
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3710 vp = sl->sl_data_vp;
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3711 if (vp == NULL) {
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3712 cmn_err(CE_WARN, "Cannot unmap - no vnode pointer.");
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3713 return (EIO);
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3714 }
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3715
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3716 return (VOP_IOCTL(vp, DKIOCFREE, (intptr_t)(&df), FKIOCTL, kcred,
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3717 &unused, NULL));
4b9dc4ca8e9f 701 UNMAP support for COMSTAR
Dan McDonald <danmcd@nexenta.com>
parents: 12591
diff changeset
3718 }