From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH 08/10] xfs: set failaddr into vc for checksum failures
Date: Fri, 7 Dec 2018 08:37:47 -0500 [thread overview]
Message-ID: <20181207133747.GC55482@bfoster> (raw)
In-Reply-To: <d380b0b8-b88f-fc96-8515-c5bd97918317@redhat.com>
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?
Brian
> /*
> * Null values for the types.
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index edbd5a210df2..4141e70bb3fa 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -131,13 +131,6 @@ typedef __u32 xfs_nlink_t;
> #define SYNCHRONIZE() barrier()
> #define __return_address __builtin_return_address(0)
>
> -/*
> - * 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; })
> -
> #define XFS_PROJID_DEFAULT 0
>
> #define howmany(x, y) (((x)+((y)-1))/(y))
> --
> 2.17.0
>
>
next prev parent reply other threads:[~2018-12-07 13:37 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 [this message]
2018-12-10 16:00 ` Eric Sandeen
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=20181207133747.GC55482@bfoster \
--to=bfoster@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/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