]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
exfat: convert exfat_add_entry() to use dentry cache
authorYuezhang Mo <Yuezhang.Mo@sony.com>
Thu, 4 Aug 2022 08:01:50 +0000 (16:01 +0800)
committerNamjae Jeon <linkinjeon@kernel.org>
Tue, 19 Mar 2024 11:55:36 +0000 (20:55 +0900)
After this conversion, if "dirsync" or "sync" is enabled, the
number of synchronized dentries in exfat_add_entry() will change
from 2 to 1.

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Andy Wu <Andy.Wu@sony.com>
Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/exfat/dir.c
fs/exfat/exfat_fs.h
fs/exfat/namei.c

index e228cdfcc9c933162321f200de6e4b660ce5248d..0065d2abc9832706ab635a686ca91250e894e26b 100644 (file)
@@ -448,53 +448,34 @@ static void exfat_init_name_entry(struct exfat_dentry *ep,
        }
 }
 
-int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
-               int entry, unsigned int type, unsigned int start_clu,
-               unsigned long long size)
+void exfat_init_dir_entry(struct exfat_entry_set_cache *es,
+               unsigned int type, unsigned int start_clu,
+               unsigned long long size, struct timespec64 *ts)
 {
-       struct super_block *sb = inode->i_sb;
+       struct super_block *sb = es->sb;
        struct exfat_sb_info *sbi = EXFAT_SB(sb);
-       struct timespec64 ts = current_time(inode);
        struct exfat_dentry *ep;
-       struct buffer_head *bh;
-
-       /*
-        * We cannot use exfat_get_dentry_set here because file ep is not
-        * initialized yet.
-        */
-       ep = exfat_get_dentry(sb, p_dir, entry, &bh);
-       if (!ep)
-               return -EIO;
 
+       ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
        exfat_set_entry_type(ep, type);
-       exfat_set_entry_time(sbi, &ts,
+       exfat_set_entry_time(sbi, ts,
                        &ep->dentry.file.create_tz,
                        &ep->dentry.file.create_time,
                        &ep->dentry.file.create_date,
                        &ep->dentry.file.create_time_cs);
-       exfat_set_entry_time(sbi, &ts,
+       exfat_set_entry_time(sbi, ts,
                        &ep->dentry.file.modify_tz,
                        &ep->dentry.file.modify_time,
                        &ep->dentry.file.modify_date,
                        &ep->dentry.file.modify_time_cs);
-       exfat_set_entry_time(sbi, &ts,
+       exfat_set_entry_time(sbi, ts,
                        &ep->dentry.file.access_tz,
                        &ep->dentry.file.access_time,
                        &ep->dentry.file.access_date,
                        NULL);
 
-       exfat_update_bh(bh, IS_DIRSYNC(inode));
-       brelse(bh);
-
-       ep = exfat_get_dentry(sb, p_dir, entry + 1, &bh);
-       if (!ep)
-               return -EIO;
-
+       ep = exfat_get_dentry_cached(es, ES_IDX_STREAM);
        exfat_init_stream_entry(ep, start_clu, size);
-       exfat_update_bh(bh, IS_DIRSYNC(inode));
-       brelse(bh);
-
-       return 0;
 }
 
 int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir,
index c6f684bf7b9214421103b65cd72e53450c76e421..ecc5f6a3ad875fe04ee9a6b89819b3566f4f6427 100644 (file)
@@ -480,9 +480,9 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
 extern const struct inode_operations exfat_dir_inode_operations;
 extern const struct file_operations exfat_dir_operations;
 unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry);
-int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
-               int entry, unsigned int type, unsigned int start_clu,
-               unsigned long long size);
+void exfat_init_dir_entry(struct exfat_entry_set_cache *es,
+               unsigned int type, unsigned int start_clu,
+               unsigned long long size, struct timespec64 *ts);
 int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
                int entry, int num_entries, struct exfat_uni_name *p_uniname);
 int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir,
index 9c549fd11fc847055a35f7a5872dc044b1576796..07506f3882bb2ee886f02959f385375f9563628d 100644 (file)
@@ -499,6 +499,8 @@ static int exfat_add_entry(struct inode *inode, const char *path,
        struct exfat_sb_info *sbi = EXFAT_SB(sb);
        struct exfat_uni_name uniname;
        struct exfat_chain clu;
+       struct timespec64 ts = current_time(inode);
+       struct exfat_entry_set_cache es;
        int clu_size = 0;
        unsigned int start_clu = EXFAT_FREE_CLUSTER;
 
@@ -531,8 +533,14 @@ static int exfat_add_entry(struct inode *inode, const char *path,
        /* fill the dos name directory entry information of the created file.
         * the first cluster is not determined yet. (0)
         */
-       ret = exfat_init_dir_entry(inode, p_dir, dentry, type,
-               start_clu, clu_size);
+
+       ret = exfat_get_empty_dentry_set(&es, sb, p_dir, dentry, num_entries);
+       if (ret)
+               goto out;
+
+       exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts);
+
+       ret = exfat_put_dentry_set(&es, IS_DIRSYNC(inode));
        if (ret)
                goto out;