linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Caleb D.S. Brzezinski" <calebdsb@protonmail.com>
To: hirofumi@mail.parknet.co.jp
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	"Caleb D.S. Brzezinski" <calebdsb@protonmail.com>
Subject: [PATCH 3/3] fat: add hash machinery to relevant filesystem operations
Date: Sun, 29 Aug 2021 14:25:42 +0000	[thread overview]
Message-ID: <20210829142459.56081-4-calebdsb@protonmail.com> (raw)
In-Reply-To: <20210829142459.56081-1-calebdsb@protonmail.com>

Add hash freeing functionality to the following functions which remove
or rename files:

msdos_rmdir()
msdos_unlink()
do_msdos_rename()

Whenever these functions are called, the memory associated with the
old, now obsolete filename is freed and dropped from the cache.

Signed-off-by: Caleb D.S. Brzezinski <calebdsb@protonmail.com>
---
 fs/fat/namei_msdos.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index f9d4f63c3..40a7d6df0 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -430,9 +430,11 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
 	struct super_block *sb = dir->i_sb;
 	struct inode *inode = d_inode(dentry);
 	struct fat_slot_info sinfo;
+	u64 hash;
 	int err;
 
 	mutex_lock(&MSDOS_SB(sb)->s_lock);
+	hash = msdos_fname_hash(dentry->d_name.name);
 	err = fat_dir_empty(inode);
 	if (err)
 		goto out;
@@ -448,6 +450,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
 	clear_nlink(inode);
 	fat_truncate_time(inode, NULL, S_CTIME);
 	fat_detach(inode);
+	drop_fname_from_cache(hash);
 out:
 	mutex_unlock(&MSDOS_SB(sb)->s_lock);
 	if (!err)
@@ -522,10 +525,12 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
 	struct inode *inode = d_inode(dentry);
 	struct super_block *sb = inode->i_sb;
 	struct fat_slot_info sinfo;
+	u64 hash;
 	int err;
 
 	mutex_lock(&MSDOS_SB(sb)->s_lock);
 	err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo);
+	hash = msdos_fname_hash(dentry->d_name.name);
 	if (err)
 		goto out;
 
@@ -535,6 +540,8 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
 	clear_nlink(inode);
 	fat_truncate_time(inode, NULL, S_CTIME);
 	fat_detach(inode);
+	drop_fname_from_cache(hash);
+
 out:
 	mutex_unlock(&MSDOS_SB(sb)->s_lock);
 	if (!err)
@@ -670,6 +677,8 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
 			drop_nlink(new_inode);
 		fat_truncate_time(new_inode, &ts, S_CTIME);
 	}
+	drop_fname_from_cache(msdos_fname_hash(old_name));
+
 out:
 	brelse(sinfo.bh);
 	brelse(dotdot_bh);
-- 
2.32.0



      parent reply	other threads:[~2021-08-29 14:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-29 14:25 [PATCH 0/3] fat: add a cache for msdos_format_name() Caleb D.S. Brzezinski
2021-08-29 14:25 ` [PATCH 1/3] fat: define functions and data structures for a formatted name cache Caleb D.S. Brzezinski
2021-08-29 21:05   ` kernel test robot
2021-08-29 21:05   ` [RFC PATCH] fat: msdos_ncache can be static kernel test robot
2021-08-29 14:25 ` [PATCH 2/3] fat: add the msdos_format_name() filename cache Caleb D.S. Brzezinski
2021-08-29 15:11   ` Al Viro
2021-08-29 15:26     ` Al Viro
2021-08-29 17:19       ` Caleb D.S. Brzezinski
2021-08-29 17:11     ` Caleb D.S. Brzezinski
2021-08-29 21:23       ` Al Viro
2021-08-29 14:25 ` Caleb D.S. Brzezinski [this message]

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=20210829142459.56081-4-calebdsb@protonmail.com \
    --to=calebdsb@protonmail.com \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).