Message ID | 171069246485.2684506.6805355726574585050.stgit@frogsfrogsfrogs (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [01/40] fsverity: remove hash page spin lock | expand |
On 2024-03-17 09:32:47, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@kernel.org> > > As a minor space optimization, don't store trailing zeroes of merkle > tree blocks to reduce space consumption and copying overhead. This > really only affects the rightmost blocks at each level of the tree. > > Signed-off-by: Darrick J. Wong <djwong@kernel.org> Looks good to me: Reviewed-by: Andrey Albershteyn <aalbersh@redhat.com> > --- > fs/xfs/xfs_verity.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > > diff --git a/fs/xfs/xfs_verity.c b/fs/xfs/xfs_verity.c > index 32891ae42c47..abd95bc1ba6e 100644 > --- a/fs/xfs/xfs_verity.c > +++ b/fs/xfs/xfs_verity.c > @@ -622,11 +622,6 @@ xfs_verity_read_merkle( > if (error) > goto out_new_mk; > > - if (!args.valuelen) { > - error = -ENODATA; > - goto out_new_mk; > - } > - > mk = xfs_verity_cache_store(ip, key, new_mk); > if (mk != new_mk) { > /* > @@ -681,6 +676,12 @@ xfs_verity_write_merkle( > .value = (void *)buf, > .valuelen = size, > }; > + const char *p = buf + size - 1; > + > + /* Don't store trailing zeroes. */ > + while (p >= (const char *)buf && *p == 0) > + p--; > + args.valuelen = p - (const char *)buf + 1; > > xfs_verity_merkle_key_to_disk(&name, pos); > return xfs_attr_set(&args); >
diff --git a/fs/xfs/xfs_verity.c b/fs/xfs/xfs_verity.c index 32891ae42c47..abd95bc1ba6e 100644 --- a/fs/xfs/xfs_verity.c +++ b/fs/xfs/xfs_verity.c @@ -622,11 +622,6 @@ xfs_verity_read_merkle( if (error) goto out_new_mk; - if (!args.valuelen) { - error = -ENODATA; - goto out_new_mk; - } - mk = xfs_verity_cache_store(ip, key, new_mk); if (mk != new_mk) { /* @@ -681,6 +676,12 @@ xfs_verity_write_merkle( .value = (void *)buf, .valuelen = size, }; + const char *p = buf + size - 1; + + /* Don't store trailing zeroes. */ + while (p >= (const char *)buf && *p == 0) + p--; + args.valuelen = p - (const char *)buf + 1; xfs_verity_merkle_key_to_disk(&name, pos); return xfs_attr_set(&args);