From: Paulo Alcantara <pc@cjr.nz>
To: Ronnie Sahlberg <lsahlber@redhat.com>,
linux-cifs <linux-cifs@vger.kernel.org>
Cc: Steve French <smfrench@gmail.com>
Subject: Re: [PATCH] cifs: cache dirent names for cached directories
Date: Tue, 03 May 2022 20:55:40 -0300 [thread overview]
Message-ID: <87bkwe2mtf.fsf@cjr.nz> (raw)
In-Reply-To: <20220503070959.2276616-2-lsahlber@redhat.com>
Hi Ronnie,
Ronnie Sahlberg <lsahlber@redhat.com> writes:
> diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
> index 1929e80c09ee..8b3fbe6b3580 100644
> --- a/fs/cifs/readdir.c
> +++ b/fs/cifs/readdir.c
> @@ -840,9 +840,112 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,
> return rc;
> }
>
> +static bool emit_cached_dirents(struct cached_dirents *cde,
> + struct dir_context *ctx)
> +{
> + struct list_head *tmp;
> + struct cached_dirent *dirent;
> + int rc;
> +
> + list_for_each(tmp, &cde->entries) {
> + dirent = list_entry(tmp, struct cached_dirent, entry);
What about list_for_each_entry()?
> +static void add_cached_dirent(struct cached_dirents *cde,
> + struct dir_context *ctx,
> + const char *name, int namelen,
> + struct cifs_fattr *fattr)
> +{
> + struct cached_dirent *de;
> +
> + if (cde->ctx != ctx)
> + return;
> + if (cde->is_valid || cde->is_failed)
> + return;
> + if (ctx->pos != cde->pos) {
> + cde->is_failed = 1;
> + return;
> + }
> + de = kzalloc(sizeof(*de), GFP_ATOMIC);
> + if (de == NULL) {
> + cde->is_failed = 1;
> + return;
> + }
> + de->name = kzalloc(namelen + 1, GFP_ATOMIC);
> + if (de->name == NULL) {
> + kfree(de);
> + cde->is_failed = 1;
> + return;
> + }
> + memcpy(de->name, name, namelen);
Replace the above kzalloc() & memcpy() with kstrndup()?
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index d6aaeff4a30a..10170266f44b 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -699,6 +699,8 @@ smb2_close_cached_fid(struct kref *ref)
> {
> struct cached_fid *cfid = container_of(ref, struct cached_fid,
> refcount);
> + struct list_head *pos, *q;
> + struct cached_dirent *dirent;
>
> if (cfid->is_valid) {
> cifs_dbg(FYI, "clear cached root file handle\n");
> @@ -718,6 +720,21 @@ smb2_close_cached_fid(struct kref *ref)
> dput(cfid->dentry);
> cfid->dentry = NULL;
> }
> + /*
> + * Delete all cached dirent names
> + */
> + mutex_lock(&cfid->dirents.de_mutex);
> + list_for_each_safe(pos, q, &cfid->dirents.entries) {
> + dirent = list_entry(pos, struct cached_dirent, entry);
list_for_each_entry_safe()?
Nice job! Looks good to me,
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
next prev parent reply other threads:[~2022-05-03 23:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-03 7:09 Patch to add caching od directory entries for the cache dir Ronnie Sahlberg
2022-05-03 7:09 ` [PATCH] cifs: cache dirent names for cached directories Ronnie Sahlberg
2022-05-03 7:19 ` Steve French
2022-05-03 23:55 ` Paulo Alcantara [this message]
2022-05-04 1:44 ` ronnie sahlberg
-- strict thread matches above, loose matches on Subject: below --
2022-05-04 1:44 cache dirent names for the cached directory while we hold a lease Ronnie Sahlberg
2022-05-04 1:44 ` [PATCH] cifs: cache dirent names for cached directories Ronnie Sahlberg
2022-05-04 1:55 ` Paulo Alcantara
2022-05-04 16:54 ` Enzo Matsumiya
2022-05-09 23:33 ` ronnie sahlberg
2022-05-10 0:01 ` ronnie sahlberg
2022-05-04 18:27 ` Enzo Matsumiya
2022-05-04 22:12 ` Leif Sahlberg
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=87bkwe2mtf.fsf@cjr.nz \
--to=pc@cjr.nz \
--cc=linux-cifs@vger.kernel.org \
--cc=lsahlber@redhat.com \
--cc=smfrench@gmail.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.