Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o, Brian Dolbec <dolsen@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] locks: handle sshfs hardlink inode numbers (bug 678218)
Date: Mon, 18 Feb 2019 20:41:40
Message-Id: 64e5292e-fe02-fc87-883d-d604265f18c7@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] locks: handle sshfs hardlink inode numbers (bug 678218) by Brian Dolbec
1 On 2/18/19 8:57 AM, Brian Dolbec wrote:
2 > On Sun, 17 Feb 2019 15:04:29 -0800
3 > Zac Medico <zmedico@g.o> wrote:
4 >
5 >> Since hardlinks on sshfs do not have matching inode numbers, detect
6 >> this behavior and use a simple stat call to detect if lock_path has
7 >> been removed.
8 >>
9 >> Bug: https://bugs.gentoo.org/678218
10 >> Signed-off-by: Zac Medico <zmedico@g.o>
11 >> ---
12 >> lib/portage/locks.py | 27 +++++++++++++++++++++++++++
13 >> 1 file changed, 27 insertions(+)
14 >>
15 >> diff --git a/lib/portage/locks.py b/lib/portage/locks.py
16 >> index 74c2c086a..510925da0 100644
17 >> --- a/lib/portage/locks.py
18 >> +++ b/lib/portage/locks.py
19 >> @@ -340,6 +340,33 @@ def _lockfile_was_removed(lock_fd, lock_path):
20 >>
21 >> hardlink_stat = os.stat(hardlink_path)
22 >> if hardlink_stat.st_ino != fstat_st.st_ino or
23 >> hardlink_stat.st_dev != fstat_st.st_dev:
24 >> + # Create another hardlink in order to detect
25 >> whether or not
26 >> + # hardlink inode numbers are expected to
27 >> match. For example,
28 >> + # inode numbers are not expected to match
29 >> for sshfs.
30 >> + inode_test = hardlink_path + '-inode-test'
31 >> + try:
32 >> + os.unlink(inode_test)
33 >> + except OSError as e:
34 >> + if e.errno not in (errno.ENOENT,
35 >> errno.ESTALE):
36 >> + _raise_exc(e)
37 >> + try:
38 >> + os.link(hardlink_path, inode_test)
39 >> + except OSError as e:
40 >> + if e.errno not in (errno.ENOENT,
41 >> errno.ESTALE):
42 >> + _raise_exc(e)
43 >> + return True
44 >> + else:
45 >> + if not
46 >> os.path.samefile(hardlink_path, inode_test):
47 >> + # This implies that inode
48 >> numbers are not expected
49 >> + # to match for this file
50 >> system, so use a simple
51 >> + # stat call to detect if
52 >> lock_path has been removed.
53 >> + return not
54 >> os.path.exists(lock_path)
55 >> + finally:
56 >> + try:
57 >> + os.unlink(inode_test)
58 >> + except OSError as e:
59 >> + if e.errno not in
60 >> (errno.ENOENT, errno.ESTALE):
61 >> + _raise_exc(e)
62 >> return True
63 >> finally:
64 >> try:
65 >
66 > Looks fine to me
67
68 Thanks, merged:
69
70 https://gitweb.gentoo.org/proj/portage.git/commit/?id=34532af167cff457c3cccda4ea4249a0bc26481a
71
72 --
73 Thanks,
74 Zac

Attachments

File name MIME type
signature.asc application/pgp-signature