hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/exfat/namei.c
....@@ -398,7 +398,7 @@
398398 ei->i_size_ondisk += sbi->cluster_size;
399399 ei->i_size_aligned += sbi->cluster_size;
400400 ei->flags = p_dir->flags;
401
- inode->i_blocks += 1 << sbi->sect_per_clus_bits;
401
+ inode->i_blocks += sbi->cluster_size >> 9;
402402 }
403403
404404 return dentry;
....@@ -596,6 +596,8 @@
596596 struct exfat_inode_info *ei = EXFAT_I(dir);
597597 struct exfat_dentry *ep, *ep2;
598598 struct exfat_entry_set_cache *es;
599
+ /* for optimized dir & entry to prevent long traverse of cluster chain */
600
+ struct exfat_hint hint_opt;
599601
600602 if (qname->len == 0)
601603 return -ENOENT;
....@@ -619,7 +621,7 @@
619621
620622 /* search the file name for directories */
621623 dentry = exfat_find_dir_entry(sb, ei, &cdir, &uni_name,
622
- num_entries, TYPE_ALL);
624
+ num_entries, TYPE_ALL, &hint_opt);
623625
624626 if (dentry < 0)
625627 return dentry; /* -error value */
....@@ -628,6 +630,11 @@
628630 info->entry = dentry;
629631 info->num_subdirs = 0;
630632
633
+ /* adjust cdir to the optimized value */
634
+ cdir.dir = hint_opt.clu;
635
+ if (cdir.flags & ALLOC_NO_FAT_CHAIN)
636
+ cdir.size -= dentry / sbi->dentries_per_clu;
637
+ dentry = hint_opt.eidx;
631638 es = exfat_get_dentry_set(sb, &cdir, dentry, ES_2_ENTRIES);
632639 if (!es)
633640 return -EIO;