From: Miklos Szeredi <mszeredi@redhat.com>
To: linux-unionfs@vger.kernel.org
Cc: Amir Goldstein <amir73il@gmail.com>, linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/4] ovl: get rid of iterate wrapper
Date: Thu, 7 Mar 2024 12:02:06 +0100 [thread overview]
Message-ID: <20240307110217.203064-2-mszeredi@redhat.com> (raw)
In-Reply-To: <20240307110217.203064-1-mszeredi@redhat.com>
Commit 3e3271549670 ("vfs: get rid of old '->iterate' directory operation")
added a wrapper around ovl_iterate() to lock the inode exclusive.
Use the overlayfs private inode lock instead to provide exclusive locking.
Add ovl_inode_lock()/_unlock() to ovl_iterate() and replace
inode_lock/_unlock() with the ovl_ variant in ovl_dir_llseek() and
ovl_dir_release().
This replacement is valid, because the inode lock was taken only to provide
exclusion between these functions (for other files referring to the same
inode).
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
fs/overlayfs/readdir.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index b894a97f8ef8..edee9f86f469 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -758,6 +758,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
if (!ctx->pos)
ovl_dir_reset(file);
+ ovl_inode_lock(file_inode(file));
if (od->is_real) {
/*
* If parent is merge, then need to adjust d_ino for '..', if
@@ -806,6 +807,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
}
err = 0;
out:
+ ovl_inode_unlock(file_inode(file));
revert_creds(old_cred);
return err;
}
@@ -815,7 +817,7 @@ static loff_t ovl_dir_llseek(struct file *file, loff_t offset, int origin)
loff_t res;
struct ovl_dir_file *od = file->private_data;
- inode_lock(file_inode(file));
+ ovl_inode_lock(file_inode(file));
if (!file->f_pos)
ovl_dir_reset(file);
@@ -845,7 +847,7 @@ static loff_t ovl_dir_llseek(struct file *file, loff_t offset, int origin)
res = offset;
}
out_unlock:
- inode_unlock(file_inode(file));
+ ovl_inode_unlock(file_inode(file));
return res;
}
@@ -929,9 +931,9 @@ static int ovl_dir_release(struct inode *inode, struct file *file)
struct ovl_dir_file *od = file->private_data;
if (od->cache) {
- inode_lock(inode);
+ ovl_inode_lock(inode);
ovl_cache_put(od, inode);
- inode_unlock(inode);
+ ovl_inode_unlock(inode);
}
fput(od->realfile);
if (od->upperfile)
@@ -966,11 +968,10 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
return 0;
}
-WRAP_DIR_ITER(ovl_iterate) // FIXME!
const struct file_operations ovl_dir_operations = {
.read = generic_read_dir,
.open = ovl_dir_open,
- .iterate_shared = shared_ovl_iterate,
+ .iterate_shared = ovl_iterate,
.llseek = ovl_dir_llseek,
.fsync = ovl_dir_fsync,
.release = ovl_dir_release,
--
2.44.0
next prev parent reply other threads:[~2024-03-07 11:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-07 11:02 [PATCH 1/4] ovl: use refcount_t in readdir Miklos Szeredi
2024-03-07 11:02 ` Miklos Szeredi [this message]
2024-03-07 11:02 ` [PATCH 3/4] ovl: only lock readdir for accessing the cache Miklos Szeredi
2024-03-07 13:11 ` Amir Goldstein
2024-03-07 14:09 ` Miklos Szeredi
2024-03-07 16:13 ` Miklos Szeredi
2024-03-07 17:31 ` Amir Goldstein
2024-03-11 13:52 ` Christian Brauner
2024-03-07 11:02 ` [PATCH 4/4] ovl: clean up struct ovl_dir_cache use outside readdir.c Miklos Szeredi
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=20240307110217.203064-2-mszeredi@redhat.com \
--to=mszeredi@redhat.com \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@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).