<div dir="ltr">Indeed, I'd rather let udev do its work on legitimate device changes. Problem is, this change event caused by sg_persist prin commands in not legitimate : no device change can be caused by interrogating the disk pr status.<div>
<br></div><div>Doug informed me newer kernels accept prin commands inside a open-ro=>close sequence, which I now verified by testing with the patch I sent ... but older kernels do not. My patch is thus not backward compatible as-is.</div>
<div><br></div><div>Any advice on how to treat this backward-compatibility issue ?</div><div><br></div><div>For information, here's a more recent version of the patch I sent to Doug earlier to address not-Linux platform behaviour stability :</div>
<div><br></div><div><div style="font-family:arial,sans-serif;font-size:19.428571701049805px">--- sg_persist.c.orig<span style="white-space:pre-wrap">   </span>2014-05-04 01:10:01.987981956 +0200</div><div style="font-family:arial,sans-serif;font-size:19.428571701049805px">
+++ sg_persist.c<span style="white-space:pre-wrap">     </span>2014-05-04 08:41:29.482017943 +0200</div><div class="im" style="font-family:arial,sans-serif;font-size:19.428571701049805px"><div>@@ -1029,6 +1029,8 @@</div><div>
     struct sg_simple_inquiry_resp inq_resp;</div><div>     const char * cp;</div><div>     struct opts_t opts;</div><div>+    int omode = 0;</div></div><div style="font-family:arial,sans-serif;font-size:19.428571701049805px">
+    const char *omode_desc = "rw";</div><div class="im" style="font-family:arial,sans-serif;font-size:19.428571701049805px"><div> </div><div>     memset(&opts, 0, sizeof(opts));</div><div>     opts.prin = 1;</div>
</div><div style="font-family:arial,sans-serif;font-size:19.428571701049805px">@@ -1292,10 +1294,17 @@</div><div class="im" style="font-family:arial,sans-serif;font-size:19.428571701049805px"><div>         sg_cmds_close_device(sg_fd);</div>
<div>     }</div><div> </div><div>-    if ((sg_fd = sg_cmds_open_device(device_name, 0 /* rw */,</div></div><div style="font-family:arial,sans-serif;font-size:19.428571701049805px">+#ifdef SG_LIB_LINUX</div><div class="im" style="font-family:arial,sans-serif;font-size:19.428571701049805px">
<div>+    if (opts.prin) {</div><div>+        omode = 1;</div><div>+        omode_desc = "ro";</div><div>+    }</div></div><div style="font-family:arial,sans-serif;font-size:19.428571701049805px">+#endif</div><div class="im" style="font-family:arial,sans-serif;font-size:19.428571701049805px">
<div>+</div><div>+    if ((sg_fd = sg_cmds_open_device(device_name, omode,</div><div>                                      opts.verbose)) < 0) {</div><div>-        pr2serr("sg_persist: error opening file (rw): %s: %s\n", device_name,</div>
<div>-                safe_strerror(-sg_fd));</div><div>+        pr2serr("sg_persist: error opening file (%s): %s: %s\n", omode_desc,</div><div>+                device_name, safe_strerror(-sg_fd));</div><div>         return SG_LIB_FILE_ERROR;</div>
<div>     }</div></div></div><div><br></div><div>Regards,</div><div>Christophe Varoqui</div><div><a href="http://www.opensvc.com">www.opensvc.com</a></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sun, May 4, 2014 at 7:23 PM, Zdenek Kabelac <span dir="ltr"><<a href="mailto:zkabelac@redhat.com" target="_blank">zkabelac@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dne 4.5.2014 18:54, Hannes Reinecke napsal(a):<div class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 05/04/2014 01:34 AM, Christophe Varoqui wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It seems sg_persist is doing an "open rw => close" for --in commands,<br>
causing a kernel change-event.<br>
</blockquote>
Yep.<br>
<br>
Look for 'watch' in the udev rules, that's precisely what it's doing.<br>
<br>
(Bloody annoying if you ask me. Generally I recommend to remove that thing<br>
from the rules).<br>
</blockquote>
<br></div>
When watch rule is disabled/removed in  udev rules - your udev db becomes invalid when i.e. you run  command like  'mkfs' - since the udev db will not be updated to list information about newly formatted filesystem.<br>

<br>
Of course there are many cases where disabling  watch rule makes sense<br>
(i.e. you export lots of disks to virtual guests) - but unless you are<br>
familiar with udev and you know what you are doing - think twice before disabling.<br>
<br>
Zdenek<br>
<br>
--<br>
dm-devel mailing list<br>
<a href="mailto:dm-devel@redhat.com" target="_blank">dm-devel@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/dm-devel" target="_blank">https://www.redhat.com/<u></u>mailman/listinfo/dm-devel</a><br>
</blockquote></div><br></div>