From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796166989; b=HmT5SbK43vOPe6P6EhqvxyCYCS0GTEM9t6J6x8uC+EkNWCFELkVKhY/XTEVAEeNyC8hj Vu6mW/lMrVrX9XR5UsmBskgOLBT9BcOH7SmIN5cxKBwEE1Wk/S3enYBNd4ldVd8/Br90Q t7DfNfBb2mDIRJ/LzXEzTkuzbSxXYRaruIhj2RBiH+WmgMTsO+j+okZ02RwoXKsrD8vzO X3/W9mBmqfnKrJw25H3+VaFGQWRXptCDnCcis4NvfQs8BAZPJmltS9nf61a5ACBKda1PP +WW+q47qk2nwr9yKmmzl1H76Lec3/hlsgkUaaOj7sGX7/aLcg18XW6IUoKq85Ww9ZNw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796166989; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References:Autocrypt: Content-Type:Content-Transfer-Encoding:User-Agent:MIME-Version; bh=MnsZcP4VJM8MCQ1mq2UD61m8pFvZ2uFGV68AJbGGYqQ=; b=SDXHhf0qnBM4n4DOOhVGHn4T1D8YDnwWdEn1b+uwzG7XUHPVXXZ1+qsAGexe3TF46wX8 inHFpT5w0tQ7ajRRkOGl41kJPZX16qJ05w2mlg22Ct5Bhp4ukJmOmwPrh2uuNmInQg7Rk Uqggw1HgZffNAXjf/q1CGr6ZbZ1snRbDaSNjc25KdJ7Iy3NxERAZPvFpcNmEme8ZTRVNP mpBCTBK5kHvgKnFYncdEjKfvNg9WCBIMUBB7K1hhIc6LWOZJ/5oLWfh2Qw6Z9K29KBRAY c2mghrJ4CSQ3aVOVcW7ncsroF4krou8swoDqhlBCiFWU8jXR1pl820+G/XLkWcbIilQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=dubeyko.com; spf=pass smtp.mailfrom=dubeyko.com; dkim=pass header.d=dubeyko-com.20260707.gappssmtp.com header.i=@dubeyko-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=Jt1leyzL; arc=none smtp.remote-ip=209.85.128.179 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C117606A322 for ; Tue, 1 Dec 2026 23:16:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4C117606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dubeyko.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dubeyko.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dubeyko-com.20260707.gappssmtp.com header.i=@dubeyko-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=Jt1leyzL Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-8b4e246acc2so91112697b3.3 for ; Tue, 01 Dec 2026 15:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20260707.gappssmtp.com; s=20260707; t=1796166987; x=1796771787; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :from:to:cc:subject:date:message-id:reply-to:content-type; bh=MnsZcP4VJM8MCQ1mq2UD61m8pFvZ2uFGV68AJbGGYqQ=; b=Jt1leyzLCMCwEQJmlE2/b7pNOaCfvZwgMTVHn2w2U2zrGGwUNycV3HYzWBmaI2LMyk OdPo1tjaVaJdmyz0mlUOoq8sw/7E1CclCjN4Tzm1wGDRmSLVob94mDFQImaK7SNDIOcG MrbL0WIgXALTDEjXvgBd5qYjKSH6OulF3MIi7DA2h6dZeYQkmMENe3w5edXOkf3dU85K GlvoOgkVfhA9wyC3eC7bLX5mBcu5Ll53nlmv/HzZsaHPh5Ow+1c3x+ziEFjAl666vats CJosxgA7u++179L1W5GvRWq+3PWC8Hyr63fieUTVi2uCmw7u0TcgncJYRoNCJ92KY+Xg m6Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796166987; x=1796771787; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=MnsZcP4VJM8MCQ1mq2UD61m8pFvZ2uFGV68AJbGGYqQ=; b=u0kbS5uRJEsveLr1XYxdag5qkyQHUlsA64T3SYrVPnEDuQiTKoyrRW9SV5O1FQts6X j3j36u7+u4m782Rhs0ZOzx662buMdXw/HPVG0iw66hb/Z1+xKv6DiCk9Ykej6HXXhSQ2 B2YfQFHjVoHI//X/N/+6LoJXMeqtxP0l0ZcuQJl4foq4INL7HjAUWvw6kc5plg9c5Ueo 5yzTNFoLtV4l8XV7NzJusMlm/j5Q5ZdgHSv9l4ICx6naT+bAicdmxz9dJBbX7LNzS7zJ lQEDNtAdOm57UOxhW0sZN4ki0MTkrMrsjH62Ox3mdYR8wXqoxuiQDAgS8wL1CTggN8O7 D8oQ== X-Forwarded-Encrypted: i=1; AL+hErExykEUFapr226Ghvj3H8yq/9DnxsJwqq7/2LiH6SwoHPlgXRkQ3pbHqCCfGxjS8CO3KxSGiQOux6YwBuI=@vger.kernel.org X-Gm-Message-State: APuU4Z9YovxWTkJOtq7nP/9oFY+QFaexdvRJXgmTzb4v2/JQiqVtSqkQ pZdO+ezEx1+FfL6TBb8HjGF+jesY6CKsYp0mxxaoXSu4jixwThjKqIZHMmmCiF9a6k8= X-Gm-Gg: AZFdTZf524/mc2dgeqtd5YESfBb1IxYp/LVm6oE4dYOf9qr07XafgZ9fTiTaIwr2WEg p+Q++H0pLmOPSCnLrXDxUzKnrch1/Z4h5tlvIO/CapVd+hlsqMHnezxS0Rt/OCzfAOPh+d0ie/Q 998Oy/KbIwIGAzbyWvmngJ62U5kne8SWd/uKfG6HhdU0j+I6Rx2Rq2Fh2Q4Y+tPvJiqzmuKvDwl t1i/cEAJGM90GNwr0RrW7M5jVIVOajJIxVDHEE533noNrPKFU9ktzyvEI6/WTHoh7eMIgs6BrZy 6y3A+w6XiJkR55+SxyCFoYw61/lck1ySjQ/4bS/wTPpSdqN2hVXwTHEkQyhZkjXShba9DH+TIaf R+FYyno+Lc9aMYKyiQeioSGXxgkhnXL0Kehzcr9s7pWZdRO40jIAyxdZVUH51hfL/43x4ES6dpZ krQqKGmWN9hy1G8yewUJawi41ZaBJbmw5BJLPObt5iOIZVcie/shxynxWPcgTYB2I4nEB1ZnMy1 eRV7b8cCZd7ryKH0K3oxxaA+CepKCyKxKb/zVzeyUUWFNDJkqXlQ2JUjXQewc2g3P+5T+4tjNbB 1UiT1Ajt9z82eIhLMIkTxgadQuxIew1McIQU3e0sAzWuRgdgJuWM7LA5xqHOhiujptgoF5jr/58 8HoHuuzA7cEnakNOLf0d4rWtmYPsDkVSWd1cklafeQEnF529JUjTXbbAlOjo220AWnrR9kp7r77 xG/Ut5sUIY5KQjubTziA== X-Received: by 2002:a05:690c:e1c8:10b0:8b5:2fa8:a678 with SMTP id 00721157ae682-8b52fa8a72amr109718467b3.14.1796166987252; Tue, 01 Dec 2026 15:16:27 -0800 (PST) Received: from ?IPv6:2600:1700:6476:1430:f726:86c4:c7ef:c27? ([2600:1700:6476:1430:f726:86c4:c7ef:c27]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b5202bf474sm149843567b3.21.2026.12.01.15.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 15:16:26 -0800 (PST) Message-ID: <7fc082eba40694435649186517018d7ea5b475a9.camel@dubeyko.com> Subject: Re: [PATCH v5 3/3] hfs/hfsplus: name the node descriptor size and the first record offset From: Viacheslav Dubeyko To: Ozgun Kultekin , glaubitz@physik.fu-berlin.de, frank.li@vivo.com Cc: linux-fsdevel@vger.kernel.org, yangguikun19@qq.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org, kovalev@altlinux.org, brauner@kernel.org, cengiz.can@canonical.com Date: Tue, 01 Dec 2026 15:16:25 -0800 In-Reply-To: <20261201094246.80197-4-ozgunkultekin@gmail.com> References: <20261127045416.1160-1-ozgunkultekin@gmail.com> <20261201094246.80197-1-ozgunkultekin@gmail.com> <20261201094246.80197-4-ozgunkultekin@gmail.com> Autocrypt: addr=slava@dubeyko.com; prefer-encrypt=mutual; keydata=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 NFdvziOa4FgUBC4X71upsZIoZJeii2V/Jtc3B4g== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-9 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Tue, 2026-12-01 at 01:42 -0800, Ozgun Kultekin wrote: > Both drivers spell the size of struct hfs_bnode_desc, which is also > the > offset of record 0 in a node, in several ways: the literal 14 in > brec.c > and btree.c, a local node_desc_size in hfs_bnode_split() of both > drivers, local desc_size variables in hfsplus_fs.h, and > sizeof(struct hfs_bnode_desc) in bnode.c, btree.c and > hfsplus/xattr.c. >=20 > Add two names next to the structure: HFS_BNODE_DESC_SIZE for the size > and HFS_BNODE_FIRST_REC_OFF for the offset of record 0, and use them > everywhere. In hfs_btree_inc_height() keep the offset of the child > pointer in a local variable and write its length as sizeof(cnid) > instead of 4. Align the conditions next to the changed lines. >=20 > No functional change. >=20 > Suggested-by: Viacheslav Dubeyko > Signed-off-by: Ozgun Kultekin > --- >=20 > Notes: > =C2=A0=C2=A0=C2=A0 v5: rebased on the hfs tree for-next branch; hfs_bnode= _split() in > hfs > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 now has the node_desc_size loc= al from "hfs: fix orphaned b- > tree > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 node in hfs_bnode_split()", co= nverted like the hfsplus one. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 map_node_bits in hfsplus/xattr= .c reordered to > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (node_size - ...) * 8, as sugg= ested by Viacheslav. > =C2=A0=C2=A0=C2=A0 v4: > https://lore.kernel.org/all/20261127045416.1160-4-ozgunkultekin@gmail.com= / > =C2=A0=C2=A0=C2=A0 v3: > https://lore.kernel.org/all/20261119005943.37851-2-ozgunkultekin@gmail.co= m/ >=20 > =C2=A0fs/hfs/bnode.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +- > =C2=A0fs/hfs/brec.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 | 47 ++++++++++++++++++-------------- > =C2=A0fs/hfs/btree.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 |=C2=A0 9 ++++--- > =C2=A0fs/hfsplus/bnode.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = |=C2=A0 2 +- > =C2=A0fs/hfsplus/brec.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 | 55 +++++++++++++++++++++--------------- > -- > =C2=A0fs/hfsplus/btree.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = |=C2=A0 9 ++++--- > =C2=A0fs/hfsplus/hfsplus_fs.h=C2=A0=C2=A0=C2=A0 |=C2=A0 8 +++--- > =C2=A0fs/hfsplus/xattr.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = |=C2=A0 8 +++--- > =C2=A0include/linux/hfs_common.h |=C2=A0 6 +++++ > =C2=A09 files changed, 83 insertions(+), 63 deletions(-) >=20 > diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c > index f2781afea7..f976e4092a 100644 > --- a/fs/hfs/bnode.c > +++ b/fs/hfs/bnode.c > @@ -429,7 +429,7 @@ struct hfs_bnode *hfs_bnode_find(struct hfs_btree > *tree, u32 num) > =C2=A0 > =C2=A0 rec_off =3D tree->node_size - 2; > =C2=A0 off =3D hfs_bnode_read_u16(node, rec_off); > - if (off !=3D sizeof(struct hfs_bnode_desc)) > + if (off !=3D HFS_BNODE_FIRST_REC_OFF) > =C2=A0 goto node_error; > =C2=A0 for (i =3D 1; i <=3D node->num_recs; off =3D next_off, i++) { > =C2=A0 rec_off -=3D 2; > diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c > index 15520b2b15..d6ba3722ec 100644 > --- a/fs/hfs/brec.c > +++ b/fs/hfs/brec.c > @@ -157,8 +157,8 @@ int hfs_brec_insert(struct hfs_find_data *fd, > void *entry, u32 entry_len) > =C2=A0 entry_len =3D sizeof(cnid); > =C2=A0 > =C2=A0 /* get index key */ > - hfs_bnode_read_key(new_node, fd->search_key, 14, > - =C2=A0=C2=A0 fd->key_capacity); > + hfs_bnode_read_key(new_node, fd->search_key, > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, fd- > >key_capacity); > =C2=A0 __hfs_brec_find(fd->bnode, fd); > =C2=A0 > =C2=A0 hfs_bnode_put(new_node); > @@ -257,7 +257,6 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd) > =C2=A0 int num_recs, new_rec_off, new_off, old_rec_off; > =C2=A0 int data_start, data_end, size; > =C2=A0 size_t rec_off_tbl_size; > - size_t node_desc_size =3D sizeof(struct hfs_bnode_desc); > =C2=A0 size_t rec_size =3D sizeof(__be16); > =C2=A0 > =C2=A0 tree =3D fd->tree; > @@ -287,7 +286,7 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd) > =C2=A0 > =C2=A0 rec_off_tbl_size =3D node->num_recs * rec_size; > =C2=A0 size =3D tree->node_size / 2; > - size -=3D node_desc_size; > + size -=3D HFS_BNODE_DESC_SIZE; > =C2=A0 size -=3D rec_off_tbl_size; > =C2=A0 old_rec_off =3D tree->node_size - (2 * rec_size); > =C2=A0 > @@ -319,14 +318,14 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd) > =C2=A0 hfs_bnode_get(new_node); > =C2=A0 fd->bnode =3D new_node; > =C2=A0 fd->record -=3D num_recs; > - fd->keyoffset -=3D data_start - node_desc_size; > - fd->entryoffset -=3D data_start - node_desc_size; > + fd->keyoffset -=3D data_start - > HFS_BNODE_FIRST_REC_OFF; > + fd->entryoffset -=3D data_start - > HFS_BNODE_FIRST_REC_OFF; > =C2=A0 } > =C2=A0 new_node->num_recs =3D node->num_recs - num_recs; > =C2=A0 node->num_recs =3D num_recs; > =C2=A0 > =C2=A0 new_rec_off =3D tree->node_size - rec_size; > - new_off =3D node_desc_size; > + new_off =3D HFS_BNODE_FIRST_REC_OFF; > =C2=A0 size =3D data_start - new_off; > =C2=A0 num_recs =3D new_node->num_recs; > =C2=A0 data_end =3D data_start; > @@ -339,8 +338,8 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd) > =C2=A0 num_recs--; > =C2=A0 } > =C2=A0 hfs_bnode_write_u16(new_node, new_rec_off, new_off); > - hfs_bnode_copy(new_node, node_desc_size, > - node, data_start, data_end - data_start); > + hfs_bnode_copy(new_node, HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 node, data_start, data_end - data= _start); > =C2=A0 > =C2=A0 /* update new bnode header */ > =C2=A0 node_desc.next =3D cpu_to_be32(new_node->next); > @@ -404,7 +403,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 > =C2=A0 /* size difference between old and new key */ > =C2=A0 if (tree->attributes & HFS_TREE_VARIDXKEYS) > - newkeylen =3D (hfs_bnode_read_u8(node, 14) | 1) + 1; > + newkeylen =3D > + (hfs_bnode_read_u8(node, > HFS_BNODE_FIRST_REC_OFF) | 1) + 1; > =C2=A0 else > =C2=A0 fd->keylength =3D newkeylen =3D tree->max_key_len + 1; We need to use key_capacity here. Am I right? Please, rework it. > =C2=A0 hfs_dbg("rec %d, keylength %d, newkeylen %d\n", > @@ -443,7 +443,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 hfs_bnode_move(parent, start_off + diff, start_off, > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end_off - start_off); > =C2=A0skip: > - hfs_bnode_copy(parent, fd->keyoffset, node, 14, newkeylen); > + hfs_bnode_copy(parent, fd->keyoffset, node, > HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newkeylen); > =C2=A0 if (!(tree->attributes & HFS_TREE_VARIDXKEYS)) > =C2=A0 hfs_bnode_write_u8(parent, fd->keyoffset, newkeylen > - 1); > =C2=A0 hfs_bnode_dump(parent); > @@ -460,8 +461,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 } > =C2=A0 fd->bnode =3D hfs_bnode_find(tree, new_node->parent); > =C2=A0 /* create index key and entry */ > - hfs_bnode_read_key(new_node, fd->search_key, 14, > - =C2=A0=C2=A0 fd->key_capacity); > + hfs_bnode_read_key(new_node, fd->search_key, > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, fd- > >key_capacity); > =C2=A0 cnid =3D cpu_to_be32(new_node->this); > =C2=A0 > =C2=A0 __hfs_brec_find(fd->bnode, fd); > @@ -473,7 +474,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 if (new_node =3D=3D node) > =C2=A0 goto out; > =C2=A0 /* restore search_key */ > - hfs_bnode_read_key(node, fd->search_key, 14, > + hfs_bnode_read_key(node, fd->search_key, > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, > =C2=A0 =C2=A0=C2=A0 fd->key_capacity); > =C2=A0 } > =C2=A0 new_node =3D NULL; > @@ -491,6 +493,7 @@ static int hfs_btree_inc_height(struct hfs_btree > *tree) > =C2=A0 struct hfs_bnode *node, *new_node; > =C2=A0 struct hfs_bnode_desc node_desc; > =C2=A0 int key_size, rec; > + u32 cnid_off; > =C2=A0 __be32 cnid; > =C2=A0 > =C2=A0 node =3D NULL; > @@ -528,28 +531,32 @@ static int hfs_btree_inc_height(struct > hfs_btree *tree) > =C2=A0 hfs_bnode_write(new_node, &node_desc, 0, sizeof(node_desc)); > =C2=A0 > =C2=A0 rec =3D tree->node_size - 2; > - hfs_bnode_write_u16(new_node, rec, 14); > + hfs_bnode_write_u16(new_node, rec, HFS_BNODE_FIRST_REC_OFF); > =C2=A0 > =C2=A0 if (node) { > =C2=A0 /* insert old root idx into new root */ > =C2=A0 node->parent =3D tree->root; > =C2=A0 if (node->type =3D=3D HFS_NODE_LEAF || > =C2=A0 =C2=A0=C2=A0=C2=A0 tree->attributes & HFS_TREE_VARIDXKEYS) > - key_size =3D hfs_bnode_read_u8(node, 14) + 1; > + key_size =3D > + hfs_bnode_read_u8(node, > HFS_BNODE_FIRST_REC_OFF) + 1; > =C2=A0 else > =C2=A0 key_size =3D tree->max_key_len + 1; Ditto. We need to use key_capacity here. Am I right? Please, rework it. > - hfs_bnode_copy(new_node, 14, node, 14, key_size); > + hfs_bnode_copy(new_node, HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 node, HFS_BNODE_FIRST_REC_OFF, > key_size); > =C2=A0 > =C2=A0 if (!(tree->attributes & HFS_TREE_VARIDXKEYS)) { > =C2=A0 key_size =3D tree->max_key_len + 1; > - hfs_bnode_write_u8(new_node, 14, tree- > >max_key_len); > + hfs_bnode_write_u8(new_node, > HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0 tree->max_key_len); > =C2=A0 } > =C2=A0 key_size =3D (key_size + 1) & -2; > =C2=A0 cnid =3D cpu_to_be32(node->this); > - hfs_bnode_write(new_node, &cnid, 14 + key_size, 4); > + cnid_off =3D HFS_BNODE_FIRST_REC_OFF + key_size; > + hfs_bnode_write(new_node, &cnid, cnid_off, > sizeof(cnid)); > =C2=A0 > =C2=A0 rec -=3D 2; > - hfs_bnode_write_u16(new_node, rec, 14 + key_size + > 4); > + hfs_bnode_write_u16(new_node, rec, cnid_off + > sizeof(cnid)); > =C2=A0 > =C2=A0 hfs_bnode_put(node); > =C2=A0 } > diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c > index f070384031..c3cd94f219 100644 > --- a/fs/hfs/btree.c > +++ b/fs/hfs/btree.c > @@ -216,7 +216,7 @@ struct hfs_btree *hfs_btree_open(struct > super_block *sb, u32 id, btree_keycmp ke > =C2=A0 > =C2=A0 /* Load the header */ > =C2=A0 head =3D (struct hfs_btree_header_rec > *)(kmap_local_folio(folio, 0) + > - =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof(struct > hfs_bnode_desc)); > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 > HFS_BNODE_FIRST_REC_OFF); > =C2=A0 tree->root =3D be32_to_cpu(head->root); > =C2=A0 tree->leaf_count =3D be32_to_cpu(head->leaf_count); > =C2=A0 tree->leaf_head =3D be32_to_cpu(head->leaf_head); > @@ -312,7 +312,7 @@ void hfs_btree_write(struct hfs_btree *tree) > =C2=A0 /* Load the header */ > =C2=A0 page =3D node->page[0]; > =C2=A0 head =3D (struct hfs_btree_header_rec *)(kmap_local_page(page) > + > - =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof(struct > hfs_bnode_desc)); > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 > HFS_BNODE_FIRST_REC_OFF); > =C2=A0 > =C2=A0 head->root =3D cpu_to_be32(tree->root); > =C2=A0 head->leaf_count =3D cpu_to_be32(tree->leaf_count); > @@ -356,8 +356,9 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct > hfs_bnode *prev, u32 idx) > =C2=A0 desc.num_recs =3D cpu_to_be16(1); > =C2=A0 desc.reserved =3D 0; > =C2=A0 hfs_bnode_write(node, &desc, 0, sizeof(desc)); > - hfs_bnode_write_u16(node, 14, 0x8000); > - hfs_bnode_write_u16(node, tree->node_size - 2, 14); > + hfs_bnode_write_u16(node, HFS_BNODE_FIRST_REC_OFF, 0x8000); > + hfs_bnode_write_u16(node, tree->node_size - 2, > + =C2=A0=C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF); > =C2=A0 hfs_bnode_write_u16(node, tree->node_size - 4, tree- > >node_size - 6); > =C2=A0 > =C2=A0 return node; > diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c > index 144348bdbf..d91714e97b 100644 > --- a/fs/hfsplus/bnode.c > +++ b/fs/hfsplus/bnode.c > @@ -592,7 +592,7 @@ struct hfs_bnode *hfs_bnode_find(struct hfs_btree > *tree, u32 num) > =C2=A0 > =C2=A0 rec_off =3D tree->node_size - 2; > =C2=A0 off =3D hfs_bnode_read_u16(node, rec_off); > - if (off !=3D sizeof(struct hfs_bnode_desc)) > + if (off !=3D HFS_BNODE_FIRST_REC_OFF) > =C2=A0 goto node_error; > =C2=A0 for (i =3D 1; i <=3D node->num_recs; off =3D next_off, i++) { > =C2=A0 rec_off -=3D 2; > diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c > index c9fb6873ac..c56ca7a852 100644 > --- a/fs/hfsplus/brec.c > +++ b/fs/hfsplus/brec.c > @@ -167,8 +167,8 @@ int hfs_brec_insert(struct hfs_find_data *fd, > void *entry, u32 entry_len) > =C2=A0 entry_len =3D sizeof(cnid); > =C2=A0 > =C2=A0 /* get index key */ > - hfs_bnode_read_key(new_node, fd->search_key, 14, > - =C2=A0=C2=A0 fd->key_capacity); > + hfs_bnode_read_key(new_node, fd->search_key, > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, fd- > >key_capacity); > =C2=A0 __hfs_brec_find(fd->bnode, fd, hfs_find_rec_by_key); > =C2=A0 > =C2=A0 hfs_bnode_put(new_node); > @@ -260,7 +260,6 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd) > =C2=A0 int num_recs, new_rec_off, new_off, old_rec_off; > =C2=A0 int data_start, data_end, size; > =C2=A0 size_t rec_off_tbl_size; > - size_t node_desc_size =3D sizeof(struct hfs_bnode_desc); > =C2=A0 size_t rec_size =3D sizeof(__be16); > =C2=A0 > =C2=A0 tree =3D fd->tree; > @@ -290,7 +289,7 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd) > =C2=A0 > =C2=A0 rec_off_tbl_size =3D node->num_recs * rec_size; > =C2=A0 size =3D tree->node_size / 2; > - size -=3D node_desc_size; > + size -=3D HFS_BNODE_DESC_SIZE; > =C2=A0 size -=3D rec_off_tbl_size; > =C2=A0 old_rec_off =3D tree->node_size - (2 * rec_size); > =C2=A0 > @@ -322,14 +321,14 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd) > =C2=A0 hfs_bnode_get(new_node); > =C2=A0 fd->bnode =3D new_node; > =C2=A0 fd->record -=3D num_recs; > - fd->keyoffset -=3D data_start - node_desc_size; > - fd->entryoffset -=3D data_start - node_desc_size; > + fd->keyoffset -=3D data_start - > HFS_BNODE_FIRST_REC_OFF; > + fd->entryoffset -=3D data_start - > HFS_BNODE_FIRST_REC_OFF; > =C2=A0 } > =C2=A0 new_node->num_recs =3D node->num_recs - num_recs; > =C2=A0 node->num_recs =3D num_recs; > =C2=A0 > =C2=A0 new_rec_off =3D tree->node_size - rec_size; > - new_off =3D node_desc_size; > + new_off =3D HFS_BNODE_FIRST_REC_OFF; > =C2=A0 size =3D data_start - new_off; > =C2=A0 num_recs =3D new_node->num_recs; > =C2=A0 data_end =3D data_start; > @@ -342,8 +341,8 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd) > =C2=A0 num_recs--; > =C2=A0 } > =C2=A0 hfs_bnode_write_u16(new_node, new_rec_off, new_off); > - hfs_bnode_copy(new_node, node_desc_size, > - node, data_start, data_end - data_start); > + hfs_bnode_copy(new_node, HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 node, data_start, data_end - data= _start); > =C2=A0 > =C2=A0 /* update new bnode header */ > =C2=A0 node_desc.next =3D cpu_to_be32(new_node->next); > @@ -410,8 +409,9 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 > =C2=A0 /* size difference between old and new key */ > =C2=A0 if ((tree->attributes & HFS_TREE_VARIDXKEYS) || > - (tree->cnid =3D=3D HFSPLUS_ATTR_CNID)) > - newkeylen =3D hfs_bnode_read_u16(node, 14) + 2; > + =C2=A0=C2=A0=C2=A0 (tree->cnid =3D=3D HFSPLUS_ATTR_CNID)) > + newkeylen =3D > + hfs_bnode_read_u16(node, > HFS_BNODE_FIRST_REC_OFF) + 2; > =C2=A0 else > =C2=A0 fd->keylength =3D newkeylen =3D tree->max_key_len + 2; Ditto. We need to use key_capacity here. Am I right? Please, rework it. > =C2=A0 hfs_dbg("rec %d, keylength %d, newkeylen %d\n", > @@ -451,7 +451,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 hfs_bnode_move(parent, start_off + diff, start_off, > =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end_off - start_off); > =C2=A0skip: > - hfs_bnode_copy(parent, fd->keyoffset, node, 14, newkeylen); > + hfs_bnode_copy(parent, fd->keyoffset, node, > HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newkeylen); > =C2=A0 hfs_bnode_dump(parent); > =C2=A0 > =C2=A0 hfs_bnode_put(node); > @@ -466,8 +467,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 } > =C2=A0 fd->bnode =3D hfs_bnode_find(tree, new_node->parent); > =C2=A0 /* create index key and entry */ > - hfs_bnode_read_key(new_node, fd->search_key, 14, > - =C2=A0=C2=A0 fd->key_capacity); > + hfs_bnode_read_key(new_node, fd->search_key, > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, fd- > >key_capacity); > =C2=A0 cnid =3D cpu_to_be32(new_node->this); > =C2=A0 > =C2=A0 __hfs_brec_find(fd->bnode, fd, hfs_find_rec_by_key); > @@ -479,7 +480,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 if (new_node =3D=3D node) > =C2=A0 goto out; > =C2=A0 /* restore search_key */ > - hfs_bnode_read_key(node, fd->search_key, 14, > + hfs_bnode_read_key(node, fd->search_key, > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, > =C2=A0 =C2=A0=C2=A0 fd->key_capacity); > =C2=A0 } > =C2=A0 new_node =3D NULL; > @@ -497,6 +499,7 @@ static int hfs_btree_inc_height(struct hfs_btree > *tree) > =C2=A0 struct hfs_bnode *node, *new_node; > =C2=A0 struct hfs_bnode_desc node_desc; > =C2=A0 int key_size, rec; > + u32 cnid_off; > =C2=A0 __be32 cnid; > =C2=A0 > =C2=A0 node =3D NULL; > @@ -534,29 +537,33 @@ static int hfs_btree_inc_height(struct > hfs_btree *tree) > =C2=A0 hfs_bnode_write(new_node, &node_desc, 0, sizeof(node_desc)); > =C2=A0 > =C2=A0 rec =3D tree->node_size - 2; > - hfs_bnode_write_u16(new_node, rec, 14); > + hfs_bnode_write_u16(new_node, rec, HFS_BNODE_FIRST_REC_OFF); > =C2=A0 > =C2=A0 if (node) { > =C2=A0 /* insert old root idx into new root */ > =C2=A0 node->parent =3D tree->root; > =C2=A0 if (node->type =3D=3D HFS_NODE_LEAF || > - tree->attributes & > HFS_TREE_VARIDXKEYS || > - tree->cnid =3D=3D HFSPLUS_ATTR_CNID) > - key_size =3D hfs_bnode_read_u16(node, 14) + 2; > + =C2=A0=C2=A0=C2=A0 tree->attributes & HFS_TREE_VARIDXKEYS || > + =C2=A0=C2=A0=C2=A0 tree->cnid =3D=3D HFSPLUS_ATTR_CNID) > + key_size =3D > + hfs_bnode_read_u16(node, > HFS_BNODE_FIRST_REC_OFF) + 2; > =C2=A0 else > =C2=A0 key_size =3D tree->max_key_len + 2; Ditto. We need to use key_capacity here. Am I right? Please, rework it. Thanks, Slava. > - hfs_bnode_copy(new_node, 14, node, 14, key_size); > + hfs_bnode_copy(new_node, HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 node, HFS_BNODE_FIRST_REC_OFF, > key_size); > =C2=A0 > =C2=A0 if (!(tree->attributes & HFS_TREE_VARIDXKEYS) && > - (tree->cnid !=3D HFSPLUS_ATTR_CNID)) { > + =C2=A0=C2=A0=C2=A0 (tree->cnid !=3D HFSPLUS_ATTR_CNID)) { > =C2=A0 key_size =3D tree->max_key_len + 2; > - hfs_bnode_write_u16(new_node, 14, tree- > >max_key_len); > + hfs_bnode_write_u16(new_node, > HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0=C2=A0 tree->max_key_len); > =C2=A0 } > =C2=A0 cnid =3D cpu_to_be32(node->this); > - hfs_bnode_write(new_node, &cnid, 14 + key_size, 4); > + cnid_off =3D HFS_BNODE_FIRST_REC_OFF + key_size; > + hfs_bnode_write(new_node, &cnid, cnid_off, > sizeof(cnid)); > =C2=A0 > =C2=A0 rec -=3D 2; > - hfs_bnode_write_u16(new_node, rec, 14 + key_size + > 4); > + hfs_bnode_write_u16(new_node, rec, cnid_off + > sizeof(cnid)); > =C2=A0 > =C2=A0 hfs_bnode_put(node); > =C2=A0 } > diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c > index 0a9b32d5c5..c42f655e71 100644 > --- a/fs/hfsplus/btree.c > +++ b/fs/hfsplus/btree.c > @@ -322,7 +322,7 @@ struct hfs_btree *hfs_btree_open(struct > super_block *sb, u32 id) > =C2=A0 > =C2=A0 /* Load the header */ > =C2=A0 head =3D (struct hfs_btree_header_rec *)(kmap_local_page(page) > + > - sizeof(struct hfs_bnode_desc)); > + HFS_BNODE_FIRST_REC_OFF); > =C2=A0 tree->root =3D be32_to_cpu(head->root); > =C2=A0 tree->leaf_count =3D be32_to_cpu(head->leaf_count); > =C2=A0 tree->leaf_head =3D be32_to_cpu(head->leaf_head); > @@ -454,7 +454,7 @@ int hfs_btree_write(struct hfs_btree *tree) > =C2=A0 /* Load the header */ > =C2=A0 page =3D node->page[0]; > =C2=A0 head =3D (struct hfs_btree_header_rec *)(kmap_local_page(page) > + > - sizeof(struct hfs_bnode_desc)); > + HFS_BNODE_FIRST_REC_OFF); > =C2=A0 > =C2=A0 head->root =3D cpu_to_be32(tree->root); > =C2=A0 head->leaf_count =3D cpu_to_be32(tree->leaf_count); > @@ -497,8 +497,9 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct > hfs_bnode *prev, u32 idx) > =C2=A0 desc.num_recs =3D cpu_to_be16(1); > =C2=A0 desc.reserved =3D 0; > =C2=A0 hfs_bnode_write(node, &desc, 0, sizeof(desc)); > - hfs_bnode_write_u16(node, 14, 0x8000); > - hfs_bnode_write_u16(node, tree->node_size - 2, 14); > + hfs_bnode_write_u16(node, HFS_BNODE_FIRST_REC_OFF, 0x8000); > + hfs_bnode_write_u16(node, tree->node_size - 2, > + =C2=A0=C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF); > =C2=A0 hfs_bnode_write_u16(node, tree->node_size - 4, tree- > >node_size - 6); > =C2=A0 > =C2=A0 return node; > diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h > index 3d33f2df0b..43062f056f 100644 > --- a/fs/hfsplus/hfsplus_fs.h > +++ b/fs/hfsplus/hfsplus_fs.h > @@ -659,16 +659,15 @@ bool hfs_bnode_num_recs_invalid(struct > hfs_bnode *node) > =C2=A0 u32 table_size; > =C2=A0 u32 area_size; > =C2=A0 u32 rec_size =3D sizeof(__be16); > - u32 desc_size =3D sizeof(struct hfs_bnode_desc); > =C2=A0 > =C2=A0 if (!node || !node->tree) > =C2=A0 return true; > =C2=A0 > =C2=A0 node_size =3D node->tree->node_size; > - if (node_size < desc_size) > + if (node_size < HFS_BNODE_DESC_SIZE) > =C2=A0 return true; > =C2=A0 > - area_size =3D node_size - desc_size; > + area_size =3D node_size - HFS_BNODE_DESC_SIZE; > =C2=A0 table_size =3D ((u32)node->num_recs + 1) * rec_size; > =C2=A0 > =C2=A0 return table_size > area_size; > @@ -691,12 +690,11 @@ bool hfs_brec_offsets_invalid(struct hfs_bnode > *node, u16 off, u16 next_off) > =C2=A0 u32 table_size; > =C2=A0 u32 table_start; > =C2=A0 u32 rec_size =3D sizeof(__be16); > - u32 desc_size =3D sizeof(struct hfs_bnode_desc); > =C2=A0 > =C2=A0 if (!node || !node->tree) > =C2=A0 return true; > =C2=A0 > - if (off < desc_size || (off & 1)) > + if (off < HFS_BNODE_FIRST_REC_OFF || (off & 1)) > =C2=A0 return true; > =C2=A0 > =C2=A0 if (next_off <=3D off || > diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c > index 3aeca4d177..37e04fa253 100644 > --- a/fs/hfsplus/xattr.c > +++ b/fs/hfsplus/xattr.c > @@ -80,7 +80,7 @@ static u32 hfsplus_init_header_node(struct inode > *attr_file, > =C2=A0 desc =3D (struct hfs_bnode_desc *)buf; > =C2=A0 desc->type =3D HFS_NODE_HEADER; > =C2=A0 desc->num_recs =3D > cpu_to_be16(HFSPLUS_BTREE_HDR_NODE_RECS_COUNT); > - offset =3D sizeof(struct hfs_bnode_desc); > + offset =3D HFS_BNODE_FIRST_REC_OFF; > =C2=A0 *--rec_offsets =3D cpu_to_be16(offset); > =C2=A0 > =C2=A0 head =3D (struct hfs_btree_header_rec *)(buf + offset); > @@ -102,8 +102,8 @@ static u32 hfsplus_init_header_node(struct inode > *attr_file, > =C2=A0 u32 map_node_bits; > =C2=A0 > =C2=A0 desc->next =3D cpu_to_be32(be32_to_cpu(head- > >leaf_tail) + 1); > - map_node_bits =3D 8 * (node_size - sizeof(struct > hfs_bnode_desc) - > - (2 * sizeof(u16)) - 2); > + map_node_bits =3D (node_size - HFS_BNODE_DESC_SIZE - > + (sizeof(u16) * 2) - 2) * 8; > =C2=A0 map_nodes =3D (be32_to_cpu(head->node_count) - > =C2=A0 hdr_node_map_rec_bits + > =C2=A0 (map_node_bits - 1)) / > map_node_bits; > @@ -163,7 +163,7 @@ static void hfsplus_init_map_node(u8 *buf, u16 > node_size, u32 next_node) > =C2=A0 rec_offsets =3D (__be16 *)(buf + node_size); > =C2=A0 > =C2=A0 /* record #1 */ > - offset =3D sizeof(struct hfs_bnode_desc); > + offset =3D HFS_BNODE_FIRST_REC_OFF; > =C2=A0 *--rec_offsets =3D cpu_to_be16(offset); > =C2=A0 > =C2=A0 /* record #2 */ > diff --git a/include/linux/hfs_common.h b/include/linux/hfs_common.h > index eb119a1c56..10324627f9 100644 > --- a/include/linux/hfs_common.h > +++ b/include/linux/hfs_common.h > @@ -495,6 +495,12 @@ struct hfs_bnode_desc { > =C2=A0 u16 reserved; > =C2=A0} __packed; > =C2=A0 > +/* Size of the node descriptor at the start of every node */ > +#define HFS_BNODE_DESC_SIZE sizeof(struct hfs_bnode_desc) > + > +/* Offset of record 0, which follows the node descriptor */ > +#define HFS_BNODE_FIRST_REC_OFF HFS_BNODE_DESC_SIZE > + > =C2=A0/* HFS/HFS+ BTree node types */ > =C2=A0#define HFS_NODE_INDEX 0x00 /* An internal (index) node */ > =C2=A0#define HFS_NODE_HEADER 0x01 /* The tree header node > (node 0) */