Skip to content

Commit 226730b

Browse files
piastrysmfrench
authored andcommitted
CIFS: Introduce cifs_open_parms struct
and pass it to the open() call. Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steven French <steven@steven-GA-970A-DS3.(none)>
1 parent 63eb3de commit 226730b

6 files changed

Lines changed: 73 additions & 41 deletions

File tree

‎fs/cifs/cifsglob.h‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ struct cifs_writedata;
194194
struct cifs_io_parms;
195195
struct cifs_search_info;
196196
struct cifsInodeInfo;
197+
struct cifs_open_parms;
197198

198199
struct smb_version_operations {
199200
int (*send_cancel)(struct TCP_Server_Info *, void *,
@@ -307,9 +308,8 @@ struct smb_version_operations {
307308
const char *, const char *,
308309
struct cifs_sb_info *);
309310
/* open a file for non-posix mounts */
310-
int (*open)(const unsigned int, struct cifs_tcon *, const char *, int,
311-
int, int, struct cifs_fid *, __u32 *, FILE_ALL_INFO *,
312-
struct cifs_sb_info *);
311+
int (*open)(const unsigned int, struct cifs_open_parms *,
312+
__u32 *, FILE_ALL_INFO *);
313313
/* set fid protocol-specific info */
314314
void (*set_fid)(struct cifsFileInfo *, struct cifs_fid *, __u32);
315315
/* close a file */
@@ -912,6 +912,16 @@ struct cifs_search_info {
912912
bool smallBuf:1; /* so we know which buf_release function to call */
913913
};
914914

915+
struct cifs_open_parms {
916+
struct cifs_tcon *tcon;
917+
struct cifs_sb_info *cifs_sb;
918+
int disposition;
919+
int desired_access;
920+
int create_options;
921+
const char *path;
922+
struct cifs_fid *fid;
923+
};
924+
915925
struct cifs_fid {
916926
__u16 netfid;
917927
#ifdef CONFIG_CIFS_SMB2

‎fs/cifs/dir.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
204204
struct inode *newinode = NULL;
205205
int disposition;
206206
struct TCP_Server_Info *server = tcon->ses->server;
207+
struct cifs_open_parms oparms;
207208

208209
*oplock = 0;
209210
if (tcon->ses->server->oplocks)
@@ -319,9 +320,15 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
319320
if (backup_cred(cifs_sb))
320321
create_options |= CREATE_OPEN_BACKUP_INTENT;
321322

322-
rc = server->ops->open(xid, tcon, full_path, disposition,
323-
desired_access, create_options, fid, oplock,
324-
buf, cifs_sb);
323+
oparms.tcon = tcon;
324+
oparms.cifs_sb = cifs_sb;
325+
oparms.desired_access = desired_access;
326+
oparms.create_options = create_options;
327+
oparms.disposition = disposition;
328+
oparms.path = full_path;
329+
oparms.fid = fid;
330+
331+
rc = server->ops->open(xid, &oparms, oplock, buf);
325332
if (rc) {
326333
cifs_dbg(FYI, "cifs_create returned 0x%x\n", rc);
327334
goto out;

‎fs/cifs/file.c‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
183183
int create_options = CREATE_NOT_DIR;
184184
FILE_ALL_INFO *buf;
185185
struct TCP_Server_Info *server = tcon->ses->server;
186+
struct cifs_open_parms oparms;
186187

187188
if (!server->ops->open)
188189
return -ENOSYS;
@@ -224,9 +225,15 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
224225
if (backup_cred(cifs_sb))
225226
create_options |= CREATE_OPEN_BACKUP_INTENT;
226227

227-
rc = server->ops->open(xid, tcon, full_path, disposition,
228-
desired_access, create_options, fid, oplock, buf,
229-
cifs_sb);
228+
oparms.tcon = tcon;
229+
oparms.cifs_sb = cifs_sb;
230+
oparms.desired_access = desired_access;
231+
oparms.create_options = create_options;
232+
oparms.disposition = disposition;
233+
oparms.path = full_path;
234+
oparms.fid = fid;
235+
236+
rc = server->ops->open(xid, &oparms, oplock, buf);
230237

231238
if (rc)
232239
goto out;
@@ -588,6 +595,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
588595
int disposition = FILE_OPEN;
589596
int create_options = CREATE_NOT_DIR;
590597
struct cifs_fid fid;
598+
struct cifs_open_parms oparms;
591599

592600
xid = get_xid();
593601
mutex_lock(&cfile->fh_mutex);
@@ -656,16 +664,22 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
656664
if (server->ops->get_lease_key)
657665
server->ops->get_lease_key(inode, &fid);
658666

667+
oparms.tcon = tcon;
668+
oparms.cifs_sb = cifs_sb;
669+
oparms.desired_access = desired_access;
670+
oparms.create_options = create_options;
671+
oparms.disposition = disposition;
672+
oparms.path = full_path;
673+
oparms.fid = &fid;
674+
659675
/*
660676
* Can not refresh inode by passing in file_info buf to be returned by
661677
* CIFSSMBOpen and then calling get_inode_info with returned buf since
662678
* file might have write behind data that needs to be flushed and server
663679
* version of file size can be stale. If we knew for sure that inode was
664680
* not dirty locally we could do this.
665681
*/
666-
rc = server->ops->open(xid, tcon, full_path, disposition,
667-
desired_access, create_options, &fid, &oplock,
668-
NULL, cifs_sb);
682+
rc = server->ops->open(xid, &oparms, &oplock, NULL);
669683
if (rc) {
670684
mutex_unlock(&cfile->fh_mutex);
671685
cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc);

‎fs/cifs/smb1ops.c‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -674,20 +674,23 @@ cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
674674
}
675675

676676
static int
677-
cifs_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path,
678-
int disposition, int desired_access, int create_options,
679-
struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf,
680-
struct cifs_sb_info *cifs_sb)
681-
{
682-
if (!(tcon->ses->capabilities & CAP_NT_SMBS))
683-
return SMBLegacyOpen(xid, tcon, path, disposition,
684-
desired_access, create_options,
685-
&fid->netfid, oplock, buf,
686-
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
677+
cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
678+
__u32 *oplock, FILE_ALL_INFO *buf)
679+
{
680+
if (!(oparms->tcon->ses->capabilities & CAP_NT_SMBS))
681+
return SMBLegacyOpen(xid, oparms->tcon, oparms->path,
682+
oparms->disposition,
683+
oparms->desired_access,
684+
oparms->create_options,
685+
&oparms->fid->netfid, oplock, buf,
686+
oparms->cifs_sb->local_nls,
687+
oparms->cifs_sb->mnt_cifs_flags
687688
& CIFS_MOUNT_MAP_SPECIAL_CHR);
688-
return CIFSSMBOpen(xid, tcon, path, disposition, desired_access,
689-
create_options, &fid->netfid, oplock, buf,
690-
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
689+
return CIFSSMBOpen(xid, oparms->tcon, oparms->path,
690+
oparms->disposition, oparms->desired_access,
691+
oparms->create_options, &oparms->fid->netfid, oplock,
692+
buf, oparms->cifs_sb->local_nls,
693+
oparms->cifs_sb->mnt_cifs_flags &
691694
CIFS_MOUNT_MAP_SPECIAL_CHR);
692695
}
693696

‎fs/cifs/smb2file.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,16 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
5757
}
5858

5959
int
60-
smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path,
61-
int disposition, int desired_access, int create_options,
62-
struct cifs_fid *fid, __u32 *oplock, FILE_ALL_INFO *buf,
63-
struct cifs_sb_info *cifs_sb)
60+
smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
61+
__u32 *oplock, FILE_ALL_INFO *buf)
6462
{
6563
int rc;
6664
__le16 *smb2_path;
6765
struct smb2_file_all_info *smb2_data = NULL;
6866
__u8 smb2_oplock[17];
67+
struct cifs_fid *fid = oparms->fid;
6968

70-
smb2_path = cifs_convert_path_to_utf16(path, cifs_sb);
69+
smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb);
7170
if (smb2_path == NULL) {
7271
rc = -ENOMEM;
7372
goto out;
@@ -80,21 +79,22 @@ smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon, const char *path,
8079
goto out;
8180
}
8281

83-
desired_access |= FILE_READ_ATTRIBUTES;
82+
oparms->desired_access |= FILE_READ_ATTRIBUTES;
8483
*smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH;
8584

86-
if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
85+
if (oparms->tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING)
8786
memcpy(smb2_oplock + 1, fid->lease_key, SMB2_LEASE_KEY_SIZE);
8887

89-
rc = SMB2_open(xid, tcon, smb2_path, &fid->persistent_fid,
90-
&fid->volatile_fid, desired_access, disposition,
91-
create_options, smb2_oplock, smb2_data);
88+
rc = SMB2_open(xid, oparms->tcon, smb2_path, &fid->persistent_fid,
89+
&fid->volatile_fid, oparms->desired_access,
90+
oparms->disposition, oparms->create_options, smb2_oplock,
91+
smb2_data);
9292
if (rc)
9393
goto out;
9494

9595
if (buf) {
9696
/* open response does not have IndexNumber field - get it */
97-
rc = SMB2_get_srv_num(xid, tcon, fid->persistent_fid,
97+
rc = SMB2_get_srv_num(xid, oparms->tcon, fid->persistent_fid,
9898
fid->volatile_fid,
9999
&smb2_data->IndexNumber);
100100
if (rc) {

‎fs/cifs/smb2proto.h‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ extern int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
8484
const char *from_name, const char *to_name,
8585
struct cifs_sb_info *cifs_sb);
8686

87-
extern int smb2_open_file(const unsigned int xid, struct cifs_tcon *tcon,
88-
const char *full_path, int disposition,
89-
int desired_access, int create_options,
90-
struct cifs_fid *fid, __u32 *oplock,
91-
FILE_ALL_INFO *buf, struct cifs_sb_info *cifs_sb);
87+
extern int smb2_open_file(const unsigned int xid,
88+
struct cifs_open_parms *oparms,
89+
__u32 *oplock, FILE_ALL_INFO *buf);
9290
extern void smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
9391
extern int smb2_unlock_range(struct cifsFileInfo *cfile,
9492
struct file_lock *flock, const unsigned int xid);

0 commit comments

Comments
 (0)