From: Eric Sandeen <sandeen@redhat.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH 08/10] xfs: set failaddr into vc for checksum failures
Date: Mon, 10 Dec 2018 10:00:08 -0600 [thread overview]
Message-ID: <590579dd-f483-1ca2-eca8-e11e4a265f2b@redhat.com> (raw)
In-Reply-To: <20181207133747.GC55482@bfoster>
On 12/7/18 7:37 AM, Brian Foster wrote:
> On Wed, Dec 05, 2018 at 03:09:48PM -0600, Eric Sandeen wrote:
>> Modify CRC checking functions to set __this_address into the
>> verifier context failaddr vc->fa using new macro XFS_BADCRC_RETURN,
>> and pass that to failure handlers as well.
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>> fs/xfs/libxfs/xfs_alloc.c | 4 ++--
>> fs/xfs/libxfs/xfs_alloc_btree.c | 2 +-
>> fs/xfs/libxfs/xfs_attr_leaf.c | 2 +-
>> fs/xfs/libxfs/xfs_bmap_btree.c | 2 +-
>> fs/xfs/libxfs/xfs_cksum.h | 5 ++++-
>> fs/xfs/libxfs/xfs_da_btree.c | 3 +--
>> fs/xfs/libxfs/xfs_dir2_block.c | 2 +-
>> fs/xfs/libxfs/xfs_dir2_data.c | 2 +-
>> fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +-
>> fs/xfs/libxfs/xfs_dir2_node.c | 2 +-
>> fs/xfs/libxfs/xfs_ialloc.c | 2 +-
>> fs/xfs/libxfs/xfs_ialloc_btree.c | 2 +-
>> fs/xfs/libxfs/xfs_refcount_btree.c | 2 +-
>> fs/xfs/libxfs/xfs_rmap_btree.c | 2 +-
>> fs/xfs/libxfs/xfs_symlink_remote.c | 2 +-
>> fs/xfs/libxfs/xfs_types.h | 12 ++++++++++--
>> fs/xfs/xfs_linux.h | 7 -------
>> 17 files changed, 29 insertions(+), 26 deletions(-)
>>
> ...
>> diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
>> index 29b0d354d9b7..ab045e8dfcb9 100644
>> --- a/fs/xfs/libxfs/xfs_types.h
>> +++ b/fs/xfs/libxfs/xfs_types.h
>> @@ -45,8 +45,16 @@ struct xfs_vc {
>> xfs_failaddr_t fa;
>> };
>>
>> -#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; false;})
>> -#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; true;})
>> +/*
>> + * Return the address of a label. Use barrier() so that the optimizer
>> + * won't reorder code to refactor the error jumpouts into a single
>> + * return, which throws off the reported address.
>> + */
>> +#define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
>> +
>
> FYI, minor whitespace damage on the line above.
>
>> +#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; false;})
>> +#define XFS_BADCRC_RETURN(vc) ({(vc)->fa = __this_address; false;})
>> +#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; true;})
>>
>
> A couple high level comments..
>
> I don't particularly care that much whether we bury function returns in
> the macro or open-code it, but the macro naming suggests the former
> (based on precedent of other such macros in XFS) while we implement the
> latter. If there's objection to a return within a macro, perhaps a
> reasonable compromise between this and the common pattern of having to
> return on a separate line is to tweak the macros to never clobber an
> existing error and update the verifiers to check/return failure state at
> opportune points. For example:
>
> ...
> if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
> XFS_VC_CORRUPT(vc);
> if (be32_to_cpu(agfl->agfl_magicnum) != XFS_AGFL_MAGIC)
> XFS_VC_CORRUPT(vc);
> if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != bp->b_pag->pag_agno)
> XFS_VC_CORRUPT(vc);
> ...
>
> return vc->fa ? false : true;
>
> Of course, that assumes it's safe to keep checking the structure(s) as
> such in the event of corruption, which perhaps is not ideal. Anyways, we
> could also just return on a separate line or rename the macros. Just
> thinking out loud a bit.
>
> I'm also a little curious why we have the need for the success macro at
> all. I've only made a cursory pass at this point, but is there a
> particular need to set anything in the xfs_vc at the point of a
> successful return as opposed to just leaving the structure in the
> initialized state?
yeah, it's probably not necessary; it seemed consistent tho. There is some
risk to this whole framework that failing to initialize a vc would cause
problems that might be difficult to debug, and always marking success
upon success seemed "safe." But you're right, not not necessary if it's
properly initialized to success at the top of the call chain.
-Eric
next prev parent reply other threads:[~2018-12-10 16:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
2018-12-05 21:02 ` [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool Eric Sandeen
2018-12-07 13:36 ` Brian Foster
2018-12-17 18:23 ` Darrick J. Wong
2018-12-05 21:03 ` [PATCH 02/10] xfs: make checksum verifiers consistently return bools Eric Sandeen
2018-12-07 13:36 ` Brian Foster
2018-12-17 18:24 ` Darrick J. Wong
2018-12-05 21:03 ` [PATCH 03/10] xfs: pass a verifier context down verifier callchains Eric Sandeen
2018-12-17 18:29 ` Darrick J. Wong
2018-12-05 21:04 ` [PATCH 04/10] xfs: pass a verifier context to crc validation functions Eric Sandeen
2018-12-05 21:05 ` [PATCH 05/10] xfs: define new macros to set verifier context on return Eric Sandeen
2018-12-05 21:06 ` [PATCH 06/10] xfs: teach xfs_btree_[sl]block_verify_crc to populate verifier context Eric Sandeen
2018-12-05 21:08 ` [PATCH 07/10] xfs: change all verifiers to return booleans Eric Sandeen
2018-12-05 21:09 ` [PATCH 08/10] xfs: set failaddr into vc for checksum failures Eric Sandeen
2018-12-07 13:37 ` Brian Foster
2018-12-10 16:00 ` Eric Sandeen [this message]
2018-12-17 18:39 ` Darrick J. Wong
2018-12-05 21:11 ` [PATCH 09/10] xfs: add errno to verifier context and populate it Eric Sandeen
2018-12-07 13:41 ` Brian Foster
2018-12-05 21:11 ` [PATCH 10/10] xfs: condense crc and verifier checks where possible Eric Sandeen
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=590579dd-f483-1ca2-eca8-e11e4a265f2b@redhat.com \
--to=sandeen@redhat.com \
--cc=bfoster@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/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