From patchwork Fri Sep 11 04:44:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuhiro Kohada X-Patchwork-Id: 11769775 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4164C618 for ; Fri, 11 Sep 2020 04:45:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A134221E8 for ; Fri, 11 Sep 2020 04:45:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P7fToiYe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725554AbgIKEou (ORCPT ); Fri, 11 Sep 2020 00:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgIKEot (ORCPT ); Fri, 11 Sep 2020 00:44:49 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F5F9C061573; Thu, 10 Sep 2020 21:44:49 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id s65so4668754pgb.0; Thu, 10 Sep 2020 21:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kWm/S620WXgqZ5OlNqBLrJgrguVAGDJTsBuFCVlofDA=; b=P7fToiYefyYMYr2wEI7bvLu/7Dj1aOdaq5zyCD96sqIsFaNjAlBokgzh0pmhkhpXCv m1Xjuca4vsr5NKr3rb3TMRrusUAOZKRHopYEipcg4aWy+nNwEdn0ZV3SjaTBk7z5FkZD EUaMitJUN2yOZvPCR1kM0dSiZ78j8OFTeo7EG/9ddwwnL429r3gohN0qSb1YKI85x226 XrUZMz96+6cv5CMh4fzGF0PWZ8xQr8i+lQbftZO2I+zt6Q909oR2qu/K6EIlIB0ctmXa LkqN5E7eq0/LBpgEfwzVZkIMu7g5ru+6LjT7FD6G7DePHPc2pnYNhPzKtjry/1Ej/Oo1 NOEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kWm/S620WXgqZ5OlNqBLrJgrguVAGDJTsBuFCVlofDA=; b=mgv8Fkcy9PyTVDXLdY/ByqmG1Zpc/o0xYaK2NWqjo0VRLQnV6sh2bDqCsxLBQ1bsbt 8LFNNiiwiTdYW8IfStAokrciK76Op8Py2QsIzMv0RISwPT/qas4o97iVGisQ8xxp3Pda USE8t3PG74YLiVwAfEFd87gTlS2epr6NhJLgpQ1OXkdnAq18sxgEmNPRvG2k1Qg64s2D OFI3uD/WxYFGcmF7Iz3aBzV7H7VhIy1ZP/BD+Q4581gWuHD/tqphnsTKiiZ6VW0KxPcM IcvvSD809I/PKa/UR7WKSeyP4Gk2GOyk6aD+uCCTnsIe3ISXCrIsWMm/JtjKzl/czprA F5SQ== X-Gm-Message-State: AOAM531A+XgRYnrioyQ8uISVFbZWunlPnXMGi9mx8bEviwV86EwhBfi1 sSaHEWSOMa8XMRYnI2ijbxQ= X-Google-Smtp-Source: ABdhPJwuMu8YaSDV6HeMSDu1k8le5fQ7WGWNcwr2m64v8GzyWCvq2VgJnCP8Y5Vmjgw2wnWl7G/A9w== X-Received: by 2002:a65:408b:: with SMTP id t11mr345723pgp.199.1599799486692; Thu, 10 Sep 2020 21:44:46 -0700 (PDT) Received: from dc803.localdomain (FL1-111-169-191-163.hyg.mesh.ad.jp. [111.169.191.163]) by smtp.gmail.com with ESMTPSA id y4sm546575pgl.67.2020.09.10.21.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 21:44:46 -0700 (PDT) From: Tetsuhiro Kohada To: kohada.t2@gmail.com Cc: kohada.tetsuhiro@dc.mitsubishielectric.co.jp, mori.takahiro@ab.mitsubishielectric.co.jp, motai.hirotaka@aj.mitsubishielectric.co.jp, Namjae Jeon , Sungjong Seo , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] exfat: remove useless directory scan in exfat_add_entry() Date: Fri, 11 Sep 2020 13:44:39 +0900 Message-Id: <20200911044439.13842-1-kohada.t2@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org There is nothing in directory just created, so there is no need to scan. Signed-off-by: Tetsuhiro Kohada Acked-by: Sungjong Seo --- fs/exfat/namei.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index b966b9120c9c..803748946ddb 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -530,19 +530,10 @@ static int exfat_add_entry(struct inode *inode, const char *path, info->size = 0; info->num_subdirs = 0; } else { - int count; - struct exfat_chain cdir; - info->attr = ATTR_SUBDIR; info->start_clu = start_clu; info->size = clu_size; - - exfat_chain_set(&cdir, info->start_clu, - EXFAT_B_TO_CLU(info->size, sbi), info->flags); - count = exfat_count_dir_entries(sb, &cdir); - if (count < 0) - return -EIO; - info->num_subdirs = count + EXFAT_MIN_SUBDIR; + info->num_subdirs = EXFAT_MIN_SUBDIR; } memset(&info->crtime, 0, sizeof(info->crtime)); memset(&info->mtime, 0, sizeof(info->mtime)); From patchwork Fri Sep 11 04:45:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuhiro Kohada X-Patchwork-Id: 11769777 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDCE859D for ; Fri, 11 Sep 2020 04:45:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1F75221E8 for ; Fri, 11 Sep 2020 04:45:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mWUO7v67" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725771AbgIKEpM (ORCPT ); Fri, 11 Sep 2020 00:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgIKEpJ (ORCPT ); Fri, 11 Sep 2020 00:45:09 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BEDBC061573; Thu, 10 Sep 2020 21:45:09 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id fa1so1114179pjb.0; Thu, 10 Sep 2020 21:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GkavzkycfND+4vCO4VeMuzt7qDfojSlqnl/vJMxoJ74=; b=mWUO7v67Y6xXVzWk3lUJ0Xc+U+hXxP+LiKgr8S1C8lYRYvLawsv+HwfKW+PdYa7Xr8 4FZCpEW60nNVlSfjBdEAnRwSL6d7BLOG5IxOdEcPVGja0R2vdlGQDexqU4+cnW0tXnAC 4piV8hlet/mzc1ubJJGbUratt+qr6+m8/FL233KLhzFRt9dnjw/m0LFz3MDPp0FYJ2UI e6RPJXhD9IToMJ9YGEmFzaZB9RudhES4UCrXDMQFTXekCHnJgjZvpibJLBVE42BGA0dT yQp+x4Z0dbE4fh5SG1UxqkI94n5Wn/p8Bh1s1bCptn1pAAZSr2GS5f+wjLQmBW9qVze7 6MRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GkavzkycfND+4vCO4VeMuzt7qDfojSlqnl/vJMxoJ74=; b=ZtY7jCc6Px1HBNfJIeWgA8mMRbH8xQFzSVZy9eaqTt043IZwZ3uWrxRRjS40FCYax6 NA1lZpsOnvDTYdsvOm3nleZsShYl415VgllvCojJYY+gEws+ONjIPwir1gfNmeK/GiwN 9on9qH6vM4KuC7iPA9/0XyiHEjQSLEY8HMscYDBy46hqyV0eUpo3GkpE3CjacXC0U7G2 Ic8K79/BDbyknSNE7K+WUWACZT5pS60//yoM7D5hG1vPel70xvQ2bVcfylFjcS58jghK tVoM2kZEDOD+dsThPfpMNexLQtMK2dvJ7fQGniDPZZQfqD0w32LO0zTcqfAqBiY1gZUj 5shA== X-Gm-Message-State: AOAM531OesXk9BIkGaNoHEzZjGSOcN4pefDZqqWMBQFozbHrFOByTpNy 3Guvz4rlr9hB1Y0+hmTZPdRujA10aTI= X-Google-Smtp-Source: ABdhPJwrP7C4ZNKEuVVFvnL2lUjp5HzDw0xYe6dftWod5cniZ2dUxjHLK5uCNxid9TR/kz30soFbhQ== X-Received: by 2002:a17:90a:104f:: with SMTP id y15mr523800pjd.45.1599799508685; Thu, 10 Sep 2020 21:45:08 -0700 (PDT) Received: from dc803.localdomain (FL1-111-169-191-163.hyg.mesh.ad.jp. [111.169.191.163]) by smtp.gmail.com with ESMTPSA id a23sm543817pgv.86.2020.09.10.21.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 21:45:08 -0700 (PDT) From: Tetsuhiro Kohada To: kohada.t2@gmail.com Cc: kohada.tetsuhiro@dc.mitsubishielectric.co.jp, mori.takahiro@ab.mitsubishielectric.co.jp, motai.hirotaka@aj.mitsubishielectric.co.jp, Namjae Jeon , Sungjong Seo , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] exfat: remove useless check in exfat_move_file() Date: Fri, 11 Sep 2020 13:45:06 +0900 Message-Id: <20200911044506.13912-1-kohada.t2@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In exfat_move_file(), the identity of source and target directory has been checked by the caller. Also, it gets stream.start_clu from file dir-entry, which is an invalid determination. Signed-off-by: Tetsuhiro Kohada Acked-by: Sungjong Seo --- fs/exfat/namei.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 803748946ddb..1c433491f771 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1095,11 +1095,6 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (!epmov) return -EIO; - /* check if the source and target directory is the same */ - if (exfat_get_entry_type(epmov) == TYPE_DIR && - le32_to_cpu(epmov->dentry.stream.start_clu) == p_newdir->dir) - return -EINVAL; - num_old_entries = exfat_count_ext_entries(sb, p_olddir, oldentry, epmov); if (num_old_entries < 0) From patchwork Fri Sep 11 04:45:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuhiro Kohada X-Patchwork-Id: 11769779 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68F5D618 for ; Fri, 11 Sep 2020 04:45:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D194221E7 for ; Fri, 11 Sep 2020 04:45:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UKgoh20y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725781AbgIKEp1 (ORCPT ); Fri, 11 Sep 2020 00:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgIKEpW (ORCPT ); Fri, 11 Sep 2020 00:45:22 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C801C061573; Thu, 10 Sep 2020 21:45:22 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 5so5744251pgl.4; Thu, 10 Sep 2020 21:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kQXurXm25NcMdooLPinVDFaLX3POiP/2UA+AXolV4yc=; b=UKgoh20yKZuTLAUbo6VldhPrQS2MUUY/nZO1Asco/BpA9BEemrd2k/rIMjdoa5jcln M1cmb4XzqPAzwFFZX9+ls7TbrO21FGcWe1aoXkU72mIXhHRvUJzzeuBojwEFFWuznMEi dYUxoPAU2oXBjssctog8vGnqIHNl7sDVe9a+cmNYmTbsJCXQLueLnZ0/qmTMYrfCLZwK XqgUviSApk6faA6BgOnEn+HWI7Cd9TmeXvjSNbd93wcgFKFXJL91rBP1pFWHoGGzTYU0 Fe37kPqLkicnLHzlKxeh5gCR/Y9aGB2QfJHoJgUWCEHoSD8imdrI8vSDlC1JRFUnQZBF 8c3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kQXurXm25NcMdooLPinVDFaLX3POiP/2UA+AXolV4yc=; b=arqSivd6D3+Mp1rh5XgDG7HLqoG+TCT6Qap7saszydH5TPN5IEDguqe3TGfyEgJqKr Ma4CHj/SjxsZrnB49Bi7Ovs+dmv/s2G0hijZLyCQ7T/jfHRDgE3r7TM9VKFXjhTlOmX2 lhzB5mMPT4i0E+3pRpQPF3Y+6ynERcEB/QLKMwynMNSndtvpwzLGu5xAx4GCsiLrQL/L irHXMXpsvzN+KNywA53EX/UhYJkQhegvvPGYIZWB+4LOs6xkkvTVP4+vDkzKNXVaVGpy GEtmke6xFQ3ekG6LfEy55YrauL/jqrVsIyLwwc0LXZL1fF29oqWlsXKC4rzpviCwKvqU KGnQ== X-Gm-Message-State: AOAM530ZlC3AJlcPbIVZwuMAOAoI3EM/HdoWqD5R4P32ovmHZOmKzEQj 7upz17EdzhFFN4V42T6EveA= X-Google-Smtp-Source: ABdhPJzzV5lffR+vPrMujphlYhlkb9LBp2YGU+ySLGarl897dMDenR5zsbyZ8mjJayf/fRLMukQWIQ== X-Received: by 2002:a17:902:7049:b029:d0:cbe1:e778 with SMTP id h9-20020a1709027049b02900d0cbe1e778mr542008plt.31.1599799522111; Thu, 10 Sep 2020 21:45:22 -0700 (PDT) Received: from dc803.localdomain (FL1-111-169-191-163.hyg.mesh.ad.jp. [111.169.191.163]) by smtp.gmail.com with ESMTPSA id z1sm572764pjn.34.2020.09.10.21.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 21:45:21 -0700 (PDT) From: Tetsuhiro Kohada To: kohada.t2@gmail.com Cc: kohada.tetsuhiro@dc.mitsubishielectric.co.jp, mori.takahiro@ab.mitsubishielectric.co.jp, motai.hirotaka@aj.mitsubishielectric.co.jp, Namjae Jeon , Sungjong Seo , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] exfat: replace memcpy with structure assignment Date: Fri, 11 Sep 2020 13:45:19 +0900 Message-Id: <20200911044519.13981-1-kohada.t2@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Use structure assignment instead of memcpy. Signed-off-by: Tetsuhiro Kohada Acked-by: Sungjong Seo --- fs/exfat/dir.c | 7 ++----- fs/exfat/inode.c | 2 +- fs/exfat/namei.c | 15 +++++++-------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index fa5bb72aa295..8520decd120c 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -974,11 +974,8 @@ int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei, if (ei->hint_femp.eidx == EXFAT_HINT_NONE || candi_empty.eidx <= - ei->hint_femp.eidx) { - memcpy(&ei->hint_femp, - &candi_empty, - sizeof(candi_empty)); - } + ei->hint_femp.eidx) + ei->hint_femp = candi_empty; } brelse(bh); diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c index 70a33d4807c3..687f77653187 100644 --- a/fs/exfat/inode.c +++ b/fs/exfat/inode.c @@ -554,7 +554,7 @@ static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info) struct exfat_inode_info *ei = EXFAT_I(inode); loff_t size = info->size; - memcpy(&ei->dir, &info->dir, sizeof(struct exfat_chain)); + ei->dir = info->dir; ei->entry = info->entry; ei->attr = info->attr; ei->start_clu = info->start_clu; diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 1c433491f771..2932b23a3b6c 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -318,8 +318,7 @@ static int exfat_find_empty_entry(struct inode *inode, hint_femp.eidx = EXFAT_HINT_NONE; if (ei->hint_femp.eidx != EXFAT_HINT_NONE) { - memcpy(&hint_femp, &ei->hint_femp, - sizeof(struct exfat_hint_femp)); + hint_femp = ei->hint_femp; ei->hint_femp.eidx = EXFAT_HINT_NONE; } @@ -519,7 +518,7 @@ static int exfat_add_entry(struct inode *inode, const char *path, if (ret) goto out; - memcpy(&info->dir, p_dir, sizeof(struct exfat_chain)); + info->dir = *p_dir; info->entry = dentry; info->flags = ALLOC_NO_FAT_CHAIN; info->type = type; @@ -625,7 +624,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname, if (dentry < 0) return dentry; /* -error value */ - memcpy(&info->dir, &cdir.dir, sizeof(struct exfat_chain)); + info->dir = cdir; info->entry = dentry; info->num_subdirs = 0; @@ -1030,7 +1029,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, if (!epnew) return -EIO; - memcpy(epnew, epold, DENTRY_SIZE); + *epnew = *epold; if (exfat_get_entry_type(epnew) == TYPE_FILE) { epnew->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE); ei->attr |= ATTR_ARCHIVE; @@ -1050,7 +1049,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, return -EIO; } - memcpy(epnew, epold, DENTRY_SIZE); + *epnew = *epold; exfat_update_bh(new_bh, sync); brelse(old_bh); brelse(new_bh); @@ -1113,7 +1112,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, if (!epnew) return -EIO; - memcpy(epnew, epmov, DENTRY_SIZE); + *epnew = *epmov; if (exfat_get_entry_type(epnew) == TYPE_FILE) { epnew->dentry.file.attr |= cpu_to_le16(ATTR_ARCHIVE); ei->attr |= ATTR_ARCHIVE; @@ -1133,7 +1132,7 @@ static int exfat_move_file(struct inode *inode, struct exfat_chain *p_olddir, return -EIO; } - memcpy(epnew, epmov, DENTRY_SIZE); + *epnew = *epmov; exfat_update_bh(new_bh, IS_DIRSYNC(inode)); brelse(mov_bh); brelse(new_bh);