Skip to content

Commit 8b4e285

Browse files
Paulo Alcantarasmfrench
authored andcommitted
smb: client: move some params to cifs_open_info_data
Instead of passing @adjust_tz and some reparse point related fields as parameters in ->query_path_info() and {smb311_posix,cifs}_info_to_fattr() calls, move them to cifs_open_info_data structure as they can be easily accessed through @DaTa. No functional changes. Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent ce04127 commit 8b4e285

File tree

5 files changed

+77
-66
lines changed

5 files changed

+77
-66
lines changed

fs/smb/client/cifsglob.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ struct cifs_cred {
186186
};
187187

188188
struct cifs_open_info_data {
189+
bool adjust_tz;
190+
union {
191+
bool reparse_point;
192+
bool symlink;
193+
};
194+
__u32 reparse_tag;
189195
char *symlink_target;
190196
union {
191197
struct smb2_file_all_info fi;
@@ -318,9 +324,11 @@ struct smb_version_operations {
318324
int (*is_path_accessible)(const unsigned int, struct cifs_tcon *,
319325
struct cifs_sb_info *, const char *);
320326
/* query path data from the server */
321-
int (*query_path_info)(const unsigned int xid, struct cifs_tcon *tcon,
322-
struct cifs_sb_info *cifs_sb, const char *full_path,
323-
struct cifs_open_info_data *data, bool *adjust_tz, bool *reparse);
327+
int (*query_path_info)(const unsigned int xid,
328+
struct cifs_tcon *tcon,
329+
struct cifs_sb_info *cifs_sb,
330+
const char *full_path,
331+
struct cifs_open_info_data *data);
324332
/* query file data from the server */
325333
int (*query_file_info)(const unsigned int xid, struct cifs_tcon *tcon,
326334
struct cifsFileInfo *cfile, struct cifs_open_info_data *data);

fs/smb/client/inode.c

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,11 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path,
632632
}
633633

634634
/* Fill a cifs_fattr struct with info from POSIX info struct */
635-
static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr, struct cifs_open_info_data *data,
635+
static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr,
636+
struct cifs_open_info_data *data,
636637
struct cifs_sid *owner,
637638
struct cifs_sid *group,
638-
struct super_block *sb, bool adjust_tz, bool symlink)
639+
struct super_block *sb)
639640
{
640641
struct smb311_posix_qinfo *info = &data->posix_fi;
641642
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
@@ -655,7 +656,7 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr, struct cifs_ope
655656
fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
656657
fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
657658

658-
if (adjust_tz) {
659+
if (data->adjust_tz) {
659660
fattr->cf_ctime.tv_sec += tcon->ses->server->timeAdj;
660661
fattr->cf_mtime.tv_sec += tcon->ses->server->timeAdj;
661662
}
@@ -669,7 +670,7 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr, struct cifs_ope
669670
/* The srv fs device id is overridden on network mount so setting rdev isn't needed here */
670671
/* fattr->cf_rdev = le32_to_cpu(info->DeviceId); */
671672

672-
if (symlink) {
673+
if (data->symlink) {
673674
fattr->cf_mode |= S_IFLNK;
674675
fattr->cf_dtype = DT_LNK;
675676
fattr->cf_symlink_target = data->symlink_target;
@@ -690,13 +691,14 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr, struct cifs_ope
690691
fattr->cf_mode, fattr->cf_uniqueid, fattr->cf_nlink);
691692
}
692693

693-
static void cifs_open_info_to_fattr(struct cifs_fattr *fattr, struct cifs_open_info_data *data,
694-
struct super_block *sb, bool adjust_tz, bool symlink,
695-
u32 reparse_tag)
694+
static void cifs_open_info_to_fattr(struct cifs_fattr *fattr,
695+
struct cifs_open_info_data *data,
696+
struct super_block *sb)
696697
{
697698
struct smb2_file_all_info *info = &data->fi;
698699
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
699700
struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
701+
u32 reparse_tag = data->reparse_tag;
700702

701703
memset(fattr, 0, sizeof(*fattr));
702704
fattr->cf_cifsattrs = le32_to_cpu(info->Attributes);
@@ -711,7 +713,7 @@ static void cifs_open_info_to_fattr(struct cifs_fattr *fattr, struct cifs_open_i
711713
fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
712714
fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
713715

714-
if (adjust_tz) {
716+
if (data->adjust_tz) {
715717
fattr->cf_ctime.tv_sec += tcon->ses->server->timeAdj;
716718
fattr->cf_mtime.tv_sec += tcon->ses->server->timeAdj;
717719
}
@@ -736,7 +738,7 @@ static void cifs_open_info_to_fattr(struct cifs_fattr *fattr, struct cifs_open_i
736738
} else if (reparse_tag == IO_REPARSE_TAG_LX_BLK) {
737739
fattr->cf_mode |= S_IFBLK | cifs_sb->ctx->file_mode;
738740
fattr->cf_dtype = DT_BLK;
739-
} else if (symlink || reparse_tag == IO_REPARSE_TAG_SYMLINK ||
741+
} else if (data->symlink || reparse_tag == IO_REPARSE_TAG_SYMLINK ||
740742
reparse_tag == IO_REPARSE_TAG_NFS) {
741743
fattr->cf_mode = S_IFLNK;
742744
fattr->cf_dtype = DT_LNK;
@@ -789,8 +791,6 @@ cifs_get_file_info(struct file *filp)
789791
struct cifsFileInfo *cfile = filp->private_data;
790792
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
791793
struct TCP_Server_Info *server = tcon->ses->server;
792-
bool symlink = false;
793-
u32 tag = 0;
794794

795795
if (!server->ops->query_file_info)
796796
return -ENOSYS;
@@ -800,11 +800,12 @@ cifs_get_file_info(struct file *filp)
800800
switch (rc) {
801801
case 0:
802802
/* TODO: add support to query reparse tag */
803+
data.adjust_tz = false;
803804
if (data.symlink_target) {
804-
symlink = true;
805-
tag = IO_REPARSE_TAG_SYMLINK;
805+
data.symlink = true;
806+
data.reparse_tag = IO_REPARSE_TAG_SYMLINK;
806807
}
807-
cifs_open_info_to_fattr(&fattr, &data, inode->i_sb, false, symlink, tag);
808+
cifs_open_info_to_fattr(&fattr, &data, inode->i_sb);
808809
break;
809810
case -EREMOTE:
810811
cifs_create_dfs_fattr(&fattr, inode->i_sb);
@@ -968,14 +969,11 @@ int cifs_get_inode_info(struct inode **inode, const char *full_path,
968969
struct TCP_Server_Info *server;
969970
struct tcon_link *tlink;
970971
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
971-
bool adjust_tz = false;
972972
struct cifs_fattr fattr = {0};
973-
bool is_reparse_point = false;
974973
struct cifs_open_info_data tmp_data = {};
975974
void *smb1_backup_rsp_buf = NULL;
976975
int rc = 0;
977976
int tmprc = 0;
978-
__u32 reparse_tag = 0;
979977

980978
tlink = cifs_sb_tlink(cifs_sb);
981979
if (IS_ERR(tlink))
@@ -992,8 +990,8 @@ int cifs_get_inode_info(struct inode **inode, const char *full_path,
992990
cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
993991
goto out;
994992
}
995-
rc = server->ops->query_path_info(xid, tcon, cifs_sb, full_path, &tmp_data,
996-
&adjust_tz, &is_reparse_point);
993+
rc = server->ops->query_path_info(xid, tcon, cifs_sb,
994+
full_path, &tmp_data);
997995
data = &tmp_data;
998996
}
999997

@@ -1008,24 +1006,23 @@ int cifs_get_inode_info(struct inode **inode, const char *full_path,
10081006
* since we have to check if its reparse tag matches a known
10091007
* special file type e.g. symlink or fifo or char etc.
10101008
*/
1011-
if (is_reparse_point && data->symlink_target) {
1012-
reparse_tag = IO_REPARSE_TAG_SYMLINK;
1009+
if (data->reparse_point && data->symlink_target) {
1010+
data->reparse_tag = IO_REPARSE_TAG_SYMLINK;
10131011
} else if ((le32_to_cpu(data->fi.Attributes) & ATTR_REPARSE) &&
10141012
server->ops->query_reparse_tag) {
10151013
tmprc = server->ops->query_reparse_tag(xid, tcon, cifs_sb, full_path,
1016-
&reparse_tag);
1017-
if (tmprc)
1018-
cifs_dbg(FYI, "%s: query_reparse_tag: rc = %d\n", __func__, tmprc);
1014+
&data->reparse_tag);
1015+
cifs_dbg(FYI, "%s: query_reparse_tag: rc = %d\n", __func__, tmprc);
10191016
if (server->ops->query_symlink) {
1020-
tmprc = server->ops->query_symlink(xid, tcon, cifs_sb, full_path,
1017+
tmprc = server->ops->query_symlink(xid, tcon, cifs_sb,
1018+
full_path,
10211019
&data->symlink_target,
1022-
is_reparse_point);
1023-
if (tmprc)
1024-
cifs_dbg(FYI, "%s: query_symlink: rc = %d\n", __func__,
1025-
tmprc);
1020+
data->reparse_point);
1021+
cifs_dbg(FYI, "%s: query_symlink: rc = %d\n",
1022+
__func__, tmprc);
10261023
}
10271024
}
1028-
cifs_open_info_to_fattr(&fattr, data, sb, adjust_tz, is_reparse_point, reparse_tag);
1025+
cifs_open_info_to_fattr(&fattr, data, sb);
10291026
break;
10301027
case -EREMOTE:
10311028
/* DFS link, no metadata available on this server */
@@ -1168,9 +1165,7 @@ smb311_posix_get_inode_info(struct inode **inode,
11681165
struct cifs_tcon *tcon;
11691166
struct tcon_link *tlink;
11701167
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
1171-
bool adjust_tz = false;
11721168
struct cifs_fattr fattr = {0};
1173-
bool symlink = false;
11741169
struct cifs_open_info_data data = {};
11751170
struct cifs_sid owner, group;
11761171
int rc = 0;
@@ -1190,18 +1185,17 @@ smb311_posix_get_inode_info(struct inode **inode,
11901185
goto out;
11911186
}
11921187

1193-
rc = smb311_posix_query_path_info(xid, tcon, cifs_sb, full_path, &data,
1194-
&owner, &group, &adjust_tz,
1195-
&symlink);
1188+
rc = smb311_posix_query_path_info(xid, tcon, cifs_sb,
1189+
full_path, &data,
1190+
&owner, &group);
11961191

11971192
/*
11981193
* 2. Convert it to internal cifs metadata (fattr)
11991194
*/
12001195

12011196
switch (rc) {
12021197
case 0:
1203-
smb311_posix_info_to_fattr(&fattr, &data, &owner, &group,
1204-
sb, adjust_tz, symlink);
1198+
smb311_posix_info_to_fattr(&fattr, &data, &owner, &group, sb);
12051199
break;
12061200
case -EREMOTE:
12071201
/* DFS link, no metadata available on this server */

fs/smb/client/smb1ops.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,14 +542,17 @@ cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
542542
return rc;
543543
}
544544

545-
static int cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
546-
struct cifs_sb_info *cifs_sb, const char *full_path,
547-
struct cifs_open_info_data *data, bool *adjustTZ, bool *symlink)
545+
static int cifs_query_path_info(const unsigned int xid,
546+
struct cifs_tcon *tcon,
547+
struct cifs_sb_info *cifs_sb,
548+
const char *full_path,
549+
struct cifs_open_info_data *data)
548550
{
549551
int rc;
550552
FILE_ALL_INFO fi = {};
551553

552-
*symlink = false;
554+
data->symlink = false;
555+
data->adjust_tz = false;
553556

554557
/* could do find first instead but this returns more info */
555558
rc = CIFSSMBQPathInfo(xid, tcon, full_path, &fi, 0 /* not legacy */, cifs_sb->local_nls,
@@ -562,7 +565,7 @@ static int cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
562565
if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
563566
rc = SMBQueryInformation(xid, tcon, full_path, &fi, cifs_sb->local_nls,
564567
cifs_remap(cifs_sb));
565-
*adjustTZ = true;
568+
data->adjust_tz = true;
566569
}
567570

568571
if (!rc) {
@@ -589,7 +592,7 @@ static int cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
589592
/* Need to check if this is a symbolic link or not */
590593
tmprc = CIFS_open(xid, &oparms, &oplock, NULL);
591594
if (tmprc == -EOPNOTSUPP)
592-
*symlink = true;
595+
data->symlink = true;
593596
else if (tmprc == 0)
594597
CIFSSMBClose(xid, tcon, fid.netfid);
595598
}

fs/smb/client/smb2inode.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,11 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
541541
return rc;
542542
}
543543

544-
int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
545-
struct cifs_sb_info *cifs_sb, const char *full_path,
546-
struct cifs_open_info_data *data, bool *adjust_tz, bool *reparse)
544+
int smb2_query_path_info(const unsigned int xid,
545+
struct cifs_tcon *tcon,
546+
struct cifs_sb_info *cifs_sb,
547+
const char *full_path,
548+
struct cifs_open_info_data *data)
547549
{
548550
__u32 create_options = 0;
549551
struct cifsFileInfo *cfile;
@@ -553,8 +555,8 @@ int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
553555
bool islink;
554556
int rc, rc2;
555557

556-
*adjust_tz = false;
557-
*reparse = false;
558+
data->adjust_tz = false;
559+
data->reparse_point = false;
558560

559561
if (strcmp(full_path, ""))
560562
rc = -ENOENT;
@@ -588,7 +590,7 @@ int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
588590
if (rc)
589591
goto out;
590592

591-
*reparse = true;
593+
data->reparse_point = true;
592594
create_options |= OPEN_REPARSE_POINT;
593595

594596
/* Failed on a symbolic link - query a reparse point info */
@@ -619,12 +621,13 @@ int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
619621
}
620622

621623

622-
int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
623-
struct cifs_sb_info *cifs_sb, const char *full_path,
624+
int smb311_posix_query_path_info(const unsigned int xid,
625+
struct cifs_tcon *tcon,
626+
struct cifs_sb_info *cifs_sb,
627+
const char *full_path,
624628
struct cifs_open_info_data *data,
625629
struct cifs_sid *owner,
626-
struct cifs_sid *group,
627-
bool *adjust_tz, bool *reparse)
630+
struct cifs_sid *group)
628631
{
629632
int rc;
630633
__u32 create_options = 0;
@@ -636,8 +639,8 @@ int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
636639
size_t sidsbuflen = 0;
637640
size_t owner_len, group_len;
638641

639-
*adjust_tz = false;
640-
*reparse = false;
642+
data->adjust_tz = false;
643+
data->reparse_point = false;
641644

642645
/*
643646
* BB TODO: Add support for using the cached root handle.
@@ -659,7 +662,7 @@ int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
659662
if (rc)
660663
goto out;
661664
}
662-
*reparse = true;
665+
data->reparse_point = true;
663666
create_options |= OPEN_REPARSE_POINT;
664667

665668
/* Failed on a symbolic link - query a reparse point info */

fs/smb/client/smb2proto.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ extern int smb3_handle_read_data(struct TCP_Server_Info *server,
5656
extern int smb2_query_reparse_tag(const unsigned int xid, struct cifs_tcon *tcon,
5757
struct cifs_sb_info *cifs_sb, const char *path,
5858
__u32 *reparse_tag);
59-
int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
60-
struct cifs_sb_info *cifs_sb, const char *full_path,
61-
struct cifs_open_info_data *data, bool *adjust_tz, bool *reparse);
59+
int smb2_query_path_info(const unsigned int xid,
60+
struct cifs_tcon *tcon,
61+
struct cifs_sb_info *cifs_sb,
62+
const char *full_path,
63+
struct cifs_open_info_data *data);
6264
extern int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
6365
const char *full_path, __u64 size,
6466
struct cifs_sb_info *cifs_sb, bool set_alloc);
@@ -275,12 +277,13 @@ extern int smb2_query_info_compound(const unsigned int xid,
275277
struct kvec *rsp, int *buftype,
276278
struct cifs_sb_info *cifs_sb);
277279
/* query path info from the server using SMB311 POSIX extensions*/
278-
int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
279-
struct cifs_sb_info *cifs_sb, const char *full_path,
280+
int smb311_posix_query_path_info(const unsigned int xid,
281+
struct cifs_tcon *tcon,
282+
struct cifs_sb_info *cifs_sb,
283+
const char *full_path,
280284
struct cifs_open_info_data *data,
281285
struct cifs_sid *owner,
282-
struct cifs_sid *group,
283-
bool *adjust_tz, bool *reparse);
286+
struct cifs_sid *group);
284287
int posix_info_parse(const void *beg, const void *end,
285288
struct smb2_posix_info_parsed *out);
286289
int posix_info_sid_size(const void *beg, const void *end);

0 commit comments

Comments
 (0)