From: Paulo Alcantara <pc@manguebit.com>
To: smfrench@gmail.com
Cc: linux-cifs@vger.kernel.org, Paulo Alcantara <pc@manguebit.com>
Subject: [PATCH v2 8/9] smb: client: optimise dentry revalidation for reparse points
Date: Sat, 25 Nov 2023 23:55:09 -0300 [thread overview]
Message-ID: <20231126025510.28147-9-pc@manguebit.com> (raw)
In-Reply-To: <20231126025510.28147-1-pc@manguebit.com>
If the positive dentry is known to be a reparse point already, save a
roundtrip in smb2_query_path_info() and smb311_posix_query_path_info()
by sending compound request with OPEN_REPARSE_POINT.
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
---
fs/smb/client/inode.c | 15 +++++++++++----
fs/smb/client/smb2inode.c | 11 ++++++++---
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 111e60e5e260..d7d19cdb3c8c 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -1142,6 +1142,8 @@ static int cifs_get_fattr(struct cifs_open_info_data *data,
*/
if (!data) {
+ if (*inode && CIFS_I(*inode)->reparse)
+ tmp_data.reparse_point = true;
rc = server->ops->query_path_info(xid, tcon, cifs_sb,
full_path, &tmp_data);
data = &tmp_data;
@@ -1301,6 +1303,7 @@ int cifs_get_inode_info(struct inode **inode,
static int smb311_posix_get_fattr(struct cifs_open_info_data *data,
struct cifs_fattr *fattr,
+ struct inode **inode,
const char *full_path,
struct super_block *sb,
const unsigned int xid)
@@ -1322,6 +1325,8 @@ static int smb311_posix_get_fattr(struct cifs_open_info_data *data,
* 1. Fetch file metadata if not provided (data)
*/
if (!data) {
+ if (*inode && CIFS_I(*inode)->reparse)
+ tmp_data.reparse_point = true;
rc = smb311_posix_query_path_info(xid, tcon, cifs_sb,
full_path, &tmp_data,
&owner, &group);
@@ -1390,7 +1395,7 @@ int smb311_posix_get_inode_info(struct inode **inode,
return 0;
}
- rc = smb311_posix_get_fattr(data, &fattr, full_path, sb, xid);
+ rc = smb311_posix_get_fattr(data, &fattr, inode, full_path, sb, xid);
if (rc)
goto out;
@@ -1537,10 +1542,12 @@ struct inode *cifs_root_iget(struct super_block *sb)
}
convert_delimiter(path, CIFS_DIR_SEP(cifs_sb));
- if (tcon->posix_extensions)
- rc = smb311_posix_get_fattr(NULL, &fattr, path, sb, xid);
- else
+ if (tcon->posix_extensions) {
+ rc = smb311_posix_get_fattr(NULL, &fattr, &inode,
+ path, sb, xid);
+ } else {
rc = cifs_get_fattr(NULL, sb, xid, NULL, &fattr, &inode, path);
+ }
iget_root:
if (!rc) {
diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index 3e8ba41b790d..9d1b043b8356 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -667,7 +667,6 @@ int smb2_query_path_info(const unsigned int xid,
int rc, rc2;
data->adjust_tz = false;
- data->reparse_point = false;
if (strcmp(full_path, ""))
rc = -ENOENT;
@@ -689,6 +688,9 @@ int smb2_query_path_info(const unsigned int xid,
in_iov[0].iov_len = sizeof(*data);
in_iov[1] = in_iov[0];
+ if (data->reparse_point)
+ goto open_reparse;
+
cifs_get_readable_path(tcon, full_path, &cfile);
rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
FILE_READ_ATTRIBUTES, FILE_OPEN,
@@ -714,6 +716,7 @@ int smb2_query_path_info(const unsigned int xid,
/* symlink already parsed in create response */
num_cmds = 1;
} else {
+open_reparse:
cmds[1] = SMB2_OP_GET_REPARSE;
num_cmds = 2;
}
@@ -766,8 +769,6 @@ int smb311_posix_query_path_info(const unsigned int xid,
int i, num_cmds;
data->adjust_tz = false;
- data->reparse_point = false;
-
/*
* BB TODO: Add support for using the cached root handle.
* Create SMB2_query_posix_info worker function to do non-compounded query
@@ -778,6 +779,9 @@ int smb311_posix_query_path_info(const unsigned int xid,
in_iov[0].iov_len = sizeof(*data);
in_iov[1] = in_iov[0];
+ if (data->reparse_point)
+ goto open_reparse;
+
cifs_get_readable_path(tcon, full_path, &cfile);
rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
FILE_READ_ATTRIBUTES, FILE_OPEN,
@@ -802,6 +806,7 @@ int smb311_posix_query_path_info(const unsigned int xid,
/* symlink already parsed in create response */
num_cmds = 1;
} else {
+open_reparse:
cmds[1] = SMB2_OP_GET_REPARSE;
num_cmds = 2;
}
--
2.43.0
next prev parent reply other threads:[~2023-11-26 2:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-26 2:55 [PATCH v2 0/9] reparse points work Paulo Alcantara
2023-11-26 2:55 ` [PATCH v2 1/9] smb: client: extend smb2_compound_op() to accept more commands Paulo Alcantara
2023-11-26 2:55 ` [PATCH v2 2/9] smb: client: allow creating special files via reparse points Paulo Alcantara
2023-11-26 2:55 ` [PATCH v2 3/9] smb: client: allow creating symlinks " Paulo Alcantara
2023-11-26 2:55 ` [PATCH v2 4/9] smb: client: optimise reparse point querying Paulo Alcantara
2023-11-26 2:55 ` [PATCH v2 5/9] smb: client: fix renaming of reparse points Paulo Alcantara
2023-11-26 2:55 ` [PATCH v2 6/9] smb: client: fix hardlinking " Paulo Alcantara
2023-11-26 2:55 ` [PATCH v2 7/9] smb: client: cleanup smb2_query_reparse_point() Paulo Alcantara
2023-11-26 2:55 ` Paulo Alcantara [this message]
2023-11-26 2:55 ` [PATCH v2 9/9] smb: client: fix missing mode bits for SMB symlinks Paulo Alcantara
2023-11-27 4:28 ` [PATCH v2 0/9] reparse points work Steve French
2023-11-27 10:14 ` Paulo Alcantara
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=20231126025510.28147-9-pc@manguebit.com \
--to=pc@manguebit.com \
--cc=linux-cifs@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox