From: David Sterba <dsterba@suse.cz>
To: Filipe Manana <fdmanana@kernel.org>
Cc: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: enhance compression error messages
Date: Thu, 9 May 2024 19:58:16 +0200 [thread overview]
Message-ID: <20240509175816.GP13977@twin.jikos.cz> (raw)
In-Reply-To: <CAL3q7H4UGXk8Oi7nA+SY585-K=HCT7MV-KrG0x46s020-5_pag@mail.gmail.com>
On Wed, May 08, 2024 at 05:17:27PM +0100, Filipe Manana wrote:
> On Fri, May 3, 2024 at 12:50 PM David Sterba <dsterba@suse.com> wrote:
> >
> > Add more verbose and specific messages to all main error points in
> > compression code for all algorithms. Currently there's no way to know
> > which inode is affected or where in the data errors happened.
> >
> > The messages follow a common format:
> >
> > - what happened
> > - error code if relevant
> > - root and inode
> > - additional data like offsets or lengths
> >
> > There's no helper for the messages as they differ in some details and
> > that would be cumbersome to generalize to a single function. As all the
> > errors are "almost never happens" there are the unlikely annotations
> > done as compression is hot path.
> >
> > Signed-off-by: David Sterba <dsterba@suse.com>
> > ---
> > fs/btrfs/lzo.c | 43 ++++++++++++++++++++---------
> > fs/btrfs/zlib.c | 60 ++++++++++++++++++++++++++++++----------
> > fs/btrfs/zstd.c | 73 +++++++++++++++++++++++++++++++++++++------------
> > 3 files changed, 131 insertions(+), 45 deletions(-)
> >
> > diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
> > index 1c396ac167aa..d2e8a9117d22 100644
> > --- a/fs/btrfs/lzo.c
> > +++ b/fs/btrfs/lzo.c
> > @@ -258,8 +258,8 @@ int lzo_compress_folios(struct list_head *ws, struct address_space *mapping,
> > workspace->cbuf, &out_len,
> > workspace->mem);
> > kunmap_local(data_in);
> > - if (ret < 0) {
> > - pr_debug("BTRFS: lzo in loop returned %d\n", ret);
> > + if (unlikely(ret < 0)) {
> > + /* lzo1x_1_compress never fails. */
> > ret = -EIO;
> > goto out;
> > }
> > @@ -354,11 +354,14 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
> > * and all sectors should be used.
> > * If this happens, it means the compressed extent is corrupted.
> > */
> > - if (len_in > min_t(size_t, BTRFS_MAX_COMPRESSED, cb->compressed_len) ||
> > - round_up(len_in, sectorsize) < cb->compressed_len) {
> > + if (unlikely(len_in > min_t(size_t, BTRFS_MAX_COMPRESSED, cb->compressed_len) ||
> > + round_up(len_in, sectorsize) < cb->compressed_len)) {
> > + struct btrfs_inode *inode = cb->bbio.inode;
> > +
> > btrfs_err(fs_info,
> > - "invalid lzo header, lzo len %u compressed len %u",
> > - len_in, cb->compressed_len);
> > +"lzo header invalid, root %llu inode %llu offset %llu lzo len %u compressed len %u",
> > + inode->root->root_key.objectid, btrfs_ino(inode),
>
> Now that we are using btrfs_root_id() everywhere after Josef's recent
> patch, please use btrfs_root_id(inode->root) everywhere in the patch
> for consistency (it's also shorter to type and the name is very
> clear).
I'll do that in v2 (as there's the problem with zlib that returns EIO),
thanks.
prev parent reply other threads:[~2024-05-09 17:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 11:42 [PATCH] btrfs: enhance compression error messages David Sterba
2024-05-08 16:17 ` Filipe Manana
2024-05-09 17:58 ` David Sterba [this message]
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=20240509175816.GP13977@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=dsterba@suse.com \
--cc=fdmanana@kernel.org \
--cc=linux-btrfs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).