Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect sa_find_sizes() size #426

Closed
behlendorf opened this issue Oct 21, 2011 · 0 comments
Closed

Incorrect sa_find_sizes() size #426

behlendorf opened this issue Oct 21, 2011 · 0 comments
Milestone

Comments

@behlendorf
Copy link
Contributor

Reported by Marcin Miroslaw and fixed in FreeBSD. We just need to review this change and make sure it's right for Linux before merging it in.

When calculating space needed for SA_BONUS buffers, hdrsize is always rounded
up to next 8-aligned boundary. However, in two places the round up was done 
against sum of 'total' plus hdrsize. On the other hand, hdrsize increments by 4 each
time, which means in certain conditions, we would end up returning with 
will_spill == 0 and (total + hdrsize) larger than full_space, leading to a failed
assertion because it's invalid for dmu_set_bonus.

Fix by: Xin Li 
Sponsored by: iXsystems, Inc.
--- a/usr/src/uts/common/fs/zfs/sa.c    Fri Jul 22 09:27:57 2011 -0700
+++ b/usr/src/uts/common/fs/zfs/sa.c    Tue Oct 18 01:50:46 2011 +0200
@@ -605,14 +605,14 @@ sa_find_sizes(sa_os_t *sa, sa_bulk_attr_
          * and spill buffer.
          */
         if (buftype == SA_BONUS && *index == -1 &&
-            P2ROUNDUP(*total + hdrsize, 8) >
+            *total + P2ROUNDUP(hdrsize, 8) >
             (full_space - sizeof (blkptr_t))) {
             *index = i;
             done = B_TRUE;
         }

 next:
-        if (P2ROUNDUP(*total + hdrsize, 8) > full_space &&
+        if (*total + P2ROUNDUP(hdrsize, 8) > full_space &&
             buftype == SA_BONUS)
             *will_spill = B_TRUE;
     }
kernelOfTruth pushed a commit to kernelOfTruth/zfs that referenced this issue Mar 1, 2015
The kmem_vasprintf(), kmem_vsprintf(), kobj_open_file(), and vn_openat()
functions should all use the kmem_flags_convert() function to generate
the GFP_* flags.  This ensures that they can be safely called in any
context and the correct flags will be used.

Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs#426
sdimitro pushed a commit to sdimitro/zfs that referenced this issue May 23, 2022
The `OnDisk` trait doesn't serve any purpose.  e.g. it's never a
required trait bound.

This commit cleans up the code by removing the OnDisk trait.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant