Skip to content

Commit 0f06093

Browse files
amir73ilsmfrench
authored andcommitted
SMB3: Backup intent flag missing from some more ops
When "backup intent" is requested on the mount (e.g. backupuid or backupgid mount options), the corresponding flag was missing from some of the operations. Change all operations to use the macro cifs_create_options() to set the backup intent flag if needed. Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 94f2630 commit 0f06093

File tree

14 files changed

+68
-118
lines changed

14 files changed

+68
-118
lines changed

fs/cifs/cifsacl.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
10841084
struct cifs_ntsd *pntsd = NULL;
10851085
int oplock = 0;
10861086
unsigned int xid;
1087-
int rc, create_options = 0;
1087+
int rc;
10881088
struct cifs_tcon *tcon;
10891089
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
10901090
struct cifs_fid fid;
@@ -1096,13 +1096,10 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
10961096
tcon = tlink_tcon(tlink);
10971097
xid = get_xid();
10981098

1099-
if (backup_cred(cifs_sb))
1100-
create_options |= CREATE_OPEN_BACKUP_INTENT;
1101-
11021099
oparms.tcon = tcon;
11031100
oparms.cifs_sb = cifs_sb;
11041101
oparms.desired_access = READ_CONTROL;
1105-
oparms.create_options = create_options;
1102+
oparms.create_options = cifs_create_options(cifs_sb, 0);
11061103
oparms.disposition = FILE_OPEN;
11071104
oparms.path = path;
11081105
oparms.fid = &fid;
@@ -1147,7 +1144,7 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
11471144
{
11481145
int oplock = 0;
11491146
unsigned int xid;
1150-
int rc, access_flags, create_options = 0;
1147+
int rc, access_flags;
11511148
struct cifs_tcon *tcon;
11521149
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
11531150
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
@@ -1160,9 +1157,6 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
11601157
tcon = tlink_tcon(tlink);
11611158
xid = get_xid();
11621159

1163-
if (backup_cred(cifs_sb))
1164-
create_options |= CREATE_OPEN_BACKUP_INTENT;
1165-
11661160
if (aclflag == CIFS_ACL_OWNER || aclflag == CIFS_ACL_GROUP)
11671161
access_flags = WRITE_OWNER;
11681162
else
@@ -1171,7 +1165,7 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
11711165
oparms.tcon = tcon;
11721166
oparms.cifs_sb = cifs_sb;
11731167
oparms.desired_access = access_flags;
1174-
oparms.create_options = create_options;
1168+
oparms.create_options = cifs_create_options(cifs_sb, 0);
11751169
oparms.disposition = FILE_OPEN;
11761170
oparms.path = path;
11771171
oparms.fid = &fid;

fs/cifs/cifsfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
275275
buf->f_ffree = 0; /* unlimited */
276276

277277
if (server->ops->queryfs)
278-
rc = server->ops->queryfs(xid, tcon, buf);
278+
rc = server->ops->queryfs(xid, tcon, cifs_sb, buf);
279279

280280
free_xid(xid);
281281
return 0;

fs/cifs/cifsglob.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ struct smb_version_operations {
298298
const char *, struct dfs_info3_param **,
299299
unsigned int *, const struct nls_table *, int);
300300
/* informational QFS call */
301-
void (*qfs_tcon)(const unsigned int, struct cifs_tcon *);
301+
void (*qfs_tcon)(const unsigned int, struct cifs_tcon *,
302+
struct cifs_sb_info *);
302303
/* check if a path is accessible or not */
303304
int (*is_path_accessible)(const unsigned int, struct cifs_tcon *,
304305
struct cifs_sb_info *, const char *);
@@ -409,7 +410,7 @@ struct smb_version_operations {
409410
struct cifsInodeInfo *);
410411
/* query remote filesystem */
411412
int (*queryfs)(const unsigned int, struct cifs_tcon *,
412-
struct kstatfs *);
413+
struct cifs_sb_info *, struct kstatfs *);
413414
/* send mandatory brlock to the server */
414415
int (*mand_lock)(const unsigned int, struct cifsFileInfo *, __u64,
415416
__u64, __u32, int, int, bool);
@@ -490,6 +491,7 @@ struct smb_version_operations {
490491
/* ioctl passthrough for query_info */
491492
int (*ioctl_query_info)(const unsigned int xid,
492493
struct cifs_tcon *tcon,
494+
struct cifs_sb_info *cifs_sb,
493495
__le16 *path, int is_dir,
494496
unsigned long p);
495497
/* make unix special files (block, char, fifo, socket) */

fs/cifs/cifsproto.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,4 +612,12 @@ static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
612612
}
613613
#endif
614614

