Re: [PATCH] resctrl: Do not open directory for writing

2020-07-10 Thread Martin Kletzander
On Fri, Jul 10, 2020 at 04:00:13PM +0200, Michal Privoznik wrote: On 7/10/20 3:39 PM, Andrea Bolognani wrote: On Fri, 2020-07-10 at 15:13 +0200, Martin Kletzander wrote: On Fri, Jul 10, 2020 at 10:47:22AM +0200, Michal Privoznik wrote: On 7/9/20 6:30 PM, Andrea Bolognani wrote: This is all bi

Re: [PATCH] resctrl: Do not open directory for writing

2020-07-10 Thread Michal Privoznik
On 7/10/20 3:39 PM, Andrea Bolognani wrote: On Fri, 2020-07-10 at 15:13 +0200, Martin Kletzander wrote: On Fri, Jul 10, 2020 at 10:47:22AM +0200, Michal Privoznik wrote: On 7/9/20 6:30 PM, Andrea Bolognani wrote: This is all bikeshedding, of course: what actually matters is making that lock ex

Re: [PATCH] resctrl: Do not open directory for writing

2020-07-10 Thread Andrea Bolognani
On Fri, 2020-07-10 at 15:13 +0200, Martin Kletzander wrote: > On Fri, Jul 10, 2020 at 10:47:22AM +0200, Michal Privoznik wrote: > > On 7/9/20 6:30 PM, Andrea Bolognani wrote: > > > This is all bikeshedding, of course: what actually matters is making > > > that lock exclusive once again :) > > > >

Re: [PATCH] resctrl: Do not open directory for writing

2020-07-10 Thread Martin Kletzander
On Fri, Jul 10, 2020 at 10:47:22AM +0200, Michal Privoznik wrote: On 7/9/20 6:30 PM, Andrea Bolognani wrote: On Thu, 2020-07-09 at 13:44 +0200, Martin Kletzander wrote: On Thu, Jul 09, 2020 at 12:50:38PM +0200, Andrea Bolognani wrote: it seems to me that this change entirely flipped the semant

Re: [PATCH] resctrl: Do not open directory for writing

2020-07-10 Thread Michal Privoznik
On 7/9/20 6:30 PM, Andrea Bolognani wrote: On Thu, 2020-07-09 at 13:44 +0200, Martin Kletzander wrote: On Thu, Jul 09, 2020 at 12:50:38PM +0200, Andrea Bolognani wrote: it seems to me that this change entirely flipped the semantics of the lock. Yep, you're right. When you have a lock that ha

Re: [PATCH] resctrl: Do not open directory for writing

2020-07-09 Thread Andrea Bolognani
On Thu, 2020-07-09 at 13:44 +0200, Martin Kletzander wrote: > On Thu, Jul 09, 2020 at 12:50:38PM +0200, Andrea Bolognani wrote: > > it seems to me that this change entirely flipped the semantics of > > the lock. > > Yep, you're right. When you have a lock that has boolean as a parameter I > thin

Re: [PATCH] resctrl: Do not open directory for writing

2020-07-09 Thread Martin Kletzander
On Thu, Jul 09, 2020 at 12:50:38PM +0200, Andrea Bolognani wrote: On Thu, 2020-07-09 at 11:40 +0200, Martin Kletzander wrote: static int virResctrlLockWrite(void) { -int fd = open(SYSFS_RESCTRL_PATH, O_RDWR | O_CLOEXEC); +int fd = open(SYSFS_RESCTRL_PATH, O_RDONLY | O_CLOEXEC); I go

Re: [PATCH] resctrl: Do not open directory for writing

2020-07-09 Thread Andrea Bolognani
On Thu, 2020-07-09 at 11:40 +0200, Martin Kletzander wrote: > static int > virResctrlLockWrite(void) > { > -int fd = open(SYSFS_RESCTRL_PATH, O_RDWR | O_CLOEXEC); > +int fd = open(SYSFS_RESCTRL_PATH, O_RDONLY | O_CLOEXEC); I got curious, so I did some digging. The commit message for 18

Re: [PATCH] resctrl: Do not open directory for writing

2020-07-09 Thread Ján Tomko
On a Thursday in 2020, Martin Kletzander wrote: When preparing for the removal of GNULIB commit 18dca21a32e9 removed the unneeded O_DIRECTORY, but unfortunately started opening the directory for writing which fails every time for a directory. There is also no need for that as flock() works on O_

[PATCH] resctrl: Do not open directory for writing

2020-07-09 Thread Martin Kletzander
When preparing for the removal of GNULIB commit 18dca21a32e9 removed the unneeded O_DIRECTORY, but unfortunately started opening the directory for writing which fails every time for a directory. There is also no need for that as flock() works on O_RDONLY file descriptor as well, even for LOCK_EX.