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@xxxxxxxxxxxxx> --- 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