From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35376C282C2 for ; Wed, 13 Feb 2019 19:42:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 058CF2083B for ; Wed, 13 Feb 2019 19:42:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HDcrD/CM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388367AbfBMTm4 (ORCPT ); Wed, 13 Feb 2019 14:42:56 -0500 Received: from mail-yb1-f193.google.com ([209.85.219.193]:32826 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730422AbfBMTm4 (ORCPT ); Wed, 13 Feb 2019 14:42:56 -0500 Received: by mail-yb1-f193.google.com with SMTP id w2so1428810ybi.0 for ; Wed, 13 Feb 2019 11:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WwVhMC4bsL778ZcRixeWh7LYhvD/DAElO2WnT+ssm6s=; b=HDcrD/CMxvVgM45IpQ5qKOe98FJLrEzt+aJD204KGszhAlOg8ZN0n7hTsF1XTMtDLQ YUaAMZZo95ruxqHlRvQB++4YwY1OQLzLyVgYKegGHWar5LgQebW8OJhZEWtIc0tjDuo2 FWEUKcJJF7MidKT5ssR60M1rbF/02qsKwp0XEy4UBjxxNTrL1j1cKA892iXRNa4OpZ03 MJ6xJxL4OTWYop83AgDm70Dy/VUW6Ffz1H2IN7mXUBoIyvFayxg3MyXNwne/xEKLfCPi c2jBHT5fPz6VGxpa2zk0/qykOzANPQwkhgQ7EZOIciUy0Zw8MGiNOEINOzpreRgMRfP0 YFfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WwVhMC4bsL778ZcRixeWh7LYhvD/DAElO2WnT+ssm6s=; b=LkhZ+xQ2zCj3By2CHRoUI/Gvp3keQ4rFv4V2vt6sjYY+Jk3CcM5jCCPsW8WeIMw/Sw 8Bj03tgUd5oDh/pCnGApPT+0qRd7VJLFgXaouuh4PEHSqSYxxUM6B4eZgeuBgDTfU9QC 4p0MY0KlhC3CatGD9q8FssAhBddvQYIp/QwGf6vJ4kneDtzoHFZQXEoZlSCXAIH1U0S2 Q7tprJFdRvm6+xIZLM6x9B/3PJA07s6rwXXZ86xImuRfQcHmiq4+jBmEw7eG9ArJvqDM 5PzQuPTFCyxdrH6qbPuYq19v7FtBlHjAUare0WSAmPbV59ewECwZ8Z06kRWbJcWwS2bR pXjg== X-Gm-Message-State: AHQUAuZDtVUtep9xO85O5RToHb1JePD2kntHLJK7+P+MZ+SCK4p7hMay 0g8RYf8J+8kXBBvwWmt1W6QIvbEHMWKBD2FUYxw= X-Google-Smtp-Source: AHgI3IYueN5pMYkoYzZBE5zhlJshgjXwuzyfKzOwWtKkA/qonIGlglCQ8MckiYho+8YFXVrQ0EqiBjQ1zoxWRjixmdY= X-Received: by 2002:a25:ba84:: with SMTP id s4mr2129924ybg.325.1550086975088; Wed, 13 Feb 2019 11:42:55 -0800 (PST) MIME-Version: 1.0 References: <20190213145443.26836-1-jack@suse.cz> <20190213145443.26836-2-jack@suse.cz> In-Reply-To: <20190213145443.26836-2-jack@suse.cz> From: Amir Goldstein Date: Wed, 13 Feb 2019 21:42:44 +0200 Message-ID: Subject: Re: [PATCH 1/6] fanotify: Fold dequeue_event() into process_access_response() To: Jan Kara Cc: linux-fsdevel , Konstantin Khlebnikov , Vivek Trivedi , Orion Poplawski Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Feb 13, 2019 at 4:54 PM Jan Kara wrote: > > Fold dequeue_event() into process_access_response(). This will make > changes to use of ->response field easier. > > Signed-off-by: Jan Kara Reviewed-by: Amir Goldstein > --- > fs/notify/fanotify/fanotify_user.c | 41 ++++++++++++-------------------------- > 1 file changed, 13 insertions(+), 28 deletions(-) > > diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c > index 9c870b0d2b56..908ebc421d15 100644 > --- a/fs/notify/fanotify/fanotify_user.c > +++ b/fs/notify/fanotify/fanotify_user.c > @@ -144,28 +144,6 @@ static int fill_event_metadata(struct fsnotify_group *group, > return ret; > } > > -static struct fanotify_perm_event_info *dequeue_event( > - struct fsnotify_group *group, int fd) > -{ > - struct fanotify_perm_event_info *event, *return_e = NULL; > - > - spin_lock(&group->notification_lock); > - list_for_each_entry(event, &group->fanotify_data.access_list, > - fae.fse.list) { > - if (event->fd != fd) > - continue; > - > - list_del_init(&event->fae.fse.list); > - return_e = event; > - break; > - } > - spin_unlock(&group->notification_lock); > - > - pr_debug("%s: found return_re=%p\n", __func__, return_e); > - > - return return_e; > -} > - > static int process_access_response(struct fsnotify_group *group, > struct fanotify_response *response_struct) > { > @@ -194,14 +172,21 @@ static int process_access_response(struct fsnotify_group *group, > if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT)) > return -EINVAL; > > - event = dequeue_event(group, fd); > - if (!event) > - return -ENOENT; > + spin_lock(&group->notification_lock); > + list_for_each_entry(event, &group->fanotify_data.access_list, > + fae.fse.list) { > + if (event->fd != fd) > + continue; > > - event->response = response; > - wake_up(&group->fanotify_data.access_waitq); > + list_del_init(&event->fae.fse.list); > + event->response = response; > + spin_unlock(&group->notification_lock); > + wake_up(&group->fanotify_data.access_waitq); > + return 0; > + } > + spin_unlock(&group->notification_lock); > > - return 0; > + return -ENOENT; > } > > static ssize_t copy_event_to_user(struct fsnotify_group *group, > -- > 2.16.4 >