linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: dhowells@redhat.com, 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,
	kernel@collabora.com
Subject: Re: [PATCH 5/8] vfs: Include origin of the SB error notification
Date: Mon, 07 Dec 2020 21:55:08 -0300	[thread overview]
Message-ID: <87zh2p5d77.fsf@collabora.com> (raw)
In-Reply-To: <20201208005110.GA106255@magnolia> (Darrick J. Wong's message of "Mon, 7 Dec 2020 16:51:10 -0800")

"Darrick J. Wong" <darrick.wong@oracle.com> writes:

> On Mon, Dec 07, 2020 at 09:31:14PM -0300, Gabriel Krisman Bertazi wrote:
>> When reporting a filesystem error, we really need to know where the
>> error came from, therefore, include "function:line" information in the
>> notification sent to userspace.  There is no current users of notify_sb
>> in the kernel, so there are no callers to update.
>> 
>> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
>> ---
>>  include/linux/fs.h               | 11 +++++++++--
>>  include/uapi/linux/watch_queue.h |  3 +++
>>  2 files changed, 12 insertions(+), 2 deletions(-)
>> 
>> diff --git a/include/linux/fs.h b/include/linux/fs.h
>> index df588edc0a34..864d86fcc68c 100644
>> --- a/include/linux/fs.h
>> +++ b/include/linux/fs.h
>> @@ -3514,14 +3514,17 @@ static inline void notify_sb(struct super_block *s,
>>  /**
>>   * notify_sb_error: Post superblock error notification.
>>   * @s: The superblock the notification is about.
>> + * @function: function name reported as source of the warning.
>> + * @line: source code line reported as source of the warning.
>>   * @error: The error number to be recorded.
>>   * @inode: The inode the error refers to (if available, 0 otherwise)
>>   * @block: The block the error refers to (if available, 0 otherwise)
>>   * @fmt: Formating string for extra information appended to the notification
>>   * @args: arguments for extra information string appended to the notification
>>   */
>> -static inline int notify_sb_error(struct super_block *s, int error,  u64 inode,
>> -				  u64 block, const char *fmt, va_list *args)
>> +static inline int notify_sb_error(struct super_block *s, const char *function, int line,
>> +				  int error, u64 inode, u64 block,
>> +				  const char *fmt, va_list *args)
>>  {
>>  #ifdef CONFIG_SB_NOTIFICATIONS
>>  	if (unlikely(s->s_watchers)) {
>> @@ -3534,8 +3537,12 @@ static inline int notify_sb_error(struct super_block *s, int error,  u64 inode,
>>  			.error_cookie	= 0,
>>  			.inode		= inode,
>>  			.block		= block,
>> +			.line		= line,
>>  		};
>>  
>> +		memcpy(&n.function, function, SB_NOTIFICATION_FNAME_LEN);
>> +		n.function[SB_NOTIFICATION_FNAME_LEN-1] = '\0';
>> +
>>  		post_sb_notification(s, &n.s, fmt, args);
>>  	}
>>  #endif
>> diff --git a/include/uapi/linux/watch_queue.h b/include/uapi/linux/watch_queue.h
>> index 937363d9f7b3..5fa5286c5cc7 100644
>> --- a/include/uapi/linux/watch_queue.h
>> +++ b/include/uapi/linux/watch_queue.h
>> @@ -114,6 +114,7 @@ enum superblock_notification_type {
>>  
>>  #define NOTIFY_SUPERBLOCK_IS_NOW_RO	WATCH_INFO_FLAG_0 /* Superblock changed to R/O */
>>  
>> +#define SB_NOTIFICATION_FNAME_LEN 30
>>  /*
>>   * Superblock notification record.
>>   * - watch.type = WATCH_TYPE_MOUNT_NOTIFY
>> @@ -130,6 +131,8 @@ struct superblock_error_notification {
>>  	__u32	error_cookie;
>>  	__u64	inode;
>>  	__u64	block;
>> +	char	function[SB_NOTIFICATION_FNAME_LEN];
>> +	__u16	line;
>
> Er... this is enlarging a structure in the userspace ABI, right?  Which
> will break userspace that latched on to the structure definition in the
> previous patch, and therefore isn't expecting a function name here.

Hi Darrick,

Since the structure is defined in the patch immediately before, I
thought it would be ok to split the patch to preserve authorship of the
different parts.  I will fold this into patch 4 in the next iteration.

>
> If you're gonna put a character string(?) at the end then I guess you
> have to pre-pad the notification structure so that we can add things
> later, or.... bump the type code every time you add a field?
>
> (Maybe I misread that?  But this is include/uapi/...)
>
> --D
>
>>  	char	desc[0];
>>  };
>>  
>> -- 
>> 2.29.2
>> 

-- 
Gabriel Krisman Bertazi

  reply	other threads:[~2020-12-08  0:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08  0:31 [PATCH 0/8] Superblock Notifications Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 1/8] watch_queue: Make watch_sizeof() check record size Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 2/8] security: Add hooks to rule on setting a watch for superblock Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 3/8] watch_queue: Support a text field at the end of the notification Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 4/8] vfs: Add superblock notifications Gabriel Krisman Bertazi
2020-12-08  0:56   ` Darrick J. Wong
2020-12-10 22:09   ` Dave Chinner
2020-12-11 20:55     ` Gabriel Krisman Bertazi
2020-12-18  1:06       ` Dave Chinner
2021-01-05 19:52         ` Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 5/8] vfs: Include origin of the SB error notification Gabriel Krisman Bertazi
2020-12-08  0:51   ` Darrick J. Wong
2020-12-08  0:55     ` Gabriel Krisman Bertazi [this message]
2020-12-08 12:42     ` David Howells
2020-12-08  0:31 ` [PATCH 6/8] fs: Add more superblock error subtypes Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 7/8] ext4: Implement SB error notification through watch_sb Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 8/8] samples: watch_queue: Add sample of SB notifications Gabriel Krisman Bertazi
2020-12-08 12:51 ` [PATCH 5/8] vfs: Include origin of the SB error notification David Howells
2020-12-08 12:58   ` Gabriel Krisman Bertazi
2020-12-08 18:41     ` Darrick J. Wong
2020-12-08 19:29       ` Gabriel Krisman Bertazi
2020-12-09  3:24         ` Darrick J. Wong
2020-12-09 13:06           ` Gabriel Krisman Bertazi
2020-12-11 22:35             ` Darrick J. Wong
2020-12-08 12:57 ` [PATCH 3/8] watch_queue: Support a text field at the end of the notification David Howells
2020-12-08 12:59 ` [PATCH 0/8] Superblock Notifications David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zh2p5d77.fsf@collabora.com \
    --to=krisman@collabora.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=darrick.wong@oracle.com \
    --cc=dhowells@redhat.com \
    --cc=kernel@collabora.com \
    --cc=khazhy@google.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).