All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 00/15] File system wide monitoring
@ 2021-04-26 18:41 Gabriel Krisman Bertazi
  2021-04-26 18:41 ` [PATCH RFC 01/15] fanotify: Fold event size calculation to its own function Gabriel Krisman Bertazi
                   ` (15 more replies)
  0 siblings, 16 replies; 46+ messages in thread
From: Gabriel Krisman Bertazi @ 2021-04-26 18:41 UTC (permalink / raw)
  To: amir73il, tytso, djwong
  Cc: david, jack, dhowells, khazhy, linux-fsdevel, linux-ext4,
	Gabriel Krisman Bertazi, kernel

Hi,

In an attempt to consolidate some of the feedback from the previous
proposals, I wrote a new attempt to solve the file system error reporting
problem.  Before I spend more time polishing it, I'd like to hear your
feedback if I'm going in the wrong direction, in particular with the
modifications to fsnotify.

This RFC follows up on my previous proposals which attempted to leverage
watch_queue[1] and fsnotify[2] to provide a mechanism for file systems
to push error notifications to user space.  This proposal starts by, as
suggested by Darrick, limiting the scope of what I'm trying to do to an
interface for administrators to monitor the health of a file system,
instead of a generic inteface for file errors.  Therefore, this doesn't
solve the problem of writeback errors or the need to watch a specific
subsystem.

* Format

The feature is implemented on top of fanotify, as a new type of fanotify
mark, FAN_ERROR, which a file system monitoring tool can register to
receive notifications.  A notification is split in three parts, and only
the first is guaranteed to exist for any given error event:

 - FS generic data: A file system agnostic structure that has a generic
 error code and identifies the filesystem.  Basically, it let's
 userspace know something happen on a monitored filesystem.

 - FS location data: Identifies where in the code the problem
 happened. (This is important for the use case of analysing frequent
 error points that we discussed earlier).

 - FS specific data: A detailed error report in a filesystem specific
 format that details what the error is.  Ideally, a capable monitoring
 tool can use the information here for error recovery.  For instance,
 xfs can put the xfs_scrub structures here, ext4 can send its error
 reports, etc.  An example of usage is done in the ext4 patch of this
 series.

More details on the information in each record can be found on the
documentation introduced in patch 15.

* Using fanotify

Using fanotify for this kind of thing is slightly tricky because we want
to guarantee delivery in some complicated conditions, for instance, the
file system might want to send an error while holding several locks.

Instead of working around file system constraints at the file system
level, this proposal tries to make the FAN_ERROR submission safe in
those contexts.  This is done with a new mode in fsnotify that
preallocates the memory at group creation to be used for the
notification submission.

This new mode in fsnotify introduces a ring buffer to queue
notifications, which eliminates the allocation path in fsnotify.  From
what I saw, the allocation is the only problem in fsnotify for
filesystems to submit errors in constrained situations.

* Visibility

Since the usecase is limited to a tool for whole file system monitoring,
errors are associated with the superblock and visible filesystem-wide.
It is assumed and required that userspace has CAP_SYS_ADMIN.

* Testing

This was tested with corrupted ext4 images in a few scenarios, which
caused errors to be triggered and monitored with the sample tool
provided in the next to final patch.

* patches

Patches 1-4 massage fanotify attempt to refactor fanotify a bit for
the patches to come.  Patch 5 introduce the ring buffer interface to
fsnotify, while patch 6 enable this support in fanotify.  Patch 7, 8 wire
the FS_ERROR event type, which will be used by filesystems.  In
sequennce, patches 9-12 implement the FAN_ERROR record types and create
the new event.  Patch 13 is an ext4 example implementation supporting
this feature.  Finally, patches 14 and 15 document and provide examples
of a userspace tool that uses this feature.

I also pushed the full series to:

  https://gitlab.collabora.com/krisman/linux -b fanotify-notifications

[1] https://lwn.net/Articles/839310/
[2] https://www.spinics.net/lists/linux-fsdevel/msg187075.html

