Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2004636yba; Mon, 15 Apr 2019 03:00:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXKINuHs1Nml+TmycQDS/Xh0X8/DvRBrTl60hLgaYQ6Mt+ZQ9ns7vYyyHE0rhzNtwwxN0A X-Received: by 2002:a63:c40c:: with SMTP id h12mr57501022pgd.39.1555322401763; Mon, 15 Apr 2019 03:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555322401; cv=none; d=google.com; s=arc-20160816; b=O+hxfxgnjS2n//MiHn1RA0lYDeKJQa5tCyVkyYwccJpQRd5Fjx5nwWXePNvRnmPe7+ oP8O6NydWcTNRc9uzISPyDg1f0Hr56UaDJLR2TrF7B7pqimOXY7Q6MtaaX9aRIXxNWsE fHUHnMsxlH3+mXOGBnSHNLkn8j6MOVKLwTz7x/S4IvG4h7UiawuXjVkeIzDzTBTqnZtf bzcKea+nCw27Xr921s4mn9iPf4IB1Q4f5mymNtGR8GKsPpQjMtC8x8SeBq74kFfC4kM3 v+h4RHJNdBYtrXozM8E+YVtbkqU9xNbcpPj9L7oKxYFXFDoWDeZMf36PCppRsRmCqngK eTAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=o5DeUQHeUyBmHtHgDTiURkH8sbnsN6GnY7jSGzipVO4=; b=r4Bwo49csHY69J7JF7obNxR5T7Jh4R/QvCKTOTaQctEpB+OFL9PltWLyP+BiWqOZcW O+peRr2B76UlIGZO9GwpQRV0o/yT9Gjz/TDEHCRwEqFt3/KVFywpl4XoKC/CsSFkzgEo +syw9D32T/PF+wTpdkL/k5SjPzrOoN1BLbtje8Wfhe67dRgQpFHet1K0bDa+GKm9jipd DIAtJDRaJkmuFKqDAnSTA7B+jsoJAN1q+48KTIsKqz3mgWBd84x05/qWRZm0VvydSOk7 Q6rFIK7C8+q43aJCxcl75YXWoCsJW0EQINL/AanSSXErj2rlQil1nrhgENRMmth7rS0F ZC+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si8904929pld.61.2019.04.15.02.59.45; Mon, 15 Apr 2019 03:00:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726785AbfDOJ7J (ORCPT + 99 others); Mon, 15 Apr 2019 05:59:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:59956 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725885AbfDOJ7J (ORCPT ); Mon, 15 Apr 2019 05:59:09 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 12B0CAE69; Mon, 15 Apr 2019 09:59:08 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 71B151E42AA; Mon, 15 Apr 2019 11:59:07 +0200 (CEST) Date: Mon, 15 Apr 2019 11:59:07 +0200 From: Jan Kara To: linux-fsdevel@vger.kernel.org Cc: Orion Poplawski , Vivek Trivedi , Amir Goldstein , linux-api@vger.kernel.org, LKML , "Eric W. Biederman" , Jan Kara Subject: Re: [PATCH] fanotify: Make wait for permission events interruptible Message-ID: <20190415095907.GA14466@quack2.suse.cz> References: <20190321151142.17104-1-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190321151142.17104-1-jack@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 21-03-19 16:11:42, Jan Kara wrote: > Switch waiting for response to fanotify permission events interruptible. > This allows e.g. the system to be suspended while there are some > fanotify permission events pending (which is reportedly pretty common > when for example AV solution is in use). However just making the wait > interruptible can result in e.g. open(2) returning -EINTR where > previously such error code never happened in practice. To avoid > confusion of userspace due to this error code, return -ERESTARTNOINTR > instead. > > Signed-off-by: Jan Kara > --- > fs/notify/fanotify/fanotify.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > Orion, can you give this patch some testing with your usecase? Also if anybody > sees any issue with returning -ERESTARTNOINTR I have missed, please speak up. Ping Orion? Did you have any chance to give this patch a try? Does it fix hibernation issues you observe without causing issues with bash and other programs? I'd like to queue this patch for the coming merge window but I'd like to see some testing results showing that it actually helps anything... Thanks! Honza > > diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c > index 6b9c27548997..eb790853844b 100644 > --- a/fs/notify/fanotify/fanotify.c > +++ b/fs/notify/fanotify/fanotify.c > @@ -92,10 +92,17 @@ static int fanotify_get_response(struct fsnotify_group *group, > > pr_debug("%s: group=%p event=%p\n", __func__, group, event); > > - ret = wait_event_killable(group->fanotify_data.access_waitq, > - event->state == FAN_EVENT_ANSWERED); > + ret = wait_event_interruptible(group->fanotify_data.access_waitq, > + event->state == FAN_EVENT_ANSWERED); > /* Signal pending? */ > if (ret < 0) { > + /* > + * Force restarting a syscall so that this is mostly invisible > + * for userspace which is not prepared for handling EINTR e.g. > + * from open(2). > + */ > + if (ret == -ERESTARTSYS) > + ret = -ERESTARTNOINTR; > spin_lock(&group->notification_lock); > /* Event reported to userspace and no answer yet? */ > if (event->state == FAN_EVENT_REPORTED) { > -- > 2.16.4 > -- Jan Kara SUSE Labs, CR