All of lore.kernel.org
 help / color / mirror / Atom feed
From: yuezhang.mo@foxmail.com
To: linkinjeon@kernel.org, sj1557.seo@samsung.com
Cc: linux-fsdevel@vger.kernel.org, Andy.Wu@sony.com,
	wataru.aoyama@sony.com, Yuezhang Mo <Yuezhang.Mo@sony.com>
Subject: [PATCH v1 04/11] exfat: covert exfat_add_entry() to use dentry cache
Date: Fri,  8 Dec 2023 19:23:13 +0800	[thread overview]
Message-ID: <tencent_F1AF0B696AA71F537A8038A60088C6D8E906@qq.com> (raw)
In-Reply-To: <20231208112318.1135649-1-yuezhang.mo@foxmail.com>

From: Yuezhang Mo <Yuezhang.Mo@sony.com>

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>
---
 fs/exfat/dir.c      | 37 +++++++++----------------------------
 fs/exfat/exfat_fs.h |  6 +++---
 fs/exfat/namei.c    | 12 ++++++++++--
 3 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index bb23585c6e7c..a7eda14a57ac 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -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,
diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index 6dc76b3f4945..0897584d1473 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -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,
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 1f662296f2fa..423cd6d505ab 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -482,6 +482,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;
 
@@ -514,8 +516,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;
 
-- 
2.25.1


  parent reply	other threads:[~2023-12-08 11:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20231208112318.1135649-1-yuezhang.mo@foxmail.com>
2023-12-08 11:23 ` [PATCH v1 01/11] exfat: add __exfat_get_dentry_set() helper yuezhang.mo
2023-12-22  5:05   ` Namjae Jeon
2023-12-08 11:23 ` [PATCH v1 02/11] exfat: add exfat_get_empty_dentry_set() helper yuezhang.mo
2023-12-08 11:23 ` [PATCH v1 03/11] exfat: covert exfat_find_empty_entry() to use dentry cache yuezhang.mo
2023-12-08 11:23 ` yuezhang.mo [this message]
2023-12-08 11:23 ` [PATCH v1 05/11] exfat: covert exfat_remove_entries() " yuezhang.mo
2023-12-22  5:07   ` Namjae Jeon
2023-12-08 11:23 ` [PATCH v1 06/11] exfat: move free cluster out of exfat_init_ext_entry() yuezhang.mo
2023-12-08 11:23 ` [PATCH v1 07/11] exfat: covert exfat_init_ext_entry() to use dentry cache yuezhang.mo
2023-12-08 11:23 ` [PATCH v1 08/11] exfat: remove __exfat_find_empty_entry() yuezhang.mo
2023-12-22  5:07   ` Namjae Jeon
2023-12-08 11:23 ` [PATCH v1 09/11] exfat: remove unused functions yuezhang.mo
2023-12-08 11:23 ` [PATCH v1 10/11] exfat: do not sync parent dir if just update timestamp yuezhang.mo
2023-12-22  5:08   ` Namjae Jeon
2023-12-24 14:58     ` Yuezhang.Mo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_F1AF0B696AA71F537A8038A60088C6D8E906@qq.com \
    --to=yuezhang.mo@foxmail.com \
    --cc=Andy.Wu@sony.com \
    --cc=Yuezhang.Mo@sony.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=wataru.aoyama@sony.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.