Gabriel Krisman Bertazi (15):
  fanotify: Fold event size calculation to its own function
  fanotify: Split fsid check from other fid mode checks
  fsnotify: Wire flags field on group allocation
  fsnotify: Wire up group information on event initialization
  fsnotify: Support event submission through ring buffer
  fanotify: Support submission through ring buffer
  fsnotify: Support FS_ERROR event type
  fsnotify: Introduce helpers to send error_events
  fanotify: Introduce generic error record
  fanotify: Introduce code location record
  fanotify: Introduce filesystem specific data record
  fanotify: Introduce the FAN_ERROR mark
  ext4: Send notifications on error
  samples: Add fs error monitoring example
  Documentation: Document the FAN_ERROR framework

 .../admin-guide/filesystem-monitoring.rst     | 103 ++++++
 Documentation/admin-guide/index.rst           |   1 +
 fs/ext4/super.c                               |  60 +++-
 fs/notify/Makefile                            |   2 +-
 fs/notify/dnotify/dnotify.c                   |   2 +-
 fs/notify/fanotify/fanotify.c                 | 127 +++++--
 fs/notify/fanotify/fanotify.h                 |  35 +-
 fs/notify/fanotify/fanotify_user.c            | 319 ++++++++++++++----
 fs/notify/fsnotify.c                          |   2 +-
 fs/notify/group.c                             |  25 +-
 fs/notify/inotify/inotify_fsnotify.c          |   2 +-
 fs/notify/inotify/inotify_user.c              |   4 +-
 fs/notify/notification.c                      |  10 +
 fs/notify/ring.c                              | 199 +++++++++++
 include/linux/fanotify.h                      |  12 +-
 include/linux/fsnotify.h                      |  15 +
 include/linux/fsnotify_backend.h              |  63 +++-
 include/uapi/linux/ext4-notify.h              |  17 +
 include/uapi/linux/fanotify.h                 |  26 ++
 kernel/audit_fsnotify.c                       |   2 +-
 kernel/audit_tree.c                           |   2 +-
 kernel/audit_watch.c                          |   2 +-
 samples/Kconfig                               |   7 +
 samples/Makefile                              |   1 +
 samples/fanotify/Makefile                     |   3 +
 samples/fanotify/fs-monitor.c                 | 135 ++++++++
 26 files changed, 1034 insertions(+), 142 deletions(-)
 create mode 100644 Documentation/admin-guide/filesystem-monitoring.rst
 create mode 100644 fs/notify/ring.c
 create mode 100644 include/uapi/linux/ext4-notify.h
 create mode 100644 samples/fanotify/Makefile
 create mode 100644 samples/fanotify/fs-monitor.c

-- 
2.31.0


