lkml.org 
[lkml]   [2019]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 05/32] timerfd/timens: Take into account ns clock offsets
On Wed, Feb 06, 2019 at 11:52:03AM +0300, Cyrill Gorcunov wrote:
> On Wed, Feb 06, 2019 at 12:10:39AM +0000, Dmitry Safonov wrote:
> > From: Andrei Vagin <avagin@gmail.com>
> >
> > Make timerfd respect timens offsets.
> > Provide two helpers timens_clock_to_host() timens_clock_from_host() that
> > are useful to wire up timens to different kernel subsystems.
> > Following patches will use timens_clock_from_host(), added here for
> > completeness.
> >
> > Signed-off-by: Andrei Vagin <avagin@openvz.org>
> > Co-developed-by: Dmitry Safonov <dima@arista.com>
> > Signed-off-by: Dmitry Safonov <dima@arista.com>
> > ---
> > fs/timerfd.c | 16 +++++++++++-----
> > 1 file changed, 11 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/timerfd.c b/fs/timerfd.c
> > index 803ca070d42e..c7ae1e371912 100644
> > --- a/fs/timerfd.c
> > +++ b/fs/timerfd.c
> > @@ -26,6 +26,7 @@
> > #include <linux/syscalls.h>
> > #include <linux/compat.h>
> > #include <linux/rcupdate.h>
> > +#include <linux/time_namespace.h>
> >
> > struct timerfd_ctx {
> > union {
> > @@ -433,22 +434,27 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
> > }
> >
> > static int do_timerfd_settime(int ufd, int flags,
> > - const struct itimerspec64 *new,
> > + struct itimerspec64 *new,
> > struct itimerspec64 *old)
> > {
> > struct fd f;
> > struct timerfd_ctx *ctx;
> > int ret;
> >
> > - if ((flags & ~TFD_SETTIME_FLAGS) ||
> > - !itimerspec64_valid(new))
> > - return -EINVAL;
>
> Please don't defer this early test of a @flags value. Otherwise
> if @flags is invalid you continue fget/put/clock-to-host even
> if result will be dropped out then.

Cyrill, you are right. I moved this check together with
itimerspec64_valid(). The idea was to call itimerspec64_valid() after
applying clock offsets but for that, we need to know clockid.

Let's wait a bit for other comments to this patch set and then we will
fix all things what will be found.

Thanks,
Andrei

\
 
 \ /
  Last update: 2019-02-07 07:38    [W:0.950 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site