From patchwork Sun May 4 18:01:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Varoqui X-Patchwork-Id: 4110741 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 87DE19F271 for ; Sun, 4 May 2014 18:06:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89DB0202AE for ; Sun, 4 May 2014 18:06:00 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mail.kernel.org (Postfix) with ESMTP id 3A8CF201FA for ; Sun, 4 May 2014 18:05:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s44I1ZIB024463; Sun, 4 May 2014 14:01:36 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s44I1YlP031827 for ; Sun, 4 May 2014 14:01:34 -0400 Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.17]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s44I1XkY028147 for ; Sun, 4 May 2014 14:01:33 -0400 Received: from mail-ie0-f169.google.com (mail-ie0-f169.google.com [209.85.223.169]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s44I1ViU012133 for ; Sun, 4 May 2014 14:01:32 -0400 Received: by mail-ie0-f169.google.com with SMTP id rl12so7255240iec.28 for ; Sun, 04 May 2014 11:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=JJgqBoGEFwfqQny8rmngzPDhfb7QveY/qaDGIfbr+aY=; b=JY0Dl7K4EQ0BArXZaZbeNW10KaXhWHbt6Cc4X+lK9xw44ECFSMcJymeUHze3yqhKK2 GeT2/3dwCGX2oUG6om8edCFJrdoc6XbpyhNwxdVWZaZOqBtqhhSHe7V+biMZ5aszanHG UTMNt43FQpQFwBgg4WT/dlHApjfMGN6NNpJ465VwSEQqGM6zfFRANNZtW1sm9dnEac6+ qYIJbbg5Wq+VJyaymAJKqnL4G7XnUFwX5RLJDGk3Dc74RZGrIMxO5u0iXe3GHICAEDUu +jkTlCfZx3jeJVEv7cFqcGkUXEBZ/2jET4IY/R9QcGhL61rCPqwoE5+UzUPz8dPL23zM Fmjw== MIME-Version: 1.0 X-Received: by 10.42.185.72 with SMTP id cn8mr2401035icb.63.1399226491643; Sun, 04 May 2014 11:01:31 -0700 (PDT) Received: by 10.64.230.198 with HTTP; Sun, 4 May 2014 11:01:31 -0700 (PDT) In-Reply-To: <5366778D.90109@redhat.com> References: <536670DF.2040605@suse.de> <5366778D.90109@redhat.com> Date: Sun, 4 May 2014 20:01:31 +0200 X-Google-Sender-Auth: SAqJfssZVltA7BP3HYGR0FdoCBM Message-ID: From: Christophe Varoqui To: device-mapper development , dgilbert@interlog.com X-RedHat-Spam-Score: -2.698 (BAYES_00, DCC_REPUT_13_19, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, SPF_PASS, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.17 X-loop: dm-devel@redhat.com Subject: Re: [dm-devel] sg_persist triggers block kernel event ??? X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. 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. Any advice on how to treat this backward-compatibility issue ? For information, here's a more recent version of the patch I sent to Doug earlier to address not-Linux platform behaviour stability : } Regards, Christophe Varoqui www.opensvc.com On Sun, May 4, 2014 at 7:23 PM, Zdenek Kabelac wrote: > Dne 4.5.2014 18:54, Hannes Reinecke napsal(a): > > On 05/04/2014 01:34 AM, Christophe Varoqui wrote: >> >>> It seems sg_persist is doing an "open rw => close" for --in commands, >>> causing a kernel change-event. >>> >> Yep. >> >> Look for 'watch' in the udev rules, that's precisely what it's doing. >> >> (Bloody annoying if you ask me. Generally I recommend to remove that thing >> from the rules). >> > > 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. > > Of course there are many cases where disabling watch rule makes sense > (i.e. you export lots of disks to virtual guests) - but unless you are > familiar with udev and you know what you are doing - think twice before > disabling. > > Zdenek > > -- > dm-devel mailing list > dm-devel@redhat.com > https://www.redhat.com/mailman/listinfo/dm-devel > --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel --- sg_persist.c.orig 2014-05-04 01:10:01.987981956 +0200 +++ sg_persist.c 2014-05-04 08:41:29.482017943 +0200 @@ -1029,6 +1029,8 @@ struct sg_simple_inquiry_resp inq_resp; const char * cp; struct opts_t opts; + int omode = 0; + const char *omode_desc = "rw"; memset(&opts, 0, sizeof(opts)); opts.prin = 1; @@ -1292,10 +1294,17 @@ sg_cmds_close_device(sg_fd); } - if ((sg_fd = sg_cmds_open_device(device_name, 0 /* rw */, +#ifdef SG_LIB_LINUX + if (opts.prin) { + omode = 1; + omode_desc = "ro"; + } +#endif + + if ((sg_fd = sg_cmds_open_device(device_name, omode, opts.verbose)) < 0) { - pr2serr("sg_persist: error opening file (rw): %s: %s\n", device_name, - safe_strerror(-sg_fd)); + pr2serr("sg_persist: error opening file (%s): %s: %s\n", omode_desc, + device_name, safe_strerror(-sg_fd)); return SG_LIB_FILE_ERROR;