^ permalink raw reply	[flat|nested] 46+ messages in thread
* Re: [PATCH RFC 12/15] fanotify: Introduce the FAN_ERROR mark
  2021-04-26 18:41 ` [PATCH RFC 12/15] fanotify: Introduce the FAN_ERROR mark Gabriel Krisman Bertazi
@ 2021-04-29 11:31 ` Dan Carpenter
  2021-04-27  7:25   ` Amir Goldstein
  1 sibling, 0 replies; 46+ messages in thread
From: kernel test robot @ 2021-04-27  4:33 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 5856 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210426184201.4177978-13-krisman@collabora.com>
References: <20210426184201.4177978-13-krisman@collabora.com>
TO: Gabriel Krisman Bertazi <krisman@collabora.com>

Hi Gabriel,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on pcmoore-audit/next]
[also build test WARNING on ext4/dev linus/master v5.12]
[cannot apply to ext3/fsnotify next-20210426]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Gabriel-Krisman-Bertazi/File-system-wide-monitoring/20210427-024627
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git next
:::::: branch date: 10 hours ago
:::::: commit date: 10 hours ago
config: i386-randconfig-m021-20210426 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
fs/notify/fanotify/fanotify_user.c:112 fanotify_event_len() warn: this array is probably non-NULL. 'fee->fs_data'

Old smatch warnings:
fs/notify/fanotify/fanotify_user.c:1443 do_fanotify_mark() error: we previously assumed 'mnt' could be null (see line 1424)

vim +112 fs/notify/fanotify/fanotify_user.c

b5e798df944730 Gabriel Krisman Bertazi 2021-04-26   89  
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26   90  static size_t fanotify_event_len(struct fanotify_event *event,
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26   91  				 unsigned int fid_mode)
5e469c830fdb5a Amir Goldstein          2019-01-10   92  {
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26   93  	size_t event_len = FAN_EVENT_METADATA_LEN;
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26   94  	struct fanotify_info *info;
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26   95  	int dir_fh_len;
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26   96  	int fh_len;
929943b38daf81 Amir Goldstein          2020-07-16   97  	int dot_len = 0;
f454fa610a69b9 Amir Goldstein          2020-07-16   98  
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26   99  	if (fanotify_is_error_event(event->mask)) {
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  100  		struct fanotify_error_event *fee = FANOTIFY_EE(event);
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  101  		/*
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  102  		 *  Error events (FAN_ERROR) have a different format
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  103  		 *  as follows:
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  104  		 * [ event_metadata            ]
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  105  		 * [ fs-generic error header   ]
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  106  		 * [ error location (optional) ]
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  107  		 * [ fs-specific blob          ]
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  108  		 */
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  109  		event_len = fanotify_error_info_len(fee);
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  110  		if (fee->loc.function)
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  111  			event_len += fanotify_location_info_len(&fee->loc);
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26 @112  		if (fee->fs_data)
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  113  			event_len += fanotify_error_fsdata_len(fee);
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  114  		return event_len;
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  115  	}
6179a61e1067e6 Gabriel Krisman Bertazi 2021-04-26  116  
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  117  	if (!fid_mode)
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  118  		return event_len;
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  119  
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  120  	info = fanotify_event_info(event);
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  121  	dir_fh_len = fanotify_event_dir_fh_len(event);
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  122  	fh_len = fanotify_event_object_fh_len(event);
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  123  
929943b38daf81 Amir Goldstein          2020-07-16  124  	if (dir_fh_len) {
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  125  		event_len += fanotify_fid_info_len(dir_fh_len, info->name_len);
929943b38daf81 Amir Goldstein          2020-07-16  126  	} else if ((fid_mode & FAN_REPORT_NAME) && (event->mask & FAN_ONDIR)) {
929943b38daf81 Amir Goldstein          2020-07-16  127  		/*
929943b38daf81 Amir Goldstein          2020-07-16  128  		 * With group flag FAN_REPORT_NAME, if name was not recorded in
929943b38daf81 Amir Goldstein          2020-07-16  129  		 * event on a directory, we will report the name ".".
929943b38daf81 Amir Goldstein          2020-07-16  130  		 */
929943b38daf81 Amir Goldstein          2020-07-16  131  		dot_len = 1;
929943b38daf81 Amir Goldstein          2020-07-16  132  	}
afc894c784c84c Jan Kara                2020-03-24  133  
44d705b0370b1d Amir Goldstein          2020-03-19  134  	if (fh_len)
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  135  		event_len += fanotify_fid_info_len(fh_len, dot_len);
5e469c830fdb5a Amir Goldstein          2019-01-10  136  
380d986e6a7cb0 Gabriel Krisman Bertazi 2021-04-26  137  	return event_len;
5e469c830fdb5a Amir Goldstein          2019-01-10  138  }
5e469c830fdb5a Amir Goldstein          2019-01-10  139  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 41522 bytes --]

^ permalink raw reply	[flat|nested] 46+ messages in thread
* Re: [PATCH RFC 13/15] ext4: Send notifications on error
  2021-04-26 18:41 ` [PATCH RFC 13/15] ext4: Send notifications on error Gabriel Krisman Bertazi
