All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-lvm] [PATCH] cannot create PV on empty drive
@ 2004-12-16 16:27 Jerome Borsboom
  2004-12-18 19:42 ` Alasdair G Kergon
  0 siblings, 1 reply; 3+ messages in thread
From: Jerome Borsboom @ 2004-12-16 16:27 UTC (permalink / raw)
  To: linux-lvm

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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [linux-lvm] [PATCH] cannot create PV on empty drive
  2004-12-16 16:27 [linux-lvm] [PATCH] cannot create PV on empty drive Jerome Borsboom
@ 2004-12-18 19:42 ` Alasdair G Kergon
  2004-12-21 20:17   ` Alasdair G Kergon
  0 siblings, 1 reply; 3+ messages in thread
From: Alasdair G Kergon @ 2004-12-18 19:42 UTC (permalink / raw)
  To: LVM general discussion and development

Do you have verbose output from the failing pvcreate with '-vvvv'?
(or debug-log-to-file output)

On Thu, Dec 16, 2004 at 05:27:14PM +0100, Jerome Borsboom wrote:
> Some debugging showed that the culprit was the recent change to 
> the dev_open_flags code. 

The patch was produced under severe time pressure before I went away 
and I know it doesn't deal with one case properly - maybe the case 
you hit.  It addresses a symptom not the cause: the code is not meant 
to be trying to write to read-only file descriptors in the first place,
and this happens here because of a shortcoming in way it does its locking. 
I'll deal with this maybe later this week or else in the New Year.

Alasdair
-- 
agk@redhat.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [linux-lvm] [PATCH] cannot create PV on empty drive
  2004-12-18 19:42 ` Alasdair G Kergon
@ 2004-12-21 20:17   ` Alasdair G Kergon
  0 siblings, 0 replies; 3+ messages in thread
From: Alasdair G Kergon @ 2004-12-21 20:17 UTC (permalink / raw)
  To: Jerome Borsboom; +Cc: LVM general discussion and development

On Sat, Dec 18, 2004 at 07:42:56PM +0000, Alasdair G Kergon wrote:
> Do you have verbose output from the failing pvcreate with '-vvvv'?
> (or debug-log-to-file output)
 
I still don't know how to reproduce this.

Meanwhile, I'm checking in a patch based on yours.

Alasdair
-- 
agk@redhat.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-12-21 20:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-16 16:27 [linux-lvm] [PATCH] cannot create PV on empty drive Jerome Borsboom
2004-12-18 19:42 ` Alasdair G Kergon
2004-12-21 20:17   ` Alasdair G Kergon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.