From: David Disseldorp <ddiss@suse.de>
To: "Luís Henriques" <lhenriques@suse.de>
Cc: fstests@vger.kernel.org, Dave Chinner <david@fromorbit.com>,
"Darrick J. Wong" <djwong@kernel.org>,
Jeff Layton <jlayton@kernel.org>, Xiubo Li <xiubli@redhat.com>,
ceph-devel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] generic/020: adjust max_attrval_size for ceph
Date: Fri, 10 Jun 2022 00:00:02 +0200 [thread overview]
Message-ID: <20220610000002.45aa2cb5@suse.de> (raw)
In-Reply-To: <87h74t51m0.fsf@brahms.olymp>
On Thu, 09 Jun 2022 15:54:15 +0100, Luís Henriques wrote:
> David Disseldorp <ddiss@suse.de> writes:
...
> > I take it a more exact calculation would be something like:
> > (64K - $max_attrval_namelen - sizeof(user.snrub="fish2\012"))?
> >
> > Perhaps you could calculate this on the fly for CephFS by passing in the
> > filename and subtracting the `getfattr -d $filename` results... That
> > said, it'd probably get a bit ugly, expecially if encoding needs to be
> > taken into account.
>
> In fact, this is *exactly* what I had before Dave suggested to keep it
> simple.
Arg, sorry I missed your previous round.
> After moving the code back into common/attr, where's how the
> generic code would look like:
>
> + ceph)
> + # CephFS does have a limit for the whole set of names+values
> + # attributes in a file. Thus, it is necessary to get the sizes
> + # of all names and values already existent and subtract them to
> + # the (default) maximum, which is 64k.
> + local len=0
> + while read line; do
> + # skip 1st line
> + [ "$line" != "${line#'#'}" ] && continue
> + n=$(echo $line | awk -F"=0x" '{print $1}')
> + v=$(echo $line | awk -F"=0x" '{print $2}')
> + nlen=${#n}
> + vlen=${#v}
> + # total is the sum of the name len and the value len
> + # divided by 2 because we're dumping them in hex format
> + t=$(($nlen + $vlen / 2))
> + len=$(($len + $t))
> + done <<< $(_getfattr -d -e hex $file 2> /dev/null)
> + echo $((65536 - $max_attrval_namelen - $len))
> + ;;
>
> so... yeah, I'm not particularly gifted on shell, it could probably be
> done in more clever/cleaner ways. Anyway, I'm open to revisit this if
> this is the preferred solution.
hmm, I was hoping something like...
(( 65536 - $max_attrval_namelen - $(getfattr -d $file | _filter | wc -c) ))
would be possible, but getfattr output does make it a bit too messy.
Cheers, David
next prev parent reply other threads:[~2022-06-09 22:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 10:53 [PATCH v2 0/2] Two xattrs-related fixes for ceph Luís Henriques
2022-06-09 10:53 ` [PATCH v2 1/2] generic/020: adjust max_attrval_size " Luís Henriques
2022-06-09 14:21 ` David Disseldorp
2022-06-09 14:54 ` Luís Henriques
2022-06-09 22:00 ` David Disseldorp [this message]
2022-06-10 13:01 ` Luis Henriques
2022-06-10 0:47 ` Xiubo Li
2022-06-10 13:06 ` Luis Henriques
2022-06-09 10:53 ` [PATCH v2 2/2] generic/486: adjust the max xattr size Luís Henriques
2022-06-10 5:35 ` Xiubo Li
2022-06-10 7:25 ` Dave Chinner
2022-06-10 9:19 ` Zorro Lang
2022-06-10 13:08 ` Luís Henriques
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=20220610000002.45aa2cb5@suse.de \
--to=ddiss@suse.de \
--cc=ceph-devel@vger.kernel.org \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=jlayton@kernel.org \
--cc=lhenriques@suse.de \
--cc=xiubli@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