615+
static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options)
616+
{
617+
if (backup_cred(cifs_sb))
618+
return options | CREATE_OPEN_BACKUP_INTENT;
619+
else
620+
return options;
621+
}
622+
615623
#endif /* _CIFSPROTO_H */

fs/cifs/connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4365,7 +4365,7 @@ static int mount_get_conns(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
43654365

43664366
/* do not care if a following call succeed - informational */
43674367
if (!tcon->pipe && server->ops->qfs_tcon) {
4368-
server->ops->qfs_tcon(*xid, tcon);
4368+
server->ops->qfs_tcon(*xid, tcon, cifs_sb);
43694369
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE) {
43704370
if (tcon->fsDevInfo.DeviceCharacteristics &
43714371
cpu_to_le32(FILE_READ_ONLY_DEVICE))

fs/cifs/dir.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,10 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
355355
if (!tcon->unix_ext && (mode & S_IWUGO) == 0)
356356
create_options |= CREATE_OPTION_READONLY;
357357

358-
if (backup_cred(cifs_sb))
359-
create_options |= CREATE_OPEN_BACKUP_INTENT;
360-
361358
oparms.tcon = tcon;
362359
oparms.cifs_sb = cifs_sb;
363360
oparms.desired_access = desired_access;
364-
oparms.create_options = create_options;
361+
oparms.create_options = cifs_create_options(cifs_sb, create_options);
365362
oparms.disposition = disposition;
366363
oparms.path = full_path;
367364
oparms.fid = fid;

fs/cifs/file.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,6 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
222222
if (!buf)
223223
return -ENOMEM;
224224

225-
if (backup_cred(cifs_sb))
226-
create_options |= CREATE_OPEN_BACKUP_INTENT;
227-
228225
/* O_SYNC also has bit for O_DSYNC so following check picks up either */
229226
if (f_flags & O_SYNC)
230227
create_options |= CREATE_WRITE_THROUGH;
@@ -235,7 +232,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
235232
oparms.tcon = tcon;
236233
oparms.cifs_sb = cifs_sb;
237234
oparms.desired_access = desired_access;
238-
oparms.create_options = create_options;
235+
oparms.create_options = cifs_create_options(cifs_sb, create_options);
239236
oparms.disposition = disposition;
240237
oparms.path = full_path;
241238
oparms.fid = fid;
@@ -752,9 +749,6 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
752749

753750
desired_access = cifs_convert_flags(cfile->f_flags);
754751

755-
if (backup_cred(cifs_sb))
756-
create_options |= CREATE_OPEN_BACKUP_INTENT;
757-
758752
/* O_SYNC also has bit for O_DSYNC so following check picks up either */
759753
if (cfile->f_flags & O_SYNC)
760754
create_options |= CREATE_WRITE_THROUGH;
@@ -768,7 +762,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
768762
oparms.tcon = tcon;
769763
oparms.cifs_sb = cifs_sb;
770764
oparms.desired_access = desired_access;
771-
oparms.create_options = create_options;
765+
oparms.create_options = cifs_create_options(cifs_sb, create_options);
772766
oparms.disposition = disposition;
773767
oparms.path = full_path;
774768
oparms.fid = &cfile->fid;

fs/cifs/inode.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
472472
oparms.tcon = tcon;
473473
oparms.cifs_sb = cifs_sb;
474474
oparms.desired_access = GENERIC_READ;
475-
oparms.create_options = CREATE_NOT_DIR;
476-
if (backup_cred(cifs_sb))
477-
oparms.create_options |= CREATE_OPEN_BACKUP_INTENT;
475+
oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
478476
oparms.disposition = FILE_OPEN;
479477
oparms.path = path;
480478
oparms.fid = &fid;
@@ -1284,7 +1282,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
12841282
oparms.tcon = tcon;
12851283
oparms.cifs_sb = cifs_sb;
12861284
oparms.desired_access = DELETE | FILE_WRITE_ATTRIBUTES;
1287-
oparms.create_options = CREATE_NOT_DIR;
1285+
oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
12881286
oparms.disposition = FILE_OPEN;
12891287
oparms.path = full_path;
12901288
oparms.fid = &fid;
@@ -1822,7 +1820,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
18221820
oparms.cifs_sb = cifs_sb;
18231821
/* open the file to be renamed -- we need DELETE perms */
18241822
oparms.desired_access = DELETE;
1825-
oparms.create_options = CREATE_NOT_DIR;
1823+
oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
18261824
oparms.disposition = FILE_OPEN;
18271825
oparms.path = from_path;
18281826
oparms.fid = &fid;

fs/cifs/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static long cifs_ioctl_query_info(unsigned int xid, struct file *filep,
6565

6666
if (tcon->ses->server->ops->ioctl_query_info)
6767
rc = tcon->ses->server->ops->ioctl_query_info(
68-
xid, tcon, utf16_path,
68+
xid, tcon, cifs_sb, utf16_path,
6969
filep->private_data ? 0 : 1, p);
7070
else
7171
rc = -EOPNOTSUPP;

fs/cifs/link.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
315315
oparms.tcon = tcon;
316316
oparms.cifs_sb = cifs_sb;
317317
oparms.desired_access = GENERIC_READ;
318-
oparms.create_options = CREATE_NOT_DIR;
318+
oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
319319
oparms.disposition = FILE_OPEN;
320320
oparms.path = path;
321321
oparms.fid = &fid;
@@ -353,15 +353,11 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
353353
struct cifs_fid fid;
354354
struct cifs_open_parms oparms;
355355
struct cifs_io_parms io_parms;
356-
int create_options = CREATE_NOT_DIR;
357-
358-
if (backup_cred(cifs_sb))
359-
create_options |= CREATE_OPEN_BACKUP_INTENT;
360356

361357
oparms.tcon = tcon;
362358
oparms.cifs_sb = cifs_sb;
363359
oparms.desired_access = GENERIC_WRITE;
364-
oparms.create_options = create_options;
360+
oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
365361
oparms.disposition = FILE_CREATE;
366362
oparms.path = path;
367363
oparms.fid = &fid;
@@ -402,9 +398,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
402398
oparms.tcon = tcon;
403399
oparms.cifs_sb = cifs_sb;
404400
oparms.desired_access = GENERIC_READ;
405-
oparms.create_options = CREATE_NOT_DIR;
406-
if (backup_cred(cifs_sb))
407-
oparms.create_options |= CREATE_OPEN_BACKUP_INTENT;
401+
oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
408402
oparms.disposition = FILE_OPEN;
409403
oparms.fid = &fid;
410404
oparms.reconnect = false;
@@ -457,14 +451,10 @@ smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
457451
struct cifs_fid fid;
458452
struct cifs_open_parms oparms;
459453
struct cifs_io_parms io_parms;
460-
int create_options = CREATE_NOT_DIR;
461454
__le16 *utf16_path;
462455
__u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
463456
struct kvec iov[2];
464457

465-
if (backup_cred(cifs_sb))
466-
create_options |= CREATE_OPEN_BACKUP_INTENT;
467-
468458
cifs_dbg(FYI, "%s: path: %s\n", __func__, path);
469459

470460
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
@@ -474,7 +464,7 @@ smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
474464
oparms.tcon = tcon;
475465
oparms.cifs_sb = cifs_sb;
476466
oparms.desired_access = GENERIC_WRITE;
477-
oparms.create_options = create_options;
467+
oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR);
478468
oparms.disposition = FILE_CREATE;
479469
oparms.fid = &fid;
480470
oparms.reconnect = false;

0 commit comments

Comments
 (0)