Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp691961pxb; Wed, 11 Nov 2020 13:53:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN8MmuyRc8RInxYGMp9idHh7MlgS/EjJsfRwpimL+YtPfn4sjXjP0fYeqM+e05E59Mriz2 X-Received: by 2002:a17:906:1e08:: with SMTP id g8mr27067677ejj.358.1605131630327; Wed, 11 Nov 2020 13:53:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605131630; cv=none; d=google.com; s=arc-20160816; b=UHM4xllhQ6m4YPo4EeCgHM6pk6bELLQizzwnEbyXWzezV7FN2FUuurDkgty34hrElv UzicexdpNotFdQLZ2D8N7A/3r2QkRi/14V08OtznYWQSlGHYLScTfxgP7rdIb+q7MIUq 9JSiSD8j9dm82YJjBp6hf+Yn5IvSg9UQHbuF03WQbD9WILQMqn5wc/nKdygapESP9668 hEbAHz/RX/ThpZEGH9jcQ2PcLzB3YpTHLMGw07y/+FKpLEDrAjFx1f4t9k2gOmVRiP5a SElgsRtypokPvlX6s1Xd1VCkxUVRRcD+E4UbD1+AsW6sLQFkBkESF4Wss3md/xALi01V eXDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=d5IGWt115WkBzx8uK7UptcmgaDn8KcPNQ8mgYK60P4s=; b=uag2vJggEeJd8HLVRSWYp9xuzz5EWvyQcrW/l8UUtuaPWNk0eT4edzkjFudafczpc8 4eFN6m2iobpsIA6f+xhZhZgTBYdKAzGA3caRI+qEPLh77qAXojx5FAlK/GMhmx/9J5C1 JKlHJ0yKAxDAdyNfQ6svCJ3qKID9O5xLSRLCVwv1wRI2LFL5ntRmPA/xhnvWkgBj5vSZ JeDuWt3l3swJaOba9ZtnZgaSz7+NtfFZKjllYb4R7MsguJbaxN16uaYoPw7mEG99oKEC FccZxMpA63oCCBdMBmHBUW3z5icYzRcNNz+X14XKUESZi4RiEwQSedbLheZJetDo38yZ b78Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk22si2394253edb.19.2020.11.11.13.53.26; Wed, 11 Nov 2020 13:53:50 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726255AbgKKVwz (ORCPT + 99 others); Wed, 11 Nov 2020 16:52:55 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49818 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726188AbgKKVwz (ORCPT ); Wed, 11 Nov 2020 16:52:55 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id A2A7C1F45DAF From: Gabriel Krisman Bertazi To: dhowells@redhat.com Cc: viro@zeniv.linux.org.uk, tytso@mit.edu, khazhy@google.com, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH RFC v2 7/8] ext4: Implement SB error notification through watch_sb Date: Wed, 11 Nov 2020 16:52:12 -0500 Message-Id: <20201111215213.4152354-8-krisman@collabora.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201111215213.4152354-1-krisman@collabora.com> References: <20201111215213.4152354-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This follows the same implementation of ext4 error reporting via dmesg, but expose that information via the new watch_queue notifications API. Signed-off-by: Gabriel Krisman Bertazi --- fs/ext4/super.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c3b864588a0b..58dc1e48b683 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -724,15 +724,17 @@ void __ext4_error(struct super_block *sb, const char *function, return; trace_ext4_error(sb, function, line); + va_start(args, fmt); if (ext4_error_ratelimit(sb)) { - va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: comm %s: %pV\n", sb->s_id, function, line, current->comm, &vaf); - va_end(args); } + notify_sb_error(sb, function, line, error, 0, 0, fmt, &args); + va_end(args); + save_error_info(sb, error, 0, block, function, line); ext4_handle_error(sb); } @@ -748,8 +750,8 @@ void __ext4_error_inode(struct inode *inode, const char *function, return; trace_ext4_error(inode->i_sb, function, line); + va_start(args, fmt); if (ext4_error_ratelimit(inode->i_sb)) { - va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; if (block) @@ -762,8 +764,11 @@ void __ext4_error_inode(struct inode *inode, const char *function, "inode #%lu: comm %s: %pV\n", inode->i_sb->s_id, function, line, inode->i_ino, current->comm, &vaf); - va_end(args); } + notify_sb_error(inode->i_sb, function, line, error, inode->i_ino, block, + fmt, &args); + va_end(args); + save_error_info(inode->i_sb, error, inode->i_ino, block, function, line); ext4_handle_error(inode->i_sb); @@ -782,11 +787,11 @@ void __ext4_error_file(struct file *file, const char *function, return; trace_ext4_error(inode->i_sb, function, line); + va_start(args, fmt); if (ext4_error_ratelimit(inode->i_sb)) { path = file_path(file, pathname, sizeof(pathname)); if (IS_ERR(path)) path = "(unknown)"; - va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; if (block) @@ -801,8 +806,11 @@ void __ext4_error_file(struct file *file, const char *function, "comm %s: path %s: %pV\n", inode->i_sb->s_id, function, line, inode->i_ino, current->comm, path, &vaf); - va_end(args); } + notify_sb_error(inode->i_sb, function, line, EFSCORRUPTED, + inode->i_ino, block, fmt, &args); + va_end(args); + save_error_info(inode->i_sb, EFSCORRUPTED, inode->i_ino, block, function, line); ext4_handle_error(inode->i_sb); @@ -872,6 +880,8 @@ void __ext4_std_error(struct super_block *sb, const char *function, sb->s_id, function, line, errstr); } + notify_sb_error(sb, function, line, errno, 0, 0, errstr, NULL); + save_error_info(sb, -errno, 0, 0, function, line); ext4_handle_error(sb); } @@ -901,6 +911,7 @@ void __ext4_abort(struct super_block *sb, const char *function, vaf.va = &args; printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: %pV\n", sb->s_id, function, line, &vaf); + notify_sb_error(sb, function, line, error, 0, 0, fmt, &args); va_end(args); if (sb_rdonly(sb) == 0) { @@ -934,6 +945,7 @@ void __ext4_msg(struct super_block *sb, vaf.fmt = fmt; vaf.va = &args; printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf); + notify_sb_msg(sb, fmt, &args); va_end(args); } @@ -958,6 +970,7 @@ void __ext4_warning(struct super_block *sb, const char *function, vaf.va = &args; printk(KERN_WARNING "EXT4-fs warning (device %s): %s:%d: %pV\n", sb->s_id, function, line, &vaf); + notify_sb_warning(sb, function, line, 0, 0, fmt, &args); va_end(args); } @@ -976,6 +989,7 @@ void __ext4_warning_inode(const struct inode *inode, const char *function, printk(KERN_WARNING "EXT4-fs warning (device %s): %s:%d: " "inode #%lu: comm %s: %pV\n", inode->i_sb->s_id, function, line, inode->i_ino, current->comm, &vaf); + notify_sb_warning(inode->i_sb, function, line, inode->i_ino, 0, fmt, &args); va_end(args); } @@ -995,8 +1009,8 @@ __acquires(bitlock) trace_ext4_error(sb, function, line); __save_error_info(sb, EFSCORRUPTED, ino, block, function, line); + va_start(args, fmt); if (ext4_error_ratelimit(sb)) { - va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: group %u, ", @@ -1007,8 +1021,9 @@ __acquires(bitlock) printk(KERN_CONT "block %llu:", (unsigned long long) block); printk(KERN_CONT "%pV\n", &vaf); - va_end(args); } + notify_sb_error(sb, function, line, EFSCORRUPTED, ino, block, fmt, &args); + va_end(args); if (test_opt(sb, WARN_ON_ERROR)) WARN_ON_ONCE(1); -- 2.29.2