[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_C19E4D9448D8514A505A9FE439D01C333B08@qq.com>
Date: Fri, 5 Sep 2025 00:17:54 +0800
From: zhoumin <teczm@...mail.com>
To: hirofumi@...l.parknet.co.jp
Cc: linux-kernel@...r.kernel.org,
zhoumin <teczm@...mail.com>
Subject: [RFC PATCH] vfat:avoid unnecessary check
Remove redundant and unreachable name check code in dir.c.
Remove flags check in fat_update_time since fat does not support
inode version.
Optimize fat_truncate_time to return a meaningful value, allowing
the removal of redundant inode checks in fat_update_time. This
ensures non-root inodes are validated only once.
Signed-off-by: zhoumin <teczm@...mail.com>
---
fs/fat/dir.c | 12 ++++--------
fs/fat/misc.c | 11 ++++-------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index acbec5bdd521..4f1be9939292 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -337,11 +337,11 @@ static int fat_parse_long(struct inode *dir, loff_t *pos,
if (ds->alias_checksum != alias_checksum)
goto parse_long;
}
- if ((*de)->name[0] == DELETED_FLAG)
+ if (IS_FREE((*de)->name))
return PARSE_INVALID;
if ((*de)->attr == ATTR_EXT)
goto parse_long;
- if (IS_FREE((*de)->name) || ((*de)->attr & ATTR_VOLUME))
+ if ((*de)->attr & ATTR_VOLUME)
return PARSE_INVALID;
if (fat_checksum((*de)->name) != alias_checksum)
*nr_slots = 0;
@@ -491,12 +491,10 @@ int fat_search_long(struct inode *inode, const unsigned char *name,
goto end_of_dir;
parse_record:
nr_slots = 0;
- if (de->name[0] == DELETED_FLAG)
+ if (IS_FREE(de->name))
continue;
if (de->attr != ATTR_EXT && (de->attr & ATTR_VOLUME))
continue;
- if (de->attr != ATTR_EXT && IS_FREE(de->name))
- continue;
if (de->attr == ATTR_EXT) {
int status = fat_parse_long(inode, &cpos, &bh, &de,
&unicode, &nr_slots);
@@ -608,12 +606,10 @@ static int __fat_readdir(struct inode *inode, struct file *file,
* need to parse long filename.
*/
if (isvfat && !short_only) {
- if (de->name[0] == DELETED_FLAG)
+ if (IS_FREE(de->name))
goto record_end;
if (de->attr != ATTR_EXT && (de->attr & ATTR_VOLUME))
goto record_end;
- if (de->attr != ATTR_EXT && IS_FREE(de->name))
- goto record_end;
} else {
if ((de->attr & ATTR_VOLUME) || IS_FREE(de->name))
goto record_end;
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index c7a2d27120ba..41f6362a0428 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -335,7 +335,7 @@ int fat_truncate_time(struct inode *inode, struct timespec64 *now, int flags)
inode_set_mtime_to_ts(inode,
inode_set_ctime_to_ts(inode, fat_truncate_mtime(sbi, now)));
- return 0;
+ return 1;
}
EXPORT_SYMBOL_GPL(fat_truncate_time);
@@ -343,18 +343,15 @@ int fat_update_time(struct inode *inode, int flags)
{
int dirty_flags = 0;
- if (inode->i_ino == MSDOS_ROOT_INO)
- return 0;
-
- if (flags & (S_ATIME | S_CTIME | S_MTIME)) {
- fat_truncate_time(inode, NULL, flags);
+ if (fat_truncate_time(inode, NULL, flags)) {
if (inode->i_sb->s_flags & SB_LAZYTIME)
dirty_flags |= I_DIRTY_TIME;
else
dirty_flags |= I_DIRTY_SYNC;
+
+ __mark_inode_dirty(inode, dirty_flags);
}
- __mark_inode_dirty(inode, dirty_flags);
return 0;
}
EXPORT_SYMBOL_GPL(fat_update_time);
--
2.43.0
Powered by blists - more mailing lists