Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp433904ybg; Mon, 1 Jun 2020 05:24:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjR0viUZ7F9flWkNneMygCKRSKsZeH5M6mVRt3OMgF0znWDeKgw39zPWOeEVh2u6ZQNwPI X-Received: by 2002:a05:6402:2c4:: with SMTP id b4mr21970383edx.331.1591014292194; Mon, 01 Jun 2020 05:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591014292; cv=none; d=google.com; s=arc-20160816; b=z6fZJZSEZ+DKh9cF7gc4DSUvjqrmfd4+BWZ1qvzvcBVpaWf0WlGIv4f0OaNHAbqfZJ 1w3XkZkzTdGfVys3d8+hdEmItmCl/39xFfGb8NjQmdZGNmG1blSGZYeSSvblgpZoQxbx sGkZ5xSOnfsusxArg8lvMj1YikMt2q5s2G14LhVqfXpbuMLgxfDsKDqBiIPzbXS8iGrt lkFc9HePcGavmizVX3v4vEQr7lfvAtMazWHseJ1aCS2vqpUPf8luzbMk6byRXRvoxOri 4Fh33Qa96kzI4Jbc87KYICUs9Q6rmXuE8RyBkUuC/FJS8eqA+a1GTzg3Lz/f3CQ9Xd2h Yu7g== 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=dy69MGQgELlHLL4nuipB9eWH9vUU1X+psE1Q1svnC+Q=; b=paLeufVK/zJvdmgoc7AV/E8xeqQWF2u/JUOtxTqiqcie/yrshJZaaOxk0J7qYkLkNr uwqeLDEb4bpwK86/WBX9sbDgfZPmV/yjtky5QWZQW5dkeyAswGEkzJKQQas1l9eZgA97 nul//CzmdOKkLDBB6qHouEHBriDysNOvtX9w0rFlz3Abrzt5mf34+ZvenL/LPFramIDJ yY5fyME+zpzki5nQdte+VsUgOqpYqx3e+ZK5+khIGSE/0+EWc9cWykDPSoElrv1I5y+J 5Rk5z44hQXPLk5coa6IqZ3Dwpzp7xKVaCbFyoE0chF6bQUq00CtfoAqNhZ7303nU9EY1 Fytg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=DIR8jNmz; 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 z1si10830923edp.481.2020.06.01.05.24.29; Mon, 01 Jun 2020 05:24:52 -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=DIR8jNmz; 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 S1726287AbgFAMUe (ORCPT + 99 others); Mon, 1 Jun 2020 08:20:34 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:27947 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbgFAMUc (ORCPT ); Mon, 1 Jun 2020 08:20:32 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200601122028epoutp0416a20005d52ecfd0d233faee46ee6c9e~UatReW_2i0829608296epoutp046 for ; Mon, 1 Jun 2020 12:20:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200601122028epoutp0416a20005d52ecfd0d233faee46ee6c9e~UatReW_2i0829608296epoutp046 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1591014028; bh=dy69MGQgELlHLL4nuipB9eWH9vUU1X+psE1Q1svnC+Q=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=DIR8jNmzag2Gz8ba1mv5pnQv5a/+JiNXxZZGt7ZSef7RxYZ8hV4LNZlkHqm4LHYlW J8x5RY/zbIdfU+jx6PpQ7jE6XZYAoXgLgUnw9h4F5cpHV+d6zcy4UEVwPokkZku+l7 PVnMuJJMyhXmUQ1FmPWWR4bvomaEQsX+QCUXFonk= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20200601122028epcas1p2ff39bf4111e69ee6d9ff974427e1727f~UatQ65CSS2504625046epcas1p2x; Mon, 1 Jun 2020 12:20:28 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.40.161]) by epsnrtp3.localdomain (Postfix) with ESMTP id 49bDlb1mvkzMqYkb; Mon, 1 Jun 2020 12:20:27 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id 04.CB.28581.B82F4DE5; Mon, 1 Jun 2020 21:20:27 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200601122026epcas1p22567fb0e0b9aeae89556e59a6f50ef67~UatPgBfk92949729497epcas1p2T; Mon, 1 Jun 2020 12:20:26 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200601122026epsmtrp15694e23b5327fe306dd7ddf83f8cf11e~UatPfbEEn1178611786epsmtrp1U; Mon, 1 Jun 2020 12:20:26 +0000 (GMT) X-AuditID: b6c32a38-2cdff70000006fa5-94-5ed4f28bff21 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 33.A3.08382.A82F4DE5; Mon, 1 Jun 2020 21:20:26 +0900 (KST) Received: from W10PB11329 (unknown [10.253.152.129]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200601122026epsmtip21ea8f739fab07ad4f07e5273a9aa9a43~UatPTUecf0351003510epsmtip2W; Mon, 1 Jun 2020 12:20:26 +0000 (GMT) From: "Sungjong Seo" To: "'Tetsuhiro Kohada'" Cc: , , , "'Namjae Jeon'" , , In-Reply-To: <20200529101459.8546-4-kohada.t2@gmail.com> Subject: RE: [PATCH 4/4 v3] exfat: standardize checksum calculation Date: Mon, 1 Jun 2020 21:20:26 +0900 Message-ID: <1fff01d6380f$07fdd970$17f98c50$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQECpNOBCAKs/TRXObwEq14CKUeHvgGnqJluAgpaxnmqTUQv4A== Content-Language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHJsWRmVeSWpSXmKPExsWy7bCmnm73pytxBp8O81j8mHubxeLNyaks Fnv2nmSxuLxrDpvF5f+fWCyWfZnMYvFjer0Du8eXOcfZPdom/2P3aD62ks1j56y77B59W1Yx enzeJBfAFpVjk5GamJJapJCal5yfkpmXbqvkHRzvHG9qZmCoa2hpYa6kkJeYm2qr5OIToOuW mQN0ipJCWWJOKVAoILG4WEnfzqYov7QkVSEjv7jEVim1ICWnwNCgQK84Mbe4NC9dLzk/18rQ wMDIFKgyISfjT0sXW8Eus4rtnT0sDYy3tLoYOTkkBEwkZpxcyNTFyMUhJLCDUaJ5/kMWCOcT o8Sla//ZIZxvjBLvZ89kg2l5t385G0RiL6PE5FsvWSGcl4wSM84/ZAapYhPQlXhy4yeYLSKg J3Hy5HWwbmaBRiaJEy+zQWxOAQuJTS0NYDXCAs4SByY+ZgKxWQRUJOaf/QcW5xWwlPgz/wmU LShx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BJCAlsZJT4u4AWxOQUsJDa1NIA1CAs4SxyY+BishkVARWL+2X9gcV4B S4k/859A2YISJ2c+YQE5ghloQdtGRpAws4C8xPa3c5gh7leQ2P3pKCvEDU4SHVu/skDUiEjM 7mxjnsAoPAvJpFkIk2YhmTQLSccCRpZVjJKpBcW56bnFhgWGeanlesWJucWleel6yfm5mxjB EaWluYNx+6oPeocYmTgYDzFKcDArifBOVr8UJ8SbklhZlVqUH19UmpNafIhRmoNFSZz3RuHC OCGB9MSS1OzU1ILUIpgsEwenVAOTUuW8J8yHjh+LYf9duTaUv4w/5UZT9H2Bbq+3S/seWn/J vpN4UuQC44cZPxZxLz+96NQtzlkHZA/cfXlbv2jfIcZAsT9nDNKLZy3WNvaLf83BWTjJ5tGv KX1f+gWF7zE9CnE8vUzss4GYVNrb8EdiFvvqns9h/sXxu/ig1b7E58d3hfd/nRD99JrSgoBu beepq0OKltr46DbzX14w8eqOr8mXV39+XX16c9bxvZtqT5c+fHaEO0xAMX07g6jRhs6zujyF 5dtObNTcufrPBIuCgFsv3139G8DI/b/a/NqrSRuZHk5NvRUjcMuz92DZ07CWieJ7vHIrhG59 UQ/RnyT54p6D9LOShRZGdTaHww6uDlJiKc5INNRiLipOBABEZTelFwMAAA== X-CMS-MailID: 20200601122026epcas1p22567fb0e0b9aeae89556e59a6f50ef67 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: 20200529101637epcas1p24499ced02928374f9140d59dc7c1e99c References: <20200529101459.8546-1-kohada.t2@gmail.com> <20200529101459.8546-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 Reviewed-by: Sungjong Seo > --- > Changes in v2: > - rebase with patch 'optimize dir-cache' applied Changes in v3: > - based on '[PATCH 2/4 v3] exfat: separate the boot sector analysis' > > 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 > 2902d285bf20..de43534aa299 100644 > --- a/fs/exfat/dir.c > +++ b/fs/exfat/dir.c > @@ -491,7 +491,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; > > @@ -500,7 +500,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); @@ - > 508,7 +508,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); > } > @@ -593,8 +593,8 @@ void exfat_update_dir_chksum_with_entry_set(struct > exfat_entry_set_cache *es) > > for (i = 0; i < es->num_entries; i++) { > ep = exfat_get_dentry_cached(es, i); > - chksum = exfat_calc_chksum_2byte(ep, DENTRY_SIZE, chksum, > - chksum_type); > + chksum = exfat_calc_chksum16(ep, DENTRY_SIZE, chksum, > + chksum_type); > chksum_type = CS_DEFAULT; > } > ep = exfat_get_dentry_cached(es, 0); > @@ -1000,7 +1000,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 > eebbe5a84b2b..9188985694f0 100644 > --- a/fs/exfat/exfat_fs.h > +++ b/fs/exfat/exfat_fs.h > @@ -137,7 +137,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; > }; > > @@ -512,8 +512,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