Linux LVM users
 help / color / mirror / Atom feed
From: "Jerome Borsboom" <j.borsboom@erasmusmc.nl>
To: linux-lvm@redhat.com
Subject: [linux-lvm] [PATCH] cannot create PV on empty drive
Date: Thu, 16 Dec 2004 17:27:14 +0100	[thread overview]
Message-ID: <41C1C572.15958.1B62373@localhost> (raw)

While I was checking out LVM, I ran into a problem with the 
2.00.31 version of LVM2. When I tried to create a new PV on 
/dev/sdb, pvcreate failed and went into an infinite loop trying 
to close a file-descriptor. This only happened when no .cache 
file was present in /etc/lvm and only on /dev/sdb, i.e. 
/dev/sdb1 did work.

Some debugging showed that the culprit was the recent change to 
the dev_open_flags code. The problem seems to be the reopening 
of the fd in RW mode without closing the old RO one. The patch 
below solved the problem for me, but I did not give it very much 
testing. Hope this helps.

Greetz,

Jerome Borsboom


diff -ru LVM2.2.00.31/lib/device/dev-io.c LVM2.2.00.31.new/lib/device/dev-io.c
--- LVM2.2.00.31/lib/device/dev-io.c    2004-12-12 22:47:14.000000000 +0100
+++ LVM2.2.00.31.new/lib/device/dev-io.c        2004-12-16 17:03:09.503357553 +0100
@@ -292,6 +292,7 @@
 {
        struct stat buf;
        const char *name;
+       int old_open_count = 0;
 
        if (dev->fd >= 0) {
                if ((dev->flags & DEV_OPENED_RW) ||
@@ -299,12 +300,12 @@
                        dev->open_count++;
                        return 1;
                }
-
-               if (dev->open_count)
-                       log_debug("WARNING: %s already opened read-only",
-                                 dev_name(dev));
-               else
-                       dev_close_immediate(dev);
+               else {
+                       if (dev->open_count)
+                               log_debug("WARNING: %s already opened read-only",
+                                         dev_name(dev));
+                       old_open_count = dev->open_count;
+                       dev_close_immediate(dev); }
        }
 
        if (memlock())
@@ -340,7 +341,7 @@
                return 0;
        }
 
-       dev->open_count = 1;
+       dev->open_count = old_open_count + 1;
        dev->flags &= ~DEV_ACCESSED_W;
        if ((flags & O_ACCMODE) == O_RDWR)
                dev->flags |= DEV_OPENED_RW;

             reply	other threads:[~2004-12-16 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-16 16:27 Jerome Borsboom [this message]
2004-12-18 19:42 ` [linux-lvm] [PATCH] cannot create PV on empty drive Alasdair G Kergon
2004-12-21 20:17   ` Alasdair G Kergon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41C1C572.15958.1B62373@localhost \
    --to=j.borsboom@erasmusmc.nl \
    --cc=linux-lvm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox