Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp147604pxb; Mon, 18 Oct 2021 23:08:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgw+KFlGSGDNjZWrBSZ+zzAvn5JLPJUUEa7ItjyhQP/WJ6PqskNIlbnl2M75Z1CnlN9z9Z X-Received: by 2002:a05:6a00:2389:b0:44d:6d57:a38e with SMTP id f9-20020a056a00238900b0044d6d57a38emr33667779pfc.50.1634623715732; Mon, 18 Oct 2021 23:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634623715; cv=none; d=google.com; s=arc-20160816; b=0sKQB4TwDK1u49ORVnoUJIE1LuAziLT8RN0DMYBHU+YSBsR3DrUpy4jqgDijqNbP/a yfYKTk+Asr+B97pNk//3si86gyiZcsK94dAwrze4mvSvp3kgWrtp+RxHPi2v6dYPhd3k 6YOrjXyYtueoWU2/AnN/okhlm+zhqRnObBiVN+Kh2MFbBrLorKPo7IsfAqMMT/CesU+3 qwpnsBGAu0F7dzs8eWtRwODM0SmV8t7wvGPyZJ8hZ2jIbvZhD7zKpGu2wNC6PZx2eYLU 8cOEVJVDp7HK12AP1oOi4hFzFRzOG2OYV8QBNA6FWRyn9zRrkCi1JXwE8ZA05Hw1rA1m dFuQ== 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=OJPnE53wDyw02nOZlJ76Hqx6u6J9KEzgtWn7Df9CAAI=; b=J8ckpU9Fb0ERCs6k9EORnu8lV9EkIMV/Sg98IYymT7G1FHNl/g3DJmZTHKM6ei9OLg RePZT23/rdTapzNfVRcbiRx1Sk30lJIHJ3wprhtEnojt/XoUZg8GR9C+xP0Du+Duft2x PZyChmn7xUbALiLRDcfui8X23q/NwY0vgiJRUscRt2GlGwtEeNTSOh2EI/mmTD8B61zE Od56zXXrK3bBmnMnzKACfwQrIlOv6lLoAJObBAyKJAtu6Un+/SC/eUBP2PN8W+iXX2HJ 6gT1xGUmUXeDOuZHTfezmxAL5qtIweJPc7YgMb4y80maCpyfpTyhI7xbL+SJKNZpnVuA /GBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=giPgNCUA; 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 f12si23439017pln.297.2021.10.18.23.08.21; Mon, 18 Oct 2021 23:08:35 -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=giPgNCUA; 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 S234350AbhJSGJ6 (ORCPT + 99 others); Tue, 19 Oct 2021 02:09:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234297AbhJSGJk (ORCPT ); Tue, 19 Oct 2021 02:09:40 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 026C8C061775; Mon, 18 Oct 2021 23:07:17 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id d125so19065585iof.5; Mon, 18 Oct 2021 23:07:16 -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=OJPnE53wDyw02nOZlJ76Hqx6u6J9KEzgtWn7Df9CAAI=; b=giPgNCUAm5DSjZ2U+HWQSSU+UpwWS02/Xog9QldoFnm/LHkmiM4bGI1LBd+YPk48ZL RR4acYiTNdWzPcbMeqkDg7UlvOzCbOSowC8lxOSCrnmevFdoDdyCtNBkF6CZpXeI7CzW 65HYY9/YK5tclFq4rDP38kURAhUHIF0C0jQYoOP4agFM3RyEjIF6rZHUV5qh3AXDgHWN UJksna0Q5aNtfT5endGY8x5r5NJbkUHzGJDlCI4zVClra7UdLmO30TWDFuKYdgOD1KGW E0jRmNXvYpaBaPFEaVZrngrGb1p5sqgfViSiDzFM4N7GIzKX0wAEea0ixhREdUtUcDmM R6tw== 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=OJPnE53wDyw02nOZlJ76Hqx6u6J9KEzgtWn7Df9CAAI=; b=OH1J/3r/ADn842oyS7g1Emv9+m25+030RADvAa2YYjOywyMMDFOnxkS7AAu8OYgrkM Sst5miZ16Z7dcXvHyD0A5qU07qxnSxaJFxnJTrZ10+hJxOYExRz3QpTwIXzmSc/iWR6z 4XtRUmQff6GrGaGM1sPKyBi+Iv/L5QAPmc33434aXD/Hq+eNjwIgE4CCJdimZIKso1/t yU5klTdggyasYUqk/r2z2cpJK0uLAyF4hPwt14OFdCuPn74hd1bVf/PFm2w4aGdwXtHB 3NtAJ5i/wLPlRA+9xy87s0G4WMljCLblVVY7L+ndcpSztsBigDOzPVv1/a/al5Bcg3OE V71A== X-Gm-Message-State: AOAM531oI1wVJZSIQchX7Bs+MVcUzlI6vNZFbxJ88Ym4MhT6H7I4qwsv WfvRVwFhT5SO3iM/JMtrryJBZPRYw7/tvWOsQjbvXAUC4I4= X-Received: by 2002:a05:6638:39c:: with SMTP id y28mr2803433jap.47.1634623635626; Mon, 18 Oct 2021 23:07:15 -0700 (PDT) MIME-Version: 1.0 References: <20211019000015.1666608-1-krisman@collabora.com> <20211019000015.1666608-28-krisman@collabora.com> In-Reply-To: <20211019000015.1666608-28-krisman@collabora.com> From: Amir Goldstein Date: Tue, 19 Oct 2021 09:07:04 +0300 Message-ID: Subject: Re: [PATCH v8 27/32] fanotify: Report fid info for file related file system errors 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 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:04 AM Gabriel Krisman Bertazi wrote: > > Plumb the pieces to add a FID report to error records. Since all error > event memory must be pre-allocated, we pre-allocate the maximum file > handle size possible, such that it should always fit. > > For errors that don't expose a file handle report it with an invalid > FID. > > Signed-off-by: Gabriel Krisman Bertazi > Reviewed-by: Amir Goldstein with minor nit below.. > --- > Changes since v7: > - Move WARN_ON to separate patch (Amir) > - Avoid duplication in the structure definition (Amir) > Changes since v6: > - pass fsid from handle_events > Changes since v5: > - Use preallocated MAX_HANDLE_SZ FH buffer > - Report superblock errors with a zerolength INVALID FID (jan, amir) > --- > fs/notify/fanotify/fanotify.c | 10 ++++++++++ > fs/notify/fanotify/fanotify.h | 11 +++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c > index 45df610debbe..335ce8f88eb8 100644 > --- a/fs/notify/fanotify/fanotify.c > +++ b/fs/notify/fanotify/fanotify.c > @@ -609,7 +609,9 @@ static struct fanotify_event *fanotify_alloc_error_event( > { > struct fs_error_report *report = > fsnotify_data_error_report(data, data_type); > + struct inode *inode = report->inode; > struct fanotify_error_event *fee; > + int fh_len; > > if (WARN_ON_ONCE(!report)) > return NULL; > @@ -622,6 +624,14 @@ static struct fanotify_event *fanotify_alloc_error_event( > fee->err_count = 1; > fee->fsid = *fsid; > > + fh_len = fanotify_encode_fh_len(inode); > + > + /* Bad fh_len. Fallback to using an invalid fh. Should never happen. */ > + if (!fh_len && inode) > + inode = NULL; > + > + fanotify_encode_fh(&fee->object_fh, inode, fh_len, NULL, 0); > + > *hash ^= fanotify_hash_fsid(fsid); > > return &fee->fae; > diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h > index bdf01ad4f9bf..4246a34667b5 100644 > --- a/fs/notify/fanotify/fanotify.h > +++ b/fs/notify/fanotify/fanotify.h > @@ -209,6 +209,9 @@ struct fanotify_error_event { > u32 err_count; /* Suppressed errors count */ > > __kernel_fsid_t fsid; /* FSID this error refers to. */ > + > + /* This must be the last element of the structure. */ > + FANOTIFY_INLINE_FH(MAX_HANDLE_SZ); Does not really have to be last but certainly doesn't hurt Thanks, Amir.