@@ -3728,10 +3728,14 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
37283728}
37293729
37303730/*
3731- * very simple check to peek ahead in the leaf looking for xattrs. If we
3732- * don't find any xattrs, we know there can't be any acls .
3731+ * Look ahead in the leaf for xattrs. If we don't find any then we know there
3732+ * can't be any ACLs .
37333733 *
3734- * slot is the slot the inode is in, objectid is the objectid of the inode
3734+ * @leaf: the eb leaf where to search
3735+ * @slot: the slot the inode is in
3736+ * @objectid: the objectid of the inode
3737+ *
3738+ * Return true if there is xattr/ACL, false otherwise.
37353739 */
37363740static noinline bool acls_after_inode_item (struct extent_buffer * leaf ,
37373741 int slot , u64 objectid ,
@@ -3755,11 +3759,11 @@ static noinline bool acls_after_inode_item(struct extent_buffer *leaf,
37553759 while (slot < nritems ) {
37563760 btrfs_item_key_to_cpu (leaf , & found_key , slot );
37573761
3758- /* we found a different objectid, there must not be acls */
3762+ /* We found a different objectid, there must be no ACLs. */
37593763 if (found_key .objectid != objectid )
37603764 return false;
37613765
3762- /* we found an xattr, assume we've got an acl */
3766+ /* We found an xattr, assume we've got an ACL. */
37633767 if (found_key .type == BTRFS_XATTR_ITEM_KEY ) {
37643768 if (* first_xattr_slot == -1 )
37653769 * first_xattr_slot = slot ;
@@ -3769,8 +3773,8 @@ static noinline bool acls_after_inode_item(struct extent_buffer *leaf,
37693773 }
37703774
37713775 /*
3772- * we found a key greater than an xattr key, there can't
3773- * be any acls later on
3776+ * We found a key greater than an xattr key, there can't be any
3777+ * ACLs later on.
37743778 */
37753779 if (found_key .type > BTRFS_XATTR_ITEM_KEY )
37763780 return false;
@@ -3779,17 +3783,22 @@ static noinline bool acls_after_inode_item(struct extent_buffer *leaf,
37793783 scanned ++ ;
37803784
37813785 /*
3782- * it goes inode, inode backrefs, xattrs, extents,
3783- * so if there are a ton of hard links to an inode there can
3784- * be a lot of backrefs. Don't waste time searching too hard,
3785- * this is just an optimization
3786+ * The item order goes like:
3787+ * - inode
3788+ * - inode backrefs
3789+ * - xattrs
3790+ * - extents,
3791+ *
3792+ * so if there are lots of hard links to an inode there can be
3793+ * a lot of backrefs. Don't waste time searching too hard,
3794+ * this is just an optimization.
37863795 */
37873796 if (scanned >= 8 )
37883797 break ;
37893798 }
3790- /* we hit the end of the leaf before we found an xattr or
3791- * something larger than an xattr. We have to assume the inode
3792- * has acls
3799+ /*
3800+ * We hit the end of the leaf before we found an xattr or something
3801+ * larger than an xattr. We have to assume the inode has ACLs.
37933802 */
37943803 if (* first_xattr_slot == -1 )
37953804 * first_xattr_slot = slot ;
0 commit comments