Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp668957pxb; Mon, 16 Aug 2021 14:42:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnWVn10Nyejm9YJGwj8aep/ZgRMr8QF6/rjB5AGIab/GW6Xl6i6+7KncsFOtIqMOkjWSEh X-Received: by 2002:a92:d5c7:: with SMTP id d7mr39465ilq.217.1629150148303; Mon, 16 Aug 2021 14:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629150148; cv=none; d=google.com; s=arc-20160816; b=wua70S3N7r7HvNi7QVGoXta2Rj/pjFBjlzJBQFnO89uM+tvwn9/hZaw7tzC11wP4tS G01KTrUfdeld2r6gDAmJAblU7M+2TpBrWaGFLi0QJ0JMBY+I0BVCTfP9gBQqhK2CzgeP mq2jDQjGG9BGIZC/4jJxdHIXA0G0XEGAX6z2GBkqNNfoFbzfXlcMK13fAk4KW0n58FBH HC8xDnjbug5ZEOpWqv1tviY78mHNexG5TIT9YGVYnmtk51DQfoSGfhcLEEhXabpdy6xJ 62exW89ofTI5FasKVb5bH2c9BkUjxjqZcdxQ7SRY5ZR1JtzqLO46LAKNkfakNxOdVvwe fDfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MyXKLJ8YRZsB2srf178FWYl7Vea6sm/6kWTI+c1tJPk=; b=Cq5kvaGLnFyEkGujb54sEOsj7+079cY4D1WKq87i35k8yg9gly5CZ3TAtfKvZzlM3c DfvHzz0xS/P1WFBx8mK+s0arn1Zv4LSm2fnqrW/M4ZG8GRAKT7Fb3r/rqbXJVE9PdpnJ Hql1L0NDAOaky2+qGhYYxNtVp0+PbVkMW8nYA3UAx8xB9XSCAazDdFzXKOALpYPP+J4z PmoC+kPuu5FKaytifBtjGwFkDZpwBxvqj4ew7Kqdr8HgWsGqwG1eLiy5vOswhDtacssf mOEsuFioGrfz94rfMqGMJVxvuP9rf4PZJtOGyXy+231naO/v9CSHxfafmFn3R8bXUcP7 ZnAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RHknz1j3; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j4si63679ilc.2.2021.08.16.14.42.05; Mon, 16 Aug 2021 14:42:28 -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=@kernel.org header.s=k20201202 header.b=RHknz1j3; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233672AbhHPVlj (ORCPT + 99 others); Mon, 16 Aug 2021 17:41:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:37154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229987AbhHPVlg (ORCPT ); Mon, 16 Aug 2021 17:41:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2EC9960E09; Mon, 16 Aug 2021 21:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629150064; bh=20nFMMREAcxNH6QbkQ0N0qSyPuh5AN9LdcPTNM8PNjs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RHknz1j31Z6FKlzVMbHugSLYht7pulY+wT/1twvGFT18Ded8tg+SnTo7CMJbjoYeM mfH9BP4EG6+Z7pmD+VhVvJfaTNBRvCNJ5QPpc/yC4LedqeRuv/gqclhPza5i/Zt2vC f0k06hsdVmmsW0sbP6oOX49TLQEraPdhIqyecFn9L/YgHCVbnknusS56sAweuqyXza fJ3Qf18jaLWKuE9JYvd2pBWcbjVjS7H+NXWP2mKPFYbn/eI799doCFPDreJA4UNuBS 0xhqozhfFiikTmjt3/6QG0aW/zC84hrOyPFNJVd9fFRGjFILCoxzjiWO9HpBRAXxtI pm/w/jTvq42gg== Date: Mon, 16 Aug 2021 14:41:03 -0700 From: "Darrick J. Wong" To: Gabriel Krisman Bertazi Cc: amir73il@gmail.com, jack@suse.com, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, khazhy@google.com, dhowells@redhat.com, david@fromorbit.com, tytso@mit.edu, repnop@google.com, kernel@collabora.com Subject: Re: [PATCH v6 18/21] fanotify: Emit generic error info type for error event Message-ID: <20210816214103.GA12664@magnolia> References: <20210812214010.3197279-1-krisman@collabora.com> <20210812214010.3197279-19-krisman@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210812214010.3197279-19-krisman@collabora.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Aug 12, 2021 at 05:40:07PM -0400, Gabriel Krisman Bertazi wrote: > The Error info type is a record sent to users on FAN_FS_ERROR events > documenting the type of error. It also carries an error count, > documenting how many errors were observed since the last reporting. > > Signed-off-by: Gabriel Krisman Bertazi > > --- > Changes since v5: > - Move error code here > --- > fs/notify/fanotify/fanotify.c | 1 + > fs/notify/fanotify/fanotify.h | 1 + > fs/notify/fanotify/fanotify_user.c | 36 ++++++++++++++++++++++++++++++ > include/uapi/linux/fanotify.h | 7 ++++++ > 4 files changed, 45 insertions(+) > diff --git a/include/uapi/linux/fanotify.h b/include/uapi/linux/fanotify.h > index 16402037fc7a..80040a92e9d9 100644 > --- a/include/uapi/linux/fanotify.h > +++ b/include/uapi/linux/fanotify.h > @@ -124,6 +124,7 @@ struct fanotify_event_metadata { > #define FAN_EVENT_INFO_TYPE_FID 1 > #define FAN_EVENT_INFO_TYPE_DFID_NAME 2 > #define FAN_EVENT_INFO_TYPE_DFID 3 > +#define FAN_EVENT_INFO_TYPE_ERROR 4 > > /* Variable length info record following event metadata */ > struct fanotify_event_info_header { > @@ -149,6 +150,12 @@ struct fanotify_event_info_fid { > unsigned char handle[0]; > }; > > +struct fanotify_event_info_error { > + struct fanotify_event_info_header hdr; > + __s32 error; > + __u32 error_count; > +}; My apologies for not having time to review this patchset since it was redesigned to use fanotify. Someday it would be helpful to be able to export more detailed error reports from XFS, but as I'm not ready to move forward and write that today, I'll try to avoid derailling this at the last minute. Eventually, XFS might want to be able to report errors in file data, file metadata, allocation group metadata, and whole-filesystem metadata. Userspace can already gather reports from XFS about corruptions reported by the online fsck code (see xfs_health.c). I /think/ we could subclass the file error structure that you've provided like so: struct fanotify_event_info_xfs_filesystem_error { struct fanotify_event_info_error base; __u32 magic; /* 0x58465342 to identify xfs */ __u32 type; /* quotas, realtime bitmap, etc. */ }; struct fanotify_event_info_xfs_perag_error { struct fanotify_event_info_error base; __u32 magic; /* 0x58465342 to identify xfs */ __u32 type; /* agf, agi, agfl, bno btree, ino btree, etc. */ __u32 agno; /* allocation group number */ }; struct fanotify_event_info_xfs_file_error { struct fanotify_event_info_error base; __u32 magic; /* 0x58465342 to identify xfs */ __u32 type; /* extent map, dir, attr, etc. */ __u64 offset; /* file data offset, if applicable */ __u64 length; /* file data length, if applicable */ }; (A real XFS implementation might have one structure with the type code providing for a tagged union or something; I split it into three separate structs here to avoid confusing things.) I have three questions at this point: 1) What's the maximum size of a fanotify event structure? None of these structures exceed 36 bytes, which I hope will fit in whatever size constraints? 2) If a program written for today's notification events sees a fanotify_event_info_header from future-XFS with a header length that is larger than FANOTIFY_INFO_ERROR_LEN, will it be able to react appropriately? Which is to say, ignore it on the grounds that the length is unexpectedly large? It /looks/ like this is the case; really I'm just fishing around here to make sure nothing in the design of /this/ patchset would make it Very Difficult(tm) to add more information later. 3) Once we let filesystem implementations create their own extended error notifications, should we have a "u32 magic" to aid in decoding? Or even add it to fanotify_event_info_error now? --D > + > struct fanotify_response { > __s32 fd; > __u32 response; > -- > 2.32.0 >