Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp140011pxb; Mon, 18 Oct 2021 22:56:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMtxV3MsZpaFFsYrgSHIgF26EXI87HNPGsEj/VWC7fJOYn1iUcVi9snionhNuFFTkC/0V/ X-Received: by 2002:a05:6402:1390:: with SMTP id b16mr49714125edv.166.1634622965693; Mon, 18 Oct 2021 22:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634622965; cv=none; d=google.com; s=arc-20160816; b=YFLDra5vanf/etGFPlUp2uwvPdOvGDybRxK4jtPoacu1wUVit9Qpli6FdaNHrmOJUc Gzdrh25oBWYuTGE6+Web8GuOkHw8uZk48AURqLm1Bqa9vi9puh/vNK7TOYv5jDWe/zDt l6jMuBIUHX6fqFF6p2Dk0IhACDW8mpEpIyk9E+keiIk3mGDF9DqBeguBkyO+9uYtHs8g 5hXz5C0/Y+mnhsUMYysHW+k76XyBHDuVPvw/0gtcS0tcvSHHxeEjTVBoKNESu2nwnKqJ 6uCAYGiepDE5LSJphpwFUKNQ/ZiQZ9BEAqSPymWyYXUNJvDba6C3Bte+pRhGLxpTPbxn ktBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=s7Os6X7/r21pXpIsxTkGiN0sAW85QcFvdx7kW8FSqXg=; b=rgJPUwg9SCDXe4wujTIz+5f634t4Jc/16VGJ8ED4gbj5vNtK/P1rPxeVhAL24byIPB apL8Py1LN6pgmk0BMcJa7LgSVw/L5/CLoYaEZSsSqGtDAQwsoRtAoSYB30/DjyUXQycI oucbb8RNcxAYNgK4mtL7pvlWuyKUSmW82wa/u6sZvdj79lCFSn9rEyHWrus9VHihSjZT HcPcNrwx+SHT/nd8vEkkTrX5I6KyMYJQedLJRd/oVp8K6T+aJJV3ElVgHOMrbjSfXoUi SgTzaYG7k6fXOJuL0tMPUUvFcbpQpy2dIgdhgRO/6N1aq+il38z+ZASBHE0u2LmOjtYV x0tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d4x2D5iM; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n4si22524717edv.329.2021.10.18.22.55.42; Mon, 18 Oct 2021 22:56:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d4x2D5iM; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233786AbhJSFzC (ORCPT + 99 others); Tue, 19 Oct 2021 01:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbhJSFzC (ORCPT ); Tue, 19 Oct 2021 01:55:02 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F1B1C06161C; Mon, 18 Oct 2021 22:52:50 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id k3so6922507ilo.7; Mon, 18 Oct 2021 22:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s7Os6X7/r21pXpIsxTkGiN0sAW85QcFvdx7kW8FSqXg=; b=d4x2D5iMi1HOp9dv9I0Wpx1EEsfeqhJjYw4OZOVLc4Bujol8aMKSSiuQdn0VFLLSma xoBBecCPDxDeu29sRet/WNqRncjXRGwdOV5RVFo3IvTKY+b4q7G4A85OTRXdyS4YevmO dsr9Dq6jquozRwF8GV7E4gqpwxESk6pE64Aqx6/caIwj3Z+KTL0bbxG8p+IrMg89HDx5 mzDqns3AvcqA/Rji5LFFHEnH3MwygFOCAZRkxiv0CpD97Ya1ASFzNZm3xRJXy4aeLu+E V/DsAy0Z9nR2q3vAERI7wInmSMafFV5MEsWcfFP4bAX0J8CHLnBqaCSzrVNqOeXHVMw3 appg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s7Os6X7/r21pXpIsxTkGiN0sAW85QcFvdx7kW8FSqXg=; b=J99jbttW0IauN08HxnAqIAEICviRyXhe7Qk2rG9rkaOsXq1EKMNBB88HL1OfIgmnE2 izIHDYBzC9hq5NcnEHNaVw30I6N2t1fhVWRKS3GHgV0ZklNfzhbUVPLBBTWwfAn3U0md BLRqmC+LX+fihrtcufQ5h23mbc5U0QF4YhmuXmwpbzEqiYgz4VYMVKukMhDMyos2AfwY 1r9a1nTsqa0is1A+W6AsgRdD7QJ5VNti8tAEdo/YYRTyPzZi+MxcssunV7zz7afmB9x4 mIfOw4zrWEst/OLoa7kSDWLk8+NStNyl4vqyZK4v46KTSh+JU7SgWyzw0GDKC+DXSdU/ UVKA== X-Gm-Message-State: AOAM533L8swB0lW5N0bsX6dIo6xark+GzoTLDVleXapz3B2O9uU2+aJ9 Y/lQ9qPE307BgqcyGc7wIzjYXoDKuEQX+ynaqII= X-Received: by 2002:a05:6e02:1b04:: with SMTP id i4mr17480955ilv.319.1634622769866; Mon, 18 Oct 2021 22:52:49 -0700 (PDT) MIME-Version: 1.0 References: <20211019000015.1666608-1-krisman@collabora.com> <20211019000015.1666608-22-krisman@collabora.com> In-Reply-To: <20211019000015.1666608-22-krisman@collabora.com> From: Amir Goldstein Date: Tue, 19 Oct 2021 08:52:38 +0300 Message-ID: Subject: Re: [PATCH v8 21/32] fanotify: Support enqueueing of error events To: Gabriel Krisman Bertazi Cc: Jan Kara , "Darrick J. Wong" , Theodore Tso , Dave Chinner , David Howells , Khazhismel Kumykov , linux-fsdevel , Ext4 , Linux API , kernel@collabora.com, Jan Kara Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Oct 19, 2021 at 3:03 AM Gabriel Krisman Bertazi wrote: > > Once an error event is triggered, enqueue it in the notification group, > similarly to what is done for other events. FAN_FS_ERROR is not > handled specially, since the memory is now handled by a preallocated > mempool. > > For now, make the event unhashed. A future patch implements merging of > this kind of event. > > Reviewed-by: Jan Kara > Signed-off-by: Gabriel Krisman Bertazi > Reviewed-by: Amir Goldstein > --- > Changes since v7: > - WARN_ON -> WARN_ON_ONCE (Amir) > --- > fs/notify/fanotify/fanotify.c | 35 +++++++++++++++++++++++++++++++++++ > fs/notify/fanotify/fanotify.h | 6 ++++++ > 2 files changed, 41 insertions(+) > > diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c > index 01d68dfc74aa..1f195c95dfcd 100644 > --- a/fs/notify/fanotify/fanotify.c > +++ b/fs/notify/fanotify/fanotify.c > @@ -574,6 +574,27 @@ static struct fanotify_event *fanotify_alloc_name_event(struct inode *id, > return &fne->fae; > } > > +static struct fanotify_event *fanotify_alloc_error_event( > + struct fsnotify_group *group, > + __kernel_fsid_t *fsid, > + const void *data, int data_type) > +{ > + struct fs_error_report *report = > + fsnotify_data_error_report(data, data_type); > + struct fanotify_error_event *fee; > + > + if (WARN_ON_ONCE(!report)) > + return NULL; > + > + fee = mempool_alloc(&group->fanotify_data.error_events_pool, GFP_NOFS); > + if (!fee) > + return NULL; > + > + fee->fae.type = FANOTIFY_EVENT_TYPE_FS_ERROR; > + > + return &fee->fae; > +} > + > static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, > u32 mask, const void *data, > int data_type, struct inode *dir, > @@ -641,6 +662,9 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, > > if (fanotify_is_perm_event(mask)) { > event = fanotify_alloc_perm_event(path, gfp); > + } else if (fanotify_is_error_event(mask)) { > + event = fanotify_alloc_error_event(group, fsid, data, > + data_type); > } else if (name_event && (file_name || child)) { > event = fanotify_alloc_name_event(id, fsid, file_name, child, > &hash, gfp); > @@ -850,6 +874,14 @@ static void fanotify_free_name_event(struct fanotify_event *event) > kfree(FANOTIFY_NE(event)); > } > > +static void fanotify_free_error_event(struct fsnotify_group *group, > + struct fanotify_event *event) > +{ > + struct fanotify_error_event *fee = FANOTIFY_EE(event); > + > + mempool_free(fee, &group->fanotify_data.error_events_pool); > +} > + > static void fanotify_free_event(struct fsnotify_group *group, > struct fsnotify_event *fsn_event) > { > @@ -873,6 +905,9 @@ static void fanotify_free_event(struct fsnotify_group *group, > case FANOTIFY_EVENT_TYPE_OVERFLOW: > kfree(event); > break; > + case FANOTIFY_EVENT_TYPE_FS_ERROR: > + fanotify_free_error_event(group, event); > + break; > default: > WARN_ON_ONCE(1); > } > diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h > index a577e87fac2b..ebef952481fa 100644 > --- a/fs/notify/fanotify/fanotify.h > +++ b/fs/notify/fanotify/fanotify.h > @@ -298,6 +298,11 @@ static inline struct fanotify_event *FANOTIFY_E(struct fsnotify_event *fse) > return container_of(fse, struct fanotify_event, fse); > } > > +static inline bool fanotify_is_error_event(u32 mask) > +{ > + return mask & FAN_FS_ERROR; > +} > + > static inline bool fanotify_event_has_path(struct fanotify_event *event) > { > return event->type == FANOTIFY_EVENT_TYPE_PATH || > @@ -327,6 +332,7 @@ static inline struct path *fanotify_event_path(struct fanotify_event *event) > static inline bool fanotify_is_hashed_event(u32 mask) > { > return !(fanotify_is_perm_event(mask) || > + fanotify_is_error_event(mask) || > fsnotify_is_overflow_event(mask)); > } > > -- > 2.33.0 >