Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

GFS2: Send useful information with uevent messages

In order to distinguish between two differing uevent messages
and to avoid using the (racy) method of reading status from
sysfs in future, this adds some status information to our
uevent messages.

Btw, before anybody says "sysfs isn't racy", I'm aware of that,
but the way that GFS2 was using it (send an ambiugous uevent and
then expect the receiver to read sysfs to find out the status
of the reported operation) was.

The additional benefit of using the new interface is that it
should be possible for a node to recover multiple journals
at the same time, since there is no longer any confusion as
to which journal the status belongs to.

At some future stage, when all the userland programs have been
converted, I intend to remove the old interface.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

+10 -2
+10 -2
fs/gfs2/locking/dlm/mount.c
··· 194 194 static void gdlm_recovery_done(void *lockspace, unsigned int jid, 195 195 unsigned int message) 196 196 { 197 + char env_jid[20]; 198 + char env_status[20]; 199 + char *envp[] = { env_jid, env_status, NULL }; 197 200 struct gdlm_ls *ls = lockspace; 198 201 ls->recover_jid_done = jid; 199 202 ls->recover_jid_status = message; 200 - kobject_uevent(&ls->kobj, KOBJ_CHANGE); 203 + sprintf(env_jid, "JID=%d", jid); 204 + sprintf(env_status, "RECOVERY=%s", 205 + message == LM_RD_SUCCESS ? "Done" : "Failed"); 206 + kobject_uevent_env(&ls->kobj, KOBJ_CHANGE, envp); 201 207 } 202 208 203 209 static void gdlm_others_may_mount(void *lockspace) 204 210 { 211 + char *message = "FIRSTMOUNT=Done"; 212 + char *envp[] = { message, NULL }; 205 213 struct gdlm_ls *ls = lockspace; 206 214 ls->first_done = 1; 207 - kobject_uevent(&ls->kobj, KOBJ_CHANGE); 215 + kobject_uevent_env(&ls->kobj, KOBJ_CHANGE, envp); 208 216 } 209 217 210 218 /* Userspace gets the offline uevent, blocks new gfs locks on