@@ -3721,10 +3721,14 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
37213721}
37223722
37233723/*
3724- * very simple check to peek ahead in the leaf looking for xattrs. If we
3725- * don't find any xattrs, we know there can't be any acls .
3724+ * Look ahead in the leaf for xattrs. If we don't find any then we know there
3725+ * can't be any ACLs .
37263726 *
3727- * slot is the slot the inode is in, objectid is the objectid of the inode
3727+ * @leaf: the eb leaf where to search
3728+ * @slot: the slot the inode is in
3729+ * @objectid: the objectid of the inode
3730+ *
3731+ * Return true if there is xattr/ACL, false otherwise.
37283732 */
37293733static noinline bool acls_after_inode_item (struct extent_buffer * leaf ,
37303734 int slot , u64 objectid ,
@@ -3748,11 +3752,11 @@ static noinline bool acls_after_inode_item(struct extent_buffer *leaf,
37483752 while (slot < nritems ) {
37493753 btrfs_item_key_to_cpu (leaf , & found_key , slot );
37503754
3751- /* we found a different objectid, there must not be acls */
3755+ /* We found a different objectid, there must be no ACLs. */
37523756 if (found_key .objectid != objectid )
37533757 return false;
37543758
3755- /* we found an xattr, assume we've got an acl */
3759+ /* We found an xattr, assume we've got an ACL. */
37563760 if (found_key .type == BTRFS_XATTR_ITEM_KEY ) {
37573761 if (* first_xattr_slot == -1 )
37583762 * first_xattr_slot = slot ;
@@ -3762,8 +3766,8 @@ static noinline bool acls_after_inode_item(struct extent_buffer *leaf,
37623766 }
37633767
37643768 /*
3765- * we found a key greater than an xattr key, there can't
3766- * be any acls later on
3769+ * We found a key greater than an xattr key, there can't be any
3770+ * ACLs later on.
37673771 */
37683772 if (found_key .type > BTRFS_XATTR_ITEM_KEY )
37693773 return false;
@@ -3772,17 +3776,22 @@ static noinline bool acls_after_inode_item(struct extent_buffer *leaf,
37723776 scanned ++ ;
37733777
37743778 /*
3775- * it goes inode, inode backrefs, xattrs, extents,
3776- * so if there are a ton of hard links to an inode there can
3777- * be a lot of backrefs. Don't waste time searching too hard,
3778- * this is just an optimization
3779+ * The item order goes like:
3780+ * - inode
3781+ * - inode backrefs
3782+ * - xattrs
3783+ * - extents,
3784+ *
3785+ * so if there are lots of hard links to an inode there can be
3786+ * a lot of backrefs. Don't waste time searching too hard,
3787+ * this is just an optimization.
37793788 */
37803789 if (scanned >= 8 )
37813790 break ;
37823791 }
3783- /* we hit the end of the leaf before we found an xattr or
3784- * something larger than an xattr. We have to assume the inode
3785- * has acls
3792+ /*
3793+ * We hit the end of the leaf before we found an xattr or something
3794+ * larger than an xattr. We have to assume the inode has ACLs.
37863795 */
37873796 if (* first_xattr_slot == -1 )
37883797 * first_xattr_slot = slot ;
0 commit comments