All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaco Kroon <jaco@uls.co.za>
To: linux-lvm@redhat.com
Subject: [linux-lvm] potential locking issues
Date: Wed, 20 Feb 2013 22:26:03 +0200	[thread overview]
Message-ID: <5125315B.1060409@uls.co.za> (raw)

Hi All,

LVM2 uses a locking scheme, relying on flock to maintain lock files for
volume groups, by default /var/lock/lvm/V_${vgname} - these lock files
are opened, then flock()ed, and eventually either unlocked and later
locked again, or potentially just unlink()ed with the lock held.

The unlink() can potentially cause the lock to desync and cause
problems.  Consider the following scenario with three processes
(ordering is as is, the numbers are process numbers):

1.  open()
2.  open()
1.  flock() <-- succeeds
2.  flock() <-- blocks.
1.  unlink()
1.  close() <--@this point process 2's flock succeeds.
3.  open() <-- note that this ends up being a *different* file.
3.  flock() <-- succeeds.

At this point both 2 and 3 thinks they have the lock and that's wrong.

I actually saw an instance today where dmeventd had a file descriptor
open to a deletect V_vggroup lockfile, so this *does* happen in the
field.  This also explains various lockups i've seen in the past, which
I later figured out usually happened when dmeventd was running (So i put
much effort into ensuring dmeventd never ever started up - which helped
a lot).

Permitting I'm right the fix would be to fix _undo_flock in
lib/locking/file_locking.c to not unlink the lockfile - ever.  Or any
other file that is used for locking purposes anywhere in the codebase
for that matter.
-- 
Kind Regards,
Jaco Kroon
 

             reply	other threads:[~2013-02-20 20:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-20 20:26 Jaco Kroon [this message]
2013-03-02 12:58 ` [linux-lvm] potential locking issues Jaco Kroon

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=5125315B.1060409@uls.co.za \
    --to=jaco@uls.co.za \
    --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 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.