Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit cf8663f

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: convert exfat_add_entry() to use dentry cache
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 <[email protected]> Reviewed-by: Andy Wu <[email protected]> Reviewed-by: Aoyama Wataru <[email protected]> Reviewed-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 01da3a5 commit cf8663f

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

fs/exfat/dir.c

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -448,53 +448,34 @@ static void exfat_init_name_entry(struct exfat_dentry *ep,
448448
}
449449
}
450450

451-
int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
452-
int entry, unsigned int type, unsigned int start_clu,
453-
unsigned long long size)
451+
void exfat_init_dir_entry(struct exfat_entry_set_cache *es,
452+
unsigned int type, unsigned int start_clu,
453+
unsigned long long size, struct timespec64 *ts)
454454
{
455-
struct super_block *sb = inode->i_sb;
455+
struct super_block *sb = es->sb;
456456
struct exfat_sb_info *sbi = EXFAT_SB(sb);
457-
struct timespec64 ts = current_time(inode);
458457
struct exfat_dentry *ep;
459-
struct buffer_head *bh;
460-
461-
/*
462-
* We cannot use exfat_get_dentry_set here because file ep is not
463-
* initialized yet.
464-
*/
465-
ep = exfat_get_dentry(sb, p_dir, entry, &bh);
466-
if (!ep)
467-
return -EIO;
468458

459+
ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
469460
exfat_set_entry_type(ep, type);
470-
exfat_set_entry_time(sbi, &ts,
461+
exfat_set_entry_time(sbi, ts,
471462
&ep->dentry.file.create_tz,
472463
&ep->dentry.file.create_time,
473464
&ep->dentry.file.create_date,
474465
&ep->dentry.file.create_time_cs);
475-
exfat_set_entry_time(sbi, &ts,
466+
exfat_set_entry_time(sbi, ts,
476467
&ep->dentry.file.modify_tz,
477468
&ep->dentry.file.modify_time,
478469
&ep->dentry.file.modify_date,
479470
&ep->dentry.file.modify_time_cs);
480-
exfat_set_entry_time(sbi, &ts,
471+
exfat_set_entry_time(sbi, ts,
481472
&ep->dentry.file.access_tz,
482473
&ep->dentry.file.access_time,
483474
&ep->dentry.file.access_date,
484475
NULL);
485476

486-
exfat_update_bh(bh, IS_DIRSYNC(inode));
487-
brelse(bh);
488-
489-
ep = exfat_get_dentry(sb, p_dir, entry + 1, &bh);
490-
if (!ep)
491-
return -EIO;
492-
477+
ep = exfat_get_dentry_cached(es, ES_IDX_STREAM);
493478
exfat_init_stream_entry(ep, start_clu, size);
494-
exfat_update_bh(bh, IS_DIRSYNC(inode));
495-
brelse(bh);
496-
497-
return 0;
498479
}
499480

500481
int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir,

fs/exfat/exfat_fs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,9 @@ int exfat_get_cluster(struct inode *inode, unsigned int cluster,
480480
extern const struct inode_operations exfat_dir_inode_operations;
481481
extern const struct file_operations exfat_dir_operations;
482482
unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry);
483-
int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
484-
int entry, unsigned int type, unsigned int start_clu,
485-
unsigned long long size);
483+
void exfat_init_dir_entry(struct exfat_entry_set_cache *es,
484+
unsigned int type, unsigned int start_clu,
485+
unsigned long long size, struct timespec64 *ts);
486486
int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
487487
int entry, int num_entries, struct exfat_uni_name *p_uniname);
488488
int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir,

fs/exfat/namei.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ static int exfat_add_entry(struct inode *inode, const char *path,
499499
struct exfat_sb_info *sbi = EXFAT_SB(sb);
500500
struct exfat_uni_name uniname;
501501
struct exfat_chain clu;
502+
struct timespec64 ts = current_time(inode);
503+
struct exfat_entry_set_cache es;
502504
int clu_size = 0;
503505
unsigned int start_clu = EXFAT_FREE_CLUSTER;
504506

@@ -531,8 +533,14 @@ static int exfat_add_entry(struct inode *inode, const char *path,
531533
/* fill the dos name directory entry information of the created file.
532534
* the first cluster is not determined yet. (0)
533535
*/
534-
ret = exfat_init_dir_entry(inode, p_dir, dentry, type,
535-
start_clu, clu_size);
536+
537+
ret = exfat_get_empty_dentry_set(&es, sb, p_dir, dentry, num_entries);
538+
if (ret)
539+
goto out;
540+
541+
exfat_init_dir_entry(&es, type, start_clu, clu_size, &ts);
542+
543+
ret = exfat_put_dentry_set(&es, IS_DIRSYNC(inode));
536544
if (ret)
537545
goto out;
538546

0 commit comments

Comments
 (0)