From: Josef Bacik <josef@redhat.com>
To: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Cc: Josef Bacik <josef@redhat.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix regression in re-setting a large xattr
Date: Fri, 14 Oct 2011 08:55:52 -0400 [thread overview]
Message-ID: <20111014125551.GA2343@localhost.localdomain> (raw)
In-Reply-To: <4E977C8C.9000809@jp.fujitsu.com>
On Fri, Oct 14, 2011 at 09:04:28AM +0900, Tsutomu Itoh wrote:
> (2011/10/14 2:11), Josef Bacik wrote:
> > Recently I changed the xattr stuff to unconditionally set the xattr first in
> > case the xattr didn't exist yet. This has introduced a regression when setting
> > an xattr that already exists with a large value. If we find the key we are
> > looking for split_leaf will assume that we're extending that item. The problem
> > is the size we pass down to btrfs_search_slot includes the size of the item
> > already, so if we have the largest xattr we can possibly have plus the size of
> > the xattr item plus the xattr item that btrfs_search_slot we'd overflow the
> > leaf. Thankfully this is not what we're doing, but split_leaf doesn't know this
> > so it just returns EOVERFLOW. So in the xattr code we need to check and see if
> > we got back EOVERFLOW and treat it like EEXIST since that's really what
> > happened. Thanks,
> >
> > Signed-off-by: Josef Bacik <josef@redhat.com>
> > ---
> > fs/btrfs/xattr.c | 13 ++++++++++++-
> > 1 files changed, 12 insertions(+), 1 deletions(-)
> >
> > diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
> > index 69565e5..5bd7877 100644
> > --- a/fs/btrfs/xattr.c
> > +++ b/fs/btrfs/xattr.c
> > @@ -127,7 +127,18 @@ static int do_setxattr(struct btrfs_trans_handle *trans,
> > again:
> > ret = btrfs_insert_xattr_item(trans, root, path, btrfs_ino(inode),
> > name, name_len, value, size);
> > - if (ret == -EEXIST) {
> > + /*
> > + * If we're setting an xattr to a new value but the new value is say
> > + * exactly BTRFS_MAX_XATTR_SIZE, we could end up with EOVERFLOW getting
> > + * back from split_leaf. This is because it thinks we'll be extending
> > + * the existing item size, but we're asking for enough space to add the
> > + * item itself. So if we get EOVERFLOW just set ret to EEXIST and let
> > + * the rest of the function figure it out.
> > + */
> > + if (ret == -EOVERFLOW)
> > + ret = -EEXIST;
> > +
> > + if (ret == -EEXIST || ret == -EOVERFLOW) {
>
> Why tested again EOVERFLOW?
>
Oops thats my fault, I had thought to check for eoverflow but then thought
better to just set it to eexist and didn't fix the first thought. I'll send out
a fix. Thanks,
Josef
prev parent reply other threads:[~2011-10-14 12:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-13 17:11 [PATCH] Btrfs: fix regression in re-setting a large xattr Josef Bacik
2011-10-14 0:04 ` Tsutomu Itoh
2011-10-14 12:55 ` Josef Bacik [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=20111014125551.GA2343@localhost.localdomain \
--to=josef@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=t-itoh@jp.fujitsu.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