]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Rename x_name to x_name_and_value
authorAlan Huang <mmpgouride@gmail.com>
Thu, 1 May 2025 20:01:32 +0000 (04:01 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:14:39 +0000 (20:14 -0400)
The flexible array contains name and value, the x_name is misleading.

Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/xattr.c
fs/bcachefs/xattr.h
fs/bcachefs/xattr_format.h

index 423ace6272bef03d35438c0014463bbf9d36b880..6b64cec78fb91f161b63e8df8f5cd6ad9280d141 100644 (file)
@@ -38,7 +38,7 @@ static u64 xattr_hash_bkey(const struct bch_hash_info *info, struct bkey_s_c k)
        struct bkey_s_c_xattr x = bkey_s_c_to_xattr(k);
 
        return bch2_xattr_hash(info,
-                &X_SEARCH(x.v->x_type, x.v->x_name, x.v->x_name_len));
+                &X_SEARCH(x.v->x_type, x.v->x_name_and_value, x.v->x_name_len));
 }
 
 static bool xattr_cmp_key(struct bkey_s_c _l, const void *_r)
@@ -48,7 +48,7 @@ static bool xattr_cmp_key(struct bkey_s_c _l, const void *_r)
 
        return l.v->x_type != r->type ||
                l.v->x_name_len != r->name.len ||
-               memcmp(l.v->x_name, r->name.name, r->name.len);
+               memcmp(l.v->x_name_and_value, r->name.name, r->name.len);
 }
 
 static bool xattr_cmp_bkey(struct bkey_s_c _l, struct bkey_s_c _r)
@@ -58,7 +58,7 @@ static bool xattr_cmp_bkey(struct bkey_s_c _l, struct bkey_s_c _r)
 
        return l.v->x_type != r.v->x_type ||
                l.v->x_name_len != r.v->x_name_len ||
-               memcmp(l.v->x_name, r.v->x_name, r.v->x_name_len);
+               memcmp(l.v->x_name_and_value, r.v->x_name_and_value, r.v->x_name_len);
 }
 
 const struct bch_hash_desc bch2_xattr_hash_desc = {
@@ -96,7 +96,7 @@ int bch2_xattr_validate(struct bch_fs *c, struct bkey_s_c k,
                         c, xattr_invalid_type,
                         "invalid type (%u)", xattr.v->x_type);
 
-       bkey_fsck_err_on(memchr(xattr.v->x_name, '\0', xattr.v->x_name_len),
+       bkey_fsck_err_on(memchr(xattr.v->x_name_and_value, '\0', xattr.v->x_name_len),
                         c, xattr_name_invalid_chars,
                         "xattr name has invalid characters");
 fsck_err:
@@ -120,13 +120,13 @@ void bch2_xattr_to_text(struct printbuf *out, struct bch_fs *c,
        unsigned name_len = xattr.v->x_name_len;
        unsigned val_len  = le16_to_cpu(xattr.v->x_val_len);
        unsigned max_name_val_bytes = bkey_val_bytes(xattr.k) -
-               offsetof(struct bch_xattr, x_name);
+               offsetof(struct bch_xattr, x_name_and_value);
 
        val_len  = min_t(int, val_len, max_name_val_bytes - name_len);
        name_len = min(name_len, max_name_val_bytes);
 
        prt_printf(out, "%.*s:%.*s",
-                  name_len, xattr.v->x_name,
+                  name_len, xattr.v->x_name_and_value,
                   val_len,  (char *) xattr_val(xattr.v));
 
        if (xattr.v->x_type == KEY_TYPE_XATTR_INDEX_POSIX_ACL_ACCESS ||
@@ -202,7 +202,7 @@ int bch2_xattr_set(struct btree_trans *trans, subvol_inum inum,
                xattr->v.x_type         = type;
                xattr->v.x_name_len     = namelen;
                xattr->v.x_val_len      = cpu_to_le16(size);
-               memcpy(xattr->v.x_name, name, namelen);
+               memcpy(xattr->v.x_name_and_value, name, namelen);
                memcpy(xattr_val(&xattr->v), value, size);
 
                ret = bch2_hash_set(trans, bch2_xattr_hash_desc, hash_info,
@@ -270,7 +270,7 @@ static int bch2_xattr_emit(struct dentry *dentry,
        if (!prefix)
                return 0;
 
-       return __bch2_xattr_emit(prefix, xattr->x_name, xattr->x_name_len, buf);
+       return __bch2_xattr_emit(prefix, xattr->x_name_and_value, xattr->x_name_len, buf);
 }
 
 static int bch2_xattr_list_bcachefs(struct bch_fs *c,
index 132fbbd15a66d06ba4a76d1a292b72073acfe88f..1139bf345f709358735d3a20fdb73412254f177c 100644 (file)
@@ -18,12 +18,12 @@ void bch2_xattr_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 static inline unsigned xattr_val_u64s(unsigned name_len, unsigned val_len)
 {
-       return DIV_ROUND_UP(offsetof(struct bch_xattr, x_name) +
+       return DIV_ROUND_UP(offsetof(struct bch_xattr, x_name_and_value) +
                            name_len + val_len, sizeof(u64));
 }
 
 #define xattr_val(_xattr)                                      \
-       ((void *) (_xattr)->x_name + (_xattr)->x_name_len)
+       ((void *) (_xattr)->x_name_and_value + (_xattr)->x_name_len)
 
 struct xattr_search_key {
        u8              type;
index 67426e33d04e56b56bce9eeea9db1df837c6e343..4121b78d9a92a586360acdc7a74ba93e0a8ce5b5 100644 (file)
@@ -16,10 +16,10 @@ struct bch_xattr {
        /*
         * x_name contains the name and value counted by
         * x_name_len + x_val_len. The introduction of
-        * __counted_by(x_name_len) caused a false positive
+        * __counted_by(x_name_len) previously caused a false positive
         * detection of an out of bounds write.
         */
-       __u8                    x_name[];
+       __u8                    x_name_and_value[];
 } __packed __aligned(8);
 
 #endif /* _BCACHEFS_XATTR_FORMAT_H */