Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1693108ybs; Tue, 26 May 2020 01:00:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDmWT+44LFzrtgm3/bjEK0WwVNuwFFwAVfbxvwHaG/JWpw9n9GQHuBUkP9jxjAjfmJT6qF X-Received: by 2002:a17:906:71d4:: with SMTP id i20mr40943ejk.375.1590480034183; Tue, 26 May 2020 01:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590480034; cv=none; d=google.com; s=arc-20160816; b=hEZsCA5Pz/1ShPiLL//K3W/FGXPYeGhH6JQiN+oNtccD04iLzrz72WjYRBxYL1lsEp 95wUukho3tx3bZvmig5YxB5/KR1hqlp+MpOCADDchUA0h0JiUGE5YM0il6WJ7iTQMg6l /xRfDf8FWzjJjzg8zLQYb4g5BACe12c4Z4c4f/rVMnSXbee/jyUFj5Het+qipr/t3vdl /VQY12bjg1XbdIwseqdtmg3p9wyWa7DaSowWo7A1aac0e8jWsDUiou6dFCCtfsEajr/A VXI6ZettOi1x2PMLQmmmnDBSK1lYW0UJzIW4fwojGxpViEZwB0j1S55w+m5aRzIZH0ZC saaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :content-language:thread-index:content-transfer-encoding :mime-version:message-id:date:subject:in-reply-to:cc:to:from :dkim-signature:dkim-filter; bh=PfJimvdiNEazsfnAJ3KOEpunw/5Jm4262M9Vn1U1FA4=; b=Kq68pOcYArAmmCg85KGhFswa+kGd4Up6nBWcwlc2kDPFI5tp3g3v87EcwGD+iUkRzW pRhl64QyG+I2sdeZ58mDpCQHV6vO/OIuq94aCzySGdLzBzYMlAzQcX8f+LJ7Gr1LHB0f h2y0Nc5VWl5DpfOi+w7rSx8HCVMglcHE7i4i0F53DjnUlWo6Ae5eyBupmideiUtYL7pV T7QdMeniN2SVFGxQE3jCCdhOgS2qvemxATznVZWWWu7tFST8sXjR9DxAeTXMa0I+2Ko0 GCk/ROChJZpN7SR3BKehCL4t+afQ/qX8PGK6r2Haz3VYcuaUkRGs1nOzNlQ3SxDe4+KQ c5wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=nsI1tzG0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si10836408ejs.646.2020.05.26.01.00.10; Tue, 26 May 2020 01:00:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=nsI1tzG0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbgEZHcq (ORCPT + 99 others); Tue, 26 May 2020 03:32:46 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:24250 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbgEZHcq (ORCPT ); Tue, 26 May 2020 03:32:46 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200526073240epoutp048df857e99c939df18bc3a844d36d179a~Sg6RNJJ9e2241522415epoutp04D for ; Tue, 26 May 2020 07:32:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200526073240epoutp048df857e99c939df18bc3a844d36d179a~Sg6RNJJ9e2241522415epoutp04D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1590478360; bh=PfJimvdiNEazsfnAJ3KOEpunw/5Jm4262M9Vn1U1FA4=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=nsI1tzG0C9GWugf5VbHBbHHJsgzsl5ItjnD0dnMb1jeS1uulRUDsZSkKe6OxlcUqa mJyFcMcdPTp29fmx3c9vW8q7oOyt17rmudWQtaR7DndklfiusvupgP7piVd2djue1w bsTmUKxpeWCiKeCAyVMvcTFpUUOXv7peIchA156k= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20200526073239epcas1p104192b116709e48eb03e721eb6cfcc76~Sg6QmbRlm0183201832epcas1p15; Tue, 26 May 2020 07:32:39 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.40.160]) by epsnrtp3.localdomain (Postfix) with ESMTP id 49WQfG32J7zMqYkr; Tue, 26 May 2020 07:32:38 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id A7.FD.04801.616CCCE5; Tue, 26 May 2020 16:32:38 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20200526073237epcas1p3eabdc05a210b552797469acd103d0ba8~Sg6PIARzw1816618166epcas1p3i; Tue, 26 May 2020 07:32:37 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200526073237epsmtrp11924a4909ab68f7926c7e13659af52b5~Sg6PG8YlE1548215482epsmtrp1L; Tue, 26 May 2020 07:32:37 +0000 (GMT) X-AuditID: b6c32a38-f89ff700000012c1-aa-5eccc6160fc8 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 48.04.08303.516CCCE5; Tue, 26 May 2020 16:32:37 +0900 (KST) Received: from namjaejeon01 (unknown [10.88.104.63]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200526073237epsmtip298d04cd994f4a19ba6079caaca4f365b~Sg6O6wMKE1888518885epsmtip2U; Tue, 26 May 2020 07:32:37 +0000 (GMT) From: "Namjae Jeon" To: "'Tetsuhiro Kohada'" Cc: , , , "'Sungjong Seo'" , , In-Reply-To: <20200525115052.19243-4-kohada.t2@gmail.com> Subject: RE: [PATCH 4/4] exfat: standardize checksum calculation Date: Tue, 26 May 2020 16:32:37 +0900 Message-ID: <00d301d6332f$d4a52300$7def6900$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQEl0VwLAqGTGno4seWfP7lwGg+RAAKJW6foAcSd2fWp+EvHYA== Content-Language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA01SbUhTYRTu3b3bruXiNq0ORrkuWCrMNuf0WhphUoP6odUPK3De9LZJd9tl d/ZhBH2YlYmW5o/WrAy0FM1Q8QtFp5WNPiDLVMK+cJCVUaZUFNrmVfLfc57znPOc876HwJQ1 shAi2+pg7VaGo2SL8ebeCI16xcMn6ZpPxUD/Kn+N0188ZTjd0enB6RftLhn9YmYCp6smS3G6 afq+dIvcMOnqkxvyS6flhjMPq2WGNueI3FDUVIMMPxrWpMj2cQlmlsli7SrWmmnLyraaEqkd u41bjfpYjVatjafjKJWVsbCJVPLOFPW2bM43C6U6zHA5PiqFEQRqw+YEuy3HwarMNsGRSLF8 FsdrNXyUwFiEHKspKtNm2ajVaKL1PmUGZx6v65bwn+OPvh94i51EI+oCFEAAGQMzD9yoAC0m lGQrgo6p+WACQVvnGYkY/EBwo2hGNl9S9LtBJibaEXh/euViMIbgw7BL6lfJSDVM/+2arQgm o8DjGZytwMhTErj9aBLzJwLIeHg8ddXnQRBB5BZ4UBHup3EyDN60NCM/VvgkVZ8HcB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yMTBeIhRgoNZSYTX6ezpOCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8 X2ctjBMSSE8sSc1OTS1ILYLJMnFwSjUwGQgdY1YsKFxj/O+d2E1utW7RuRMT378Sr5HmUd90 0tOL07AyKySGKZR/muy/rPaSy6sfFTF33/p9SSTivtObaz76QS/2eD/9GLpS6v+sR0lRYfdF K8L7tu8IumsVwPmr5IKXuomVam744ayTZ3nZ/sVKJbGuZfixxZpl8c+3KhdOm+c1vL20R2Vl Cl+AyaGNesEvOr+t0Pxe+Xz6b09u7zdbzby1Qvc4HtY2mPu2V0bllE6eg+PWiXG7Raw/LogS ynbML9beGRZ07fesfX+ffE44/6F1dnS025YOSftGD23R6HkFj9O2tobzh6ldaNvyW2Wua/IC p53WhS9Xssctfnus9HJQ+t3e2+d7D21UYinOSDTUYi4qTgQAD3ZAbBgDAAA= X-CMS-MailID: 20200526073237epcas1p3eabdc05a210b552797469acd103d0ba8 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200525115121epcas1p2843be2c4af35d5d7e176c68af95052f8 References: <20200525115052.19243-1-kohada.t2@gmail.com> <20200525115052.19243-4-kohada.t2@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > To clarify that it is a 16-bit checksum, the parts related to the 16-bit checksum are renamed and > change type to u16. > Furthermore, replace checksum calculation in exfat_load_upcase_table() with exfat_calc_checksum32(). > > Signed-off-by: Tetsuhiro Kohada I can not apply this patch to exfat dev tree. Could you please check it ? patching file fs/exfat/dir.c Hunk #1 succeeded at 491 (offset -5 lines). Hunk #2 succeeded at 500 (offset -5 lines). Hunk #3 succeeded at 508 (offset -5 lines). Hunk #4 FAILED at 600. Hunk #5 succeeded at 1000 (offset -47 lines). 1 out of 5 hunks FAILED -- saving rejects to file fs/exfat/dir.c.rej patching file fs/exfat/exfat_fs.h Hunk #1 succeeded at 137 (offset -2 lines). Hunk #2 succeeded at 512 (offset -3 lines). patching file fs/exfat/misc.c patching file fs/exfat/nls.c Thanks! > --- > fs/exfat/dir.c | 12 ++++++------ > fs/exfat/exfat_fs.h | 5 ++--- > fs/exfat/misc.c | 10 ++++------ > fs/exfat/nls.c | 19 +++++++------------ > 4 files changed, 19 insertions(+), 27 deletions(-) > > diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index b5a237c33d50..b673362a895c 100644 > --- a/fs/exfat/dir.c > +++ b/fs/exfat/dir.c > @@ -496,7 +496,7 @@ int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, > int ret = 0; > int i, num_entries; > sector_t sector; > - unsigned short chksum; > + u16 chksum; > struct exfat_dentry *ep, *fep; > struct buffer_head *fbh, *bh; > > @@ -505,7 +505,7 @@ int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, > return -EIO; > > num_entries = fep->dentry.file.num_ext + 1; > - chksum = exfat_calc_chksum_2byte(fep, DENTRY_SIZE, 0, CS_DIR_ENTRY); > + chksum = exfat_calc_chksum16(fep, DENTRY_SIZE, 0, CS_DIR_ENTRY); > > for (i = 1; i < num_entries; i++) { > ep = exfat_get_dentry(sb, p_dir, entry + i, &bh, NULL); @@ -513,7 +513,7 @@ int > exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir, > ret = -EIO; > goto release_fbh; > } > - chksum = exfat_calc_chksum_2byte(ep, DENTRY_SIZE, chksum, > + chksum = exfat_calc_chksum16(ep, DENTRY_SIZE, chksum, > CS_DEFAULT); > brelse(bh); > } > @@ -600,10 +600,10 @@ int exfat_update_dir_chksum_with_entry_set(struct super_block *sb, > int chksum_type = CS_DIR_ENTRY, i, num_entries = es->num_entries; > unsigned int buf_off = (off - es->offset); > unsigned int remaining_byte_in_sector, copy_entries, clu; > - unsigned short chksum = 0; > + u16 chksum = 0; > > for (i = 0; i < num_entries; i++) { > - chksum = exfat_calc_chksum_2byte(&es->entries[i], DENTRY_SIZE, > + chksum = exfat_calc_chksum16(&es->entries[i], DENTRY_SIZE, > chksum, chksum_type); > chksum_type = CS_DEFAULT; > } > @@ -1047,7 +1047,7 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei, > } > > if (entry_type == TYPE_STREAM) { > - unsigned short name_hash; > + u16 name_hash; > > if (step != DIRENT_STEP_STRM) { > step = DIRENT_STEP_FILE; > diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h index 15817281b3c8..993d13bbebec 100644 > --- a/fs/exfat/exfat_fs.h > +++ b/fs/exfat/exfat_fs.h > @@ -139,7 +139,7 @@ struct exfat_dentry_namebuf { struct exfat_uni_name { > /* +3 for null and for converting */ > unsigned short name[MAX_NAME_LENGTH + 3]; > - unsigned short name_hash; > + u16 name_hash; > unsigned char name_len; > }; > > @@ -515,8 +515,7 @@ void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, void > exfat_truncate_atime(struct timespec64 *ts); void exfat_set_entry_time(struct exfat_sb_info *sbi, > struct timespec64 *ts, > u8 *tz, __le16 *time, __le16 *date, u8 *time_cs); -unsigned short > exfat_calc_chksum_2byte(void *data, int len, > - unsigned short chksum, int type); > +u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type); > u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type); void exfat_update_bh(struct > super_block *sb, struct buffer_head *bh, int sync); void exfat_chain_set(struct exfat_chain *ec, > unsigned int dir, diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c index b82d2dd5bd7c..17d41f3d3709 > 100644 > --- a/fs/exfat/misc.c > +++ b/fs/exfat/misc.c > @@ -136,17 +136,15 @@ void exfat_truncate_atime(struct timespec64 *ts) > ts->tv_nsec = 0; > } > > -unsigned short exfat_calc_chksum_2byte(void *data, int len, > - unsigned short chksum, int type) > +u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type) > { > int i; > - unsigned char *c = (unsigned char *)data; > + u8 *c = (u8 *)data; > > for (i = 0; i < len; i++, c++) { > - if (((i == 2) || (i == 3)) && (type == CS_DIR_ENTRY)) > + if (unlikely(type == CS_DIR_ENTRY && (i == 2 || i == 3))) > continue; > - chksum = (((chksum & 1) << 15) | ((chksum & 0xFFFE) >> 1)) + > - (unsigned short)*c; > + chksum = ((chksum << 15) | (chksum >> 1)) + *c; > } > return chksum; > } > diff --git a/fs/exfat/nls.c b/fs/exfat/nls.c index 1ebda90cbdd7..19321773dd07 100644 > --- a/fs/exfat/nls.c > +++ b/fs/exfat/nls.c > @@ -527,7 +527,7 @@ static int exfat_utf8_to_utf16(struct super_block *sb, > > *uniname = '\0'; > p_uniname->name_len = unilen; > - p_uniname->name_hash = exfat_calc_chksum_2byte(upname, unilen << 1, 0, > + p_uniname->name_hash = exfat_calc_chksum16(upname, unilen << 1, 0, > CS_DEFAULT); > > if (p_lossy) > @@ -623,7 +623,7 @@ static int exfat_nls_to_ucs2(struct super_block *sb, > > *uniname = '\0'; > p_uniname->name_len = unilen; > - p_uniname->name_hash = exfat_calc_chksum_2byte(upname, unilen << 1, 0, > + p_uniname->name_hash = exfat_calc_chksum16(upname, unilen << 1, 0, > CS_DEFAULT); > > if (p_lossy) > @@ -655,7 +655,8 @@ static int exfat_load_upcase_table(struct super_block *sb, { > struct exfat_sb_info *sbi = EXFAT_SB(sb); > unsigned int sect_size = sb->s_blocksize; > - unsigned int i, index = 0, checksum = 0; > + unsigned int i, index = 0; > + u32 chksum = 0; > int ret; > unsigned char skip = false; > unsigned short *upcase_table; > @@ -681,13 +682,6 @@ static int exfat_load_upcase_table(struct super_block *sb, > for (i = 0; i < sect_size && index <= 0xFFFF; i += 2) { > unsigned short uni = get_unaligned_le16(bh->b_data + i); > > - checksum = ((checksum & 1) ? 0x80000000 : 0) + > - (checksum >> 1) + > - *(((unsigned char *)bh->b_data) + i); > - checksum = ((checksum & 1) ? 0x80000000 : 0) + > - (checksum >> 1) + > - *(((unsigned char *)bh->b_data) + (i + 1)); > - > if (skip) { > index += uni; > skip = false; > @@ -701,13 +695,14 @@ static int exfat_load_upcase_table(struct super_block *sb, > } > } > brelse(bh); > + chksum = exfat_calc_chksum32(bh->b_data, i, chksum, CS_DEFAULT); > } > > - if (index >= 0xFFFF && utbl_checksum == checksum) > + if (index >= 0xFFFF && utbl_checksum == chksum) > return 0; > > exfat_err(sb, "failed to load upcase table (idx : 0x%08x, chksum : 0x%08x, utbl_chksum : > 0x%08x)", > - index, checksum, utbl_checksum); > + index, chksum, utbl_checksum); > ret = -EINVAL; > free_table: > exfat_free_upcase_table(sbi); > -- > 2.25.1