@ 2021-04-29 13:19 ` Dan Carpenter
  2021-04-27  4:32   ` Amir Goldstein
  2021-04-29  0:57   ` Darrick J. Wong
  2 siblings, 0 replies; 46+ messages in thread
From: kernel test robot @ 2021-04-27  8:36 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 17965 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210426184201.4177978-14-krisman@collabora.com>
References: <20210426184201.4177978-14-krisman@collabora.com>
TO: Gabriel Krisman Bertazi <krisman@collabora.com>

Hi Gabriel,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on pcmoore-audit/next]
[also build test WARNING on ext4/dev linus/master v5.12]
[cannot apply to ext3/fsnotify next-20210426]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Gabriel-Krisman-Bertazi/File-system-wide-monitoring/20210427-024627
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git next
:::::: branch date: 14 hours ago
:::::: commit date: 14 hours ago
config: i386-randconfig-m021-20210426 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
fs/ext4/super.c:739 ext4_fsnotify_error() warn: variable dereferenced before check 'inode' (see line 738)
fs/ext4/super.c:918 __ext4_std_error() error: uninitialized symbol 'errstr'.

Old smatch warnings:
fs/ext4/super.c:3787 ext4_register_li_request() error: we previously assumed 'ext4_li_info' could be null (see line 3769)
fs/ext4/super.c:4463 ext4_fill_super() warn: bitwise AND condition is false here

vim +/inode +739 fs/ext4/super.c

ac27a0ec112a08 Dave Kleikamp           2006-10-11  731  
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  732  static void ext4_fsnotify_error(int error, struct inode *inode, __u64 block,
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  733  				const char *func, int line,
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  734  				const char *desc, struct va_format *vaf)
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  735  {
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  736  	struct ext4_error_inode_report report;
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  737  
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26 @738  	if (inode->i_sb->s_fsnotify_marks) {
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26 @739  		report.inode = inode ? inode->i_ino : -1L;
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  740  		report.block = block ? block : -1L;
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  741  
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  742  		snprintf(report.desc, EXT4_FSN_DESC_LEN, "%s%pV\n", desc?:"", vaf);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  743  
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  744  		fsnotify_error_event(error, inode, func, line, &report, sizeof(report));
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  745  	}
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  746  }
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  747  
efbed4dc5857f8 Theodore Ts'o           2013-10-17  748  #define ext4_error_ratelimit(sb)					\
efbed4dc5857f8 Theodore Ts'o           2013-10-17  749  		___ratelimit(&(EXT4_SB(sb)->s_err_ratelimit_state),	\
efbed4dc5857f8 Theodore Ts'o           2013-10-17  750  			     "EXT4-fs error")
efbed4dc5857f8 Theodore Ts'o           2013-10-17  751  
12062dddda4509 Eric Sandeen            2010-02-15  752  void __ext4_error(struct super_block *sb, const char *function,
014c9caa29d3a4 Jan Kara                2020-11-27  753  		  unsigned int line, bool force_ro, int error, __u64 block,
54d3adbc29f0c7 Theodore Ts'o           2020-03-28  754  		  const char *fmt, ...)
ac27a0ec112a08 Dave Kleikamp           2006-10-11  755  {
0ff2ea7d84e311 Joe Perches             2010-12-19  756  	struct va_format vaf;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  757  	va_list args;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  758  
0db1ff222d40f1 Theodore Ts'o           2017-02-05  759  	if (unlikely(ext4_forced_shutdown(EXT4_SB(sb))))
0db1ff222d40f1 Theodore Ts'o           2017-02-05  760  		return;
0db1ff222d40f1 Theodore Ts'o           2017-02-05  761  
ccf0f32acd436b Theodore Ts'o           2018-02-18  762  	trace_ext4_error(sb, function, line);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  763  
ac27a0ec112a08 Dave Kleikamp           2006-10-11  764  	va_start(args, fmt);
0ff2ea7d84e311 Joe Perches             2010-12-19  765  	vaf.fmt = fmt;
0ff2ea7d84e311 Joe Perches             2010-12-19  766  	vaf.va = &args;
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  767  	if (ext4_error_ratelimit(sb)) {
efbed4dc5857f8 Theodore Ts'o           2013-10-17  768  		printk(KERN_CRIT
efbed4dc5857f8 Theodore Ts'o           2013-10-17  769  		       "EXT4-fs error (device %s): %s:%d: comm %s: %pV\n",
0ff2ea7d84e311 Joe Perches             2010-12-19  770  		       sb->s_id, function, line, current->comm, &vaf);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  771  
efbed4dc5857f8 Theodore Ts'o           2013-10-17  772  	}
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  773  	ext4_fsnotify_error(error, sb->s_root->d_inode, block, function, line, NULL, &vaf);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  774  	va_end(args);
e789ca0cc1d512 Jan Kara                2020-12-16  775  	ext4_handle_error(sb, force_ro, error, 0, block, function, line);
ac27a0ec112a08 Dave Kleikamp           2006-10-11  776  }
ac27a0ec112a08 Dave Kleikamp           2006-10-11  777  
e7c96e8e47baf2 Joe Perches             2013-07-01  778  void __ext4_error_inode(struct inode *inode, const char *function,
54d3adbc29f0c7 Theodore Ts'o           2020-03-28  779  			unsigned int line, ext4_fsblk_t block, int error,
273df556b6ee20 Frank Mayhar            2010-03-02  780  			const char *fmt, ...)
273df556b6ee20 Frank Mayhar            2010-03-02  781  {
273df556b6ee20 Frank Mayhar            2010-03-02  782  	va_list args;
f7c21177af0b32 Theodore Ts'o           2011-01-10  783  	struct va_format vaf;
273df556b6ee20 Frank Mayhar            2010-03-02  784  
0db1ff222d40f1 Theodore Ts'o           2017-02-05  785  	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
0db1ff222d40f1 Theodore Ts'o           2017-02-05  786  		return;
0db1ff222d40f1 Theodore Ts'o           2017-02-05  787  
ccf0f32acd436b Theodore Ts'o           2018-02-18  788  	trace_ext4_error(inode->i_sb, function, line);
273df556b6ee20 Frank Mayhar            2010-03-02  789  	va_start(args, fmt);
f7c21177af0b32 Theodore Ts'o           2011-01-10  790  	vaf.fmt = fmt;
f7c21177af0b32 Theodore Ts'o           2011-01-10  791  	vaf.va = &args;
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  792  	if (ext4_error_ratelimit(inode->i_sb)) {
c398eda0e43a79 Theodore Ts'o           2010-07-27  793  		if (block)
d9ee81da93e86a Joe Perches             2012-03-19  794  			printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: "
d9ee81da93e86a Joe Perches             2012-03-19  795  			       "inode #%lu: block %llu: comm %s: %pV\n",
d9ee81da93e86a Joe Perches             2012-03-19  796  			       inode->i_sb->s_id, function, line, inode->i_ino,
d9ee81da93e86a Joe Perches             2012-03-19  797  			       block, current->comm, &vaf);
d9ee81da93e86a Joe Perches             2012-03-19  798  		else
d9ee81da93e86a Joe Perches             2012-03-19  799  			printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: "
d9ee81da93e86a Joe Perches             2012-03-19  800  			       "inode #%lu: comm %s: %pV\n",
d9ee81da93e86a Joe Perches             2012-03-19  801  			       inode->i_sb->s_id, function, line, inode->i_ino,
d9ee81da93e86a Joe Perches             2012-03-19  802  			       current->comm, &vaf);
efbed4dc5857f8 Theodore Ts'o           2013-10-17  803  	}
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  804  
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  805  	ext4_fsnotify_error(error, inode, block, function, line, NULL, &vaf);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  806  	va_end(args);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  807  
e789ca0cc1d512 Jan Kara                2020-12-16  808  	ext4_handle_error(inode->i_sb, false, error, inode->i_ino, block,
54d3adbc29f0c7 Theodore Ts'o           2020-03-28  809  			  function, line);
273df556b6ee20 Frank Mayhar            2010-03-02  810  }
273df556b6ee20 Frank Mayhar            2010-03-02  811  
e7c96e8e47baf2 Joe Perches             2013-07-01  812  void __ext4_error_file(struct file *file, const char *function,
f7c21177af0b32 Theodore Ts'o           2011-01-10  813  		       unsigned int line, ext4_fsblk_t block,
f7c21177af0b32 Theodore Ts'o           2011-01-10  814  		       const char *fmt, ...)
273df556b6ee20 Frank Mayhar            2010-03-02  815  {
273df556b6ee20 Frank Mayhar            2010-03-02  816  	va_list args;
f7c21177af0b32 Theodore Ts'o           2011-01-10  817  	struct va_format vaf;
496ad9aa8ef448 Al Viro                 2013-01-23  818  	struct inode *inode = file_inode(file);
273df556b6ee20 Frank Mayhar            2010-03-02  819  	char pathname[80], *path;
273df556b6ee20 Frank Mayhar            2010-03-02  820  
0db1ff222d40f1 Theodore Ts'o           2017-02-05  821  	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
0db1ff222d40f1 Theodore Ts'o           2017-02-05  822  		return;
0db1ff222d40f1 Theodore Ts'o           2017-02-05  823  
ccf0f32acd436b Theodore Ts'o           2018-02-18  824  	trace_ext4_error(inode->i_sb, function, line);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  825  
9bf39ab2adafd7 Miklos Szeredi          2015-06-19  826  	path = file_path(file, pathname, sizeof(pathname));
f9a62d090cf47f Dan Carpenter           2011-01-10  827  	if (IS_ERR(path))
273df556b6ee20 Frank Mayhar            2010-03-02  828  		path = "(unknown)";
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  829  
f7c21177af0b32 Theodore Ts'o           2011-01-10  830  	va_start(args, fmt);
f7c21177af0b32 Theodore Ts'o           2011-01-10  831  	vaf.fmt = fmt;
f7c21177af0b32 Theodore Ts'o           2011-01-10  832  	vaf.va = &args;
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  833  
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  834  	if (ext4_error_ratelimit(inode->i_sb)) {
d9ee81da93e86a Joe Perches             2012-03-19  835  		if (block)
d9ee81da93e86a Joe Perches             2012-03-19  836  			printk(KERN_CRIT
d9ee81da93e86a Joe Perches             2012-03-19  837  			       "EXT4-fs error (device %s): %s:%d: inode #%lu: "
d9ee81da93e86a Joe Perches             2012-03-19  838  			       "block %llu: comm %s: path %s: %pV\n",
d9ee81da93e86a Joe Perches             2012-03-19  839  			       inode->i_sb->s_id, function, line, inode->i_ino,
d9ee81da93e86a Joe Perches             2012-03-19  840  			       block, current->comm, path, &vaf);
d9ee81da93e86a Joe Perches             2012-03-19  841  		else
d9ee81da93e86a Joe Perches             2012-03-19  842  			printk(KERN_CRIT
d9ee81da93e86a Joe Perches             2012-03-19  843  			       "EXT4-fs error (device %s): %s:%d: inode #%lu: "
d9ee81da93e86a Joe Perches             2012-03-19  844  			       "comm %s: path %s: %pV\n",
d9ee81da93e86a Joe Perches             2012-03-19  845  			       inode->i_sb->s_id, function, line, inode->i_ino,
d9ee81da93e86a Joe Perches             2012-03-19  846  			       current->comm, path, &vaf);
efbed4dc5857f8 Theodore Ts'o           2013-10-17  847  	}
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  848  	ext4_fsnotify_error(EFSCORRUPTED, inode, block, function, line, NULL, &vaf);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  849  	va_end(args);
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26  850  
e789ca0cc1d512 Jan Kara                2020-12-16  851  	ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block,
54d3adbc29f0c7 Theodore Ts'o           2020-03-28  852  			  function, line);
273df556b6ee20 Frank Mayhar            2010-03-02  853  }
273df556b6ee20 Frank Mayhar            2010-03-02  854  
722887ddc8982f Theodore Ts'o           2013-02-08  855  const char *ext4_decode_error(struct super_block *sb, int errno,
ac27a0ec112a08 Dave Kleikamp           2006-10-11  856  			      char nbuf[16])
ac27a0ec112a08 Dave Kleikamp           2006-10-11  857  {
ac27a0ec112a08 Dave Kleikamp           2006-10-11  858  	char *errstr = NULL;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  859  
ac27a0ec112a08 Dave Kleikamp           2006-10-11  860  	switch (errno) {
6a797d27378389 Darrick J. Wong         2015-10-17  861  	case -EFSCORRUPTED:
6a797d27378389 Darrick J. Wong         2015-10-17  862  		errstr = "Corrupt filesystem";
6a797d27378389 Darrick J. Wong         2015-10-17  863  		break;
6a797d27378389 Darrick J. Wong         2015-10-17  864  	case -EFSBADCRC:
6a797d27378389 Darrick J. Wong         2015-10-17  865  		errstr = "Filesystem failed CRC";
6a797d27378389 Darrick J. Wong         2015-10-17  866  		break;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  867  	case -EIO:
ac27a0ec112a08 Dave Kleikamp           2006-10-11  868  		errstr = "IO failure";
ac27a0ec112a08 Dave Kleikamp           2006-10-11  869  		break;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  870  	case -ENOMEM:
ac27a0ec112a08 Dave Kleikamp           2006-10-11  871  		errstr = "Out of memory";
ac27a0ec112a08 Dave Kleikamp           2006-10-11  872  		break;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  873  	case -EROFS:
78f1ddbb498283 Theodore Ts'o           2009-07-27  874  		if (!sb || (EXT4_SB(sb)->s_journal &&
78f1ddbb498283 Theodore Ts'o           2009-07-27  875  			    EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT))
ac27a0ec112a08 Dave Kleikamp           2006-10-11  876  			errstr = "Journal has aborted";
ac27a0ec112a08 Dave Kleikamp           2006-10-11  877  		else
ac27a0ec112a08 Dave Kleikamp           2006-10-11  878  			errstr = "Readonly filesystem";
ac27a0ec112a08 Dave Kleikamp           2006-10-11  879  		break;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  880  	default:
ac27a0ec112a08 Dave Kleikamp           2006-10-11  881  		/* If the caller passed in an extra buffer for unknown
ac27a0ec112a08 Dave Kleikamp           2006-10-11  882  		 * errors, textualise them now.  Else we just return
ac27a0ec112a08 Dave Kleikamp           2006-10-11  883  		 * NULL. */
ac27a0ec112a08 Dave Kleikamp           2006-10-11  884  		if (nbuf) {
ac27a0ec112a08 Dave Kleikamp           2006-10-11  885  			/* Check for truncated error codes... */
ac27a0ec112a08 Dave Kleikamp           2006-10-11  886  			if (snprintf(nbuf, 16, "error %d", -errno) >= 0)
ac27a0ec112a08 Dave Kleikamp           2006-10-11  887  				errstr = nbuf;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  888  		}
ac27a0ec112a08 Dave Kleikamp           2006-10-11  889  		break;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  890  	}
ac27a0ec112a08 Dave Kleikamp           2006-10-11  891  
ac27a0ec112a08 Dave Kleikamp           2006-10-11  892  	return errstr;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  893  }
ac27a0ec112a08 Dave Kleikamp           2006-10-11  894  
617ba13b31fbf5 Mingming Cao            2006-10-11  895  /* __ext4_std_error decodes expected errors from journaling functions
ac27a0ec112a08 Dave Kleikamp           2006-10-11  896   * automatically and invokes the appropriate error response.  */
ac27a0ec112a08 Dave Kleikamp           2006-10-11  897  
c398eda0e43a79 Theodore Ts'o           2010-07-27  898  void __ext4_std_error(struct super_block *sb, const char *function,
c398eda0e43a79 Theodore Ts'o           2010-07-27  899  		      unsigned int line, int errno)
ac27a0ec112a08 Dave Kleikamp           2006-10-11  900  {
ac27a0ec112a08 Dave Kleikamp           2006-10-11  901  	char nbuf[16];
ac27a0ec112a08 Dave Kleikamp           2006-10-11  902  	const char *errstr;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  903  
0db1ff222d40f1 Theodore Ts'o           2017-02-05  904  	if (unlikely(ext4_forced_shutdown(EXT4_SB(sb))))
0db1ff222d40f1 Theodore Ts'o           2017-02-05  905  		return;
0db1ff222d40f1 Theodore Ts'o           2017-02-05  906  
ac27a0ec112a08 Dave Kleikamp           2006-10-11  907  	/* Special case: if the error is EROFS, and we're not already
ac27a0ec112a08 Dave Kleikamp           2006-10-11  908  	 * inside a transaction, then there's really no point in logging
ac27a0ec112a08 Dave Kleikamp           2006-10-11  909  	 * an error. */
bc98a42c1f7d0f David Howells           2017-07-17  910  	if (errno == -EROFS && journal_current_handle() == NULL && sb_rdonly(sb))
ac27a0ec112a08 Dave Kleikamp           2006-10-11  911  		return;
ac27a0ec112a08 Dave Kleikamp           2006-10-11  912  
efbed4dc5857f8 Theodore Ts'o           2013-10-17  913  	if (ext4_error_ratelimit(sb)) {
617ba13b31fbf5 Mingming Cao            2006-10-11  914  		errstr = ext4_decode_error(sb, errno, nbuf);
c398eda0e43a79 Theodore Ts'o           2010-07-27  915  		printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n",
c398eda0e43a79 Theodore Ts'o           2010-07-27  916  		       sb->s_id, function, line, errstr);
efbed4dc5857f8 Theodore Ts'o           2013-10-17  917  	}
151ead19fe71b5 Gabriel Krisman Bertazi 2021-04-26 @918  	ext4_fsnotify_error(errno, NULL, -1L, function, line, errstr, NULL);
ac27a0ec112a08 Dave Kleikamp           2006-10-11  919  
e789ca0cc1d512 Jan Kara                2020-12-16  920  	ext4_handle_error(sb, false, -errno, 0, 0, function, line);
ac27a0ec112a08 Dave Kleikamp           2006-10-11  921  }
ac27a0ec112a08 Dave Kleikamp           2006-10-11  922  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 41522 bytes --]

^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2021-05-11 10:43 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 18:41 [PATCH RFC 00/15] File system wide monitoring Gabriel Krisman Bertazi
2021-04-26 18:41 ` [PATCH RFC 01/15] fanotify: Fold event size calculation to its own function Gabriel Krisman Bertazi
2021-04-27  4:42   ` Amir Goldstein
2021-04-26 18:41 ` [PATCH RFC 02/15] fanotify: Split fsid check from other fid mode checks Gabriel Krisman Bertazi
2021-04-27  4:53   ` Amir Goldstein
2021-04-26 18:41 ` [PATCH RFC 03/15] fsnotify: Wire flags field on group allocation Gabriel Krisman Bertazi
2021-04-27  5:03   ` Amir Goldstein
2021-04-26 18:41 ` [PATCH RFC 04/15] fsnotify: Wire up group information on event initialization Gabriel Krisman Bertazi
2021-04-26 18:41 ` [PATCH RFC 05/15] fsnotify: Support event submission through ring buffer Gabriel Krisman Bertazi
2021-04-26 22:00   ` kernel test robot
2021-04-26 22:43   ` kernel test robot
2021-04-27  5:39   ` Amir Goldstein
2021-04-29 18:33     ` Gabriel Krisman Bertazi
2021-04-26 18:41 ` [PATCH RFC 06/15] fanotify: Support " Gabriel Krisman Bertazi
2021-04-27  6:02   ` Amir Goldstein
2021-04-29 18:36     ` Gabriel Krisman Bertazi
2021-04-26 18:41 ` [PATCH RFC 07/15] fsnotify: Support FS_ERROR event type Gabriel Krisman Bertazi
2021-04-27  8:39   ` Amir Goldstein
2021-04-26 18:41 ` [PATCH RFC 08/15] fsnotify: Introduce helpers to send error_events Gabriel Krisman Bertazi
2021-04-27  6:49   ` Amir Goldstein
2021-04-26 18:41 ` [PATCH RFC 09/15] fanotify: Introduce generic error record Gabriel Krisman Bertazi
2021-04-27  7:01   ` Amir Goldstein
2021-04-26 18:41 ` [PATCH RFC 10/15] fanotify: Introduce code location record Gabriel Krisman Bertazi
2021-04-27  7:11   ` Amir Goldstein
2021-04-29 18:40     ` Gabriel Krisman Bertazi
2021-05-11  5:35       ` Khazhy Kumykov
2021-04-26 18:41 ` [PATCH RFC 11/15] fanotify: Introduce filesystem specific data record Gabriel Krisman Bertazi
2021-04-27  7:12   ` Amir Goldstein
2021-04-26 18:41 ` [PATCH RFC 12/15] fanotify: Introduce the FAN_ERROR mark Gabriel Krisman Bertazi
2021-04-26 22:45   ` kernel test robot
2021-04-27  7:25   ` Amir Goldstein
2021-04-26 18:41 ` [PATCH RFC 13/15] ext4: Send notifications on error Gabriel Krisman Bertazi
2021-04-26 23:10   ` kernel test robot
2021-04-27  4:32   ` Amir Goldstein
2021-04-29  0:57   ` Darrick J. Wong
2021-04-26 18:42 ` [PATCH RFC 14/15] samples: Add fs error monitoring example Gabriel Krisman Bertazi
2021-04-26 23:10   ` kernel test robot
2021-04-26 18:42 ` [PATCH RFC 15/15] Documentation: Document the FAN_ERROR framework Gabriel Krisman Bertazi
2021-04-27  4:11 ` [PATCH RFC 00/15] File system wide monitoring Amir Goldstein
2021-04-27 15:44   ` Gabriel Krisman Bertazi
2021-05-11  4:45     ` Khazhy Kumykov
2021-05-11 10:43   ` Jan Kara
2021-04-27  4:33 [PATCH RFC 12/15] fanotify: Introduce the FAN_ERROR mark kernel test robot
2021-04-29 11:31 ` Dan Carpenter
2021-04-27  8:36 [PATCH RFC 13/15] ext4: Send notifications on error kernel test robot
2021-04-29 13:19 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.