Gentoo Archives: gentoo-commits

From: "Richard Yao (ryao)" <ryao@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-kernel/spl/files: spl-0.6.0_rc14-simplify-hostid-logic.patch
Date: Thu, 28 Mar 2013 22:19:30
Message-Id: 20130328221921.A41A52171E@flycatcher.gentoo.org
1 ryao 13/03/28 22:19:21
2
3 Added: spl-0.6.0_rc14-simplify-hostid-logic.patch
4 Log:
5 Version bump to 0.6.1; Simplify hostid logic
6
7 (Portage version: 2.2.0_alpha169/cvs/Linux x86_64, signed Manifest commit with key 0xBEE84C64)
8
9 Revision Changes Path
10 1.1 sys-kernel/spl/files/spl-0.6.0_rc14-simplify-hostid-logic.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-kernel/spl/files/spl-0.6.0_rc14-simplify-hostid-logic.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-kernel/spl/files/spl-0.6.0_rc14-simplify-hostid-logic.patch?rev=1.1&content-type=text/plain
14
15 Index: spl-0.6.0_rc14-simplify-hostid-logic.patch
16 ===================================================================
17 From f47f028ae6f039c13d3138e2ee1c0056a3a3f789 Mon Sep 17 00:00:00 2001
18 From: Richard Yao <ryao@×××××××××××××.edu>
19 Date: Mon, 11 Mar 2013 21:16:36 -0400
20 Subject: [PATCH] Simplify hostid logic
21
22 There is plenty of compatibility code for a hw_hostid
23 that isn't used by anything. At the same time, there are apparently
24 issues with the current hostid logic. coredumb in #zfsonlinux on
25 freenode reported that Fedora 17 changes its hostid on every boot, which
26 required force importing his pool. A suggestion by wca was to adopt
27 FreeBSD's behavior, where it treats hostid as zero if /etc/hostid does
28 not exist
29
30 Adopting FreeBSD's behavior permits us to eliminate plenty of code,
31 including a userland helper that invokes the system's hostid as a
32 fallback.
33
34 Signed-off-by: Richard Yao <ryao@×××××××××××××.edu>
35 ---
36 include/sys/sysmacros.h | 1 -
37 include/sys/systeminfo.h | 3 +--
38 module/spl/spl-generic.c | 55 ++++++------------------------------------------
39 module/spl/spl-proc.c | 11 ----------
40 4 files changed, 7 insertions(+), 63 deletions(-)
41
42 diff --git a/include/sys/sysmacros.h b/include/sys/sysmacros.h
43 index 7c4da67..4dd2685 100644
44 --- a/include/sys/sysmacros.h
45 +++ b/include/sys/sysmacros.h
46 @@ -138,7 +138,6 @@
47 /* Missing globals */
48 extern char spl_version[32];
49 extern unsigned long spl_hostid;
50 -extern char hw_serial[11];
51
52 /* Missing misc functions */
53 extern int highbit(unsigned long i);
54 diff --git a/include/sys/systeminfo.h b/include/sys/systeminfo.h
55 index e22a085..a4c1984 100644
56 --- a/include/sys/systeminfo.h
57 +++ b/include/sys/systeminfo.h
58 @@ -25,6 +25,5 @@
59 #ifndef _SPL_SYSTEMINFO_H
60 #define _SPL_SYSTEMINFO_H
61
62 -#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */
63 #define HW_HOSTID_LEN 11 /* minimum buffer size needed */
64 /* to hold a decimal or hex */
65 diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c
66 index 3cef489..b8e2ed1 100644
67 --- a/module/spl/spl-generic.c
68 +++ b/module/spl/spl-generic.c
69 @@ -52,14 +52,11 @@
70 char spl_version[32] = "SPL v" SPL_META_VERSION "-" SPL_META_RELEASE;
71 EXPORT_SYMBOL(spl_version);
72
73 -unsigned long spl_hostid = HW_INVALID_HOSTID;
74 +unsigned long spl_hostid = 0;
75 EXPORT_SYMBOL(spl_hostid);
76 module_param(spl_hostid, ulong, 0644);
77 MODULE_PARM_DESC(spl_hostid, "The system hostid.");
78
79 -char hw_serial[HW_HOSTID_LEN] = "<none>";
80 -EXPORT_SYMBOL(hw_serial);
81 -
82 proc_t p0 = { 0 };
83 EXPORT_SYMBOL(p0);
84
85 @@ -467,7 +464,7 @@ struct new_utsname *__utsname(void)
86 int result;
87 uint64_t size;
88 struct _buf *file;
89 - unsigned long hostid = 0;
90 + uint32_t hostid = 0;
91
92 file = kobj_open_file(spl_hostid_path);
93
94 @@ -511,45 +508,10 @@ struct new_utsname *__utsname(void)
95 return 0;
96 }
97
98 -#define GET_HOSTID_CMD \
99 - "exec 0</dev/null " \
100 - " 1>/proc/sys/kernel/spl/hostid " \
101 - " 2>/dev/null; " \
102 - "hostid"
103 -
104 -static int
105 -hostid_exec(void)
106 -{
107 - char *argv[] = { "/bin/sh",
108 - "-c",
109 - GET_HOSTID_CMD,
110 - NULL };
111 - char *envp[] = { "HOME=/",
112 - "TERM=linux",
113 - "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
114 - NULL };
115 - int rc;
116 -
117 - /* Doing address resolution in the kernel is tricky and just
118 - * not a good idea in general. So to set the proper 'hw_serial'
119 - * use the usermodehelper support to ask '/bin/sh' to run
120 - * '/usr/bin/hostid' and redirect the result to /proc/sys/spl/hostid
121 - * for us to use. It's a horrific solution but it will do for now.
122 - */
123 - rc = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
124 - if (rc)
125 - printk("SPL: Failed user helper '%s %s %s', rc = %d\n",
126 - argv[0], argv[1], argv[2], rc);
127 -
128 - return rc;
129 -}
130 -
131 uint32_t
132 zone_get_hostid(void *zone)
133 {
134 static int first = 1;
135 - unsigned long hostid;
136 - int rc;
137
138 /* Only the global zone is supported */
139 ASSERT(zone == NULL);
140 @@ -559,21 +521,16 @@ struct new_utsname *__utsname(void)
141
142 /*
143 * Get the hostid if it was not passed as a module parameter.
144 - * Try reading the /etc/hostid file directly, and then fall
145 - * back to calling the /usr/bin/hostid utility.
146 + * Try reading the /etc/hostid file directly.
147 */
148 - if ((spl_hostid == HW_INVALID_HOSTID) &&
149 - (rc = hostid_read()) && (rc = hostid_exec()))
150 - return HW_INVALID_HOSTID;
151 + if (hostid_read())
152 + spl_hostid = 0;
153
154 printk(KERN_NOTICE "SPL: using hostid 0x%08x\n",
155 (unsigned int) spl_hostid);
156 }
157
158 - if (ddi_strtoul(hw_serial, NULL, HW_HOSTID_LEN-1, &hostid) != 0)
159 - return HW_INVALID_HOSTID;
160 -
161 - return (uint32_t)hostid;
162 + return spl_hostid;
163 }
164 EXPORT_SYMBOL(zone_get_hostid);
165
166 diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c
167 index cd4fa1b..1113cf2 100644
168 --- a/module/spl/spl-proc.c
169 +++ b/module/spl/spl-proc.c
170 @@ -506,9 +506,6 @@ enum {
171 if (str == end)
172 SRETURN(-EINVAL);
173
174 - (void) snprintf(hw_serial, HW_HOSTID_LEN, "%lu", spl_hostid);
175 - hw_serial[HW_HOSTID_LEN - 1] = '\0';
176 - *ppos += *lenp;
177 } else {
178 len = snprintf(str, sizeof(str), "%lx", spl_hostid);
179 if (*ppos >= len)
180 @@ -1051,14 +1048,6 @@ enum {
181 .mode = 0644,
182 .proc_handler = &proc_dohostid,
183 },
184 - {
185 - CTL_NAME (CTL_HW_SERIAL)
186 - .procname = "hw_serial",
187 - .data = hw_serial,
188 - .maxlen = sizeof(hw_serial),
189 - .mode = 0444,
190 - .proc_handler = &proc_dostring,
191 - },
192 #ifndef HAVE_KALLSYMS_LOOKUP_NAME
193 {
194 CTL_NAME (CTL_KALLSYMS)
195 --
196 1.8.1.5