Skip to content

Commit 1319a28

Browse files
committed
Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "A set of minor cifs fixes" * 'for-next' of git://git.samba.org/sfrench/cifs-2.6: [CIFS] Minor cleanup of xattr query function fs: cifs: transport: Use time_after for time comparison SMB2: Fix share type handling cifs: cifsacl: Use a temporary ops variable to reduce code length Don't delay freeing mids when blocked on slow socket write of request CIFS: silence lockdep splat in cifs_relock_file()
2 parents 2ea659a + 67b4c88 commit 1319a28

File tree

9 files changed

+33
-49
lines changed

9 files changed

+33
-49
lines changed

fs/cifs/cifsacl.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,20 +1135,19 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
11351135
u32 acllen = 0;
11361136
int rc = 0;
11371137
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
1138-
struct cifs_tcon *tcon;
1138+
struct smb_version_operations *ops;
11391139

11401140
cifs_dbg(NOISY, "converting ACL to mode for %s\n", path);
11411141

11421142
if (IS_ERR(tlink))
11431143
return PTR_ERR(tlink);
1144-
tcon = tlink_tcon(tlink);
11451144

1146-
if (pfid && (tcon->ses->server->ops->get_acl_by_fid))
1147-
pntsd = tcon->ses->server->ops->get_acl_by_fid(cifs_sb, pfid,
1148-
&acllen);
1149-
else if (tcon->ses->server->ops->get_acl)
1150-
pntsd = tcon->ses->server->ops->get_acl(cifs_sb, inode, path,
1151-
&acllen);
1145+
ops = tlink_tcon(tlink)->ses->server->ops;
1146+
1147+
if (pfid && (ops->get_acl_by_fid))
1148+
pntsd = ops->get_acl_by_fid(cifs_sb, pfid, &acllen);
1149+
else if (ops->get_acl)
1150+
pntsd = ops->get_acl(cifs_sb, inode, path, &acllen);
11521151
else {
11531152
cifs_put_tlink(tlink);
11541153
return -EOPNOTSUPP;
@@ -1181,23 +1180,23 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,
11811180
struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
11821181
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
11831182
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
1184-
struct cifs_tcon *tcon;
1183+
struct smb_version_operations *ops;
11851184

11861185
if (IS_ERR(tlink))
11871186
return PTR_ERR(tlink);
1188-
tcon = tlink_tcon(tlink);
1187+
1188+
ops = tlink_tcon(tlink)->ses->server->ops;
11891189

11901190
cifs_dbg(NOISY, "set ACL from mode for %s\n", path);
11911191

11921192
/* Get the security descriptor */
11931193

1194-
if (tcon->ses->server->ops->get_acl == NULL) {
1194+
if (ops->get_acl == NULL) {
11951195
cifs_put_tlink(tlink);
11961196
return -EOPNOTSUPP;
11971197
}
11981198

1199-
pntsd = tcon->ses->server->ops->get_acl(cifs_sb, inode, path,
1200-
&secdesclen);
1199+
pntsd = ops->get_acl(cifs_sb, inode, path, &secdesclen);
12011200
if (IS_ERR(pntsd)) {
12021201
rc = PTR_ERR(pntsd);
12031202
cifs_dbg(VFS, "%s: error %d getting sec desc\n", __func__, rc);
@@ -1224,13 +1223,12 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode,
12241223

12251224
cifs_dbg(NOISY, "build_sec_desc rc: %d\n", rc);
12261225

1227-
if (tcon->ses->server->ops->set_acl == NULL)
1226+
if (ops->set_acl == NULL)
12281227
rc = -EOPNOTSUPP;
12291228

12301229
if (!rc) {
12311230
/* Set the security descriptor */
1232-
rc = tcon->ses->server->ops->set_acl(pnntsd, secdesclen, inode,
1233-
path, aclflag);
1231+
rc = ops->set_acl(pnntsd, secdesclen, inode, path, aclflag);
12341232
cifs_dbg(NOISY, "set_cifs_acl rc: %d\n", rc);
12351233
}
12361234
cifs_put_tlink(tlink);

fs/cifs/cifsglob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ struct smb_version_operations {
418418
int (*validate_negotiate)(const unsigned int, struct cifs_tcon *);
419419
ssize_t (*query_all_EAs)(const unsigned int, struct cifs_tcon *,
420420
const unsigned char *, const unsigned char *, char *,
421-
size_t, const struct nls_table *, int);
421+
size_t, struct cifs_sb_info *);
422422
int (*set_EA)(const unsigned int, struct cifs_tcon *, const char *,
423423
const char *, const void *, const __u16,
424424
const struct nls_table *, int);

fs/cifs/cifsproto.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,7 @@ extern int CIFSSMBCopy(unsigned int xid,
480480
extern ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
481481
const unsigned char *searchName,
482482
const unsigned char *ea_name, char *EAData,
483-
size_t bufsize, const struct nls_table *nls_codepage,
484-
int remap_special_chars);
483+
size_t bufsize, struct cifs_sb_info *cifs_sb);
485484
extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
486485
const char *fileName, const char *ea_name,
487486
const void *ea_value, const __u16 ea_value_len,

fs/cifs/cifssmb.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,7 @@ cifs_echo_callback(struct mid_q_entry *mid)
697697
{
698698
struct TCP_Server_Info *server = mid->callback_data;
699699

700-
mutex_lock(&server->srv_mutex);
701700
DeleteMidQEntry(mid);
702-
mutex_unlock(&server->srv_mutex);
703701
add_credits(server, 1, CIFS_ECHO_OP);
704702
}
705703

@@ -1599,9 +1597,7 @@ cifs_readv_callback(struct mid_q_entry *mid)
15991597
}
16001598

16011599
queue_work(cifsiod_wq, &rdata->work);
1602-
mutex_lock(&server->srv_mutex);
16031600
DeleteMidQEntry(mid);
1604-
mutex_unlock(&server->srv_mutex);
16051601
add_credits(server, 1, 0);
16061602
}
16071603

@@ -2058,7 +2054,6 @@ cifs_writev_callback(struct mid_q_entry *mid)
20582054
{
20592055
struct cifs_writedata *wdata = mid->callback_data;
20602056
struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
2061-
struct TCP_Server_Info *server = tcon->ses->server;
20622057
unsigned int written;
20632058
WRITE_RSP *smb = (WRITE_RSP *)mid->resp_buf;
20642059

@@ -2095,9 +2090,7 @@ cifs_writev_callback(struct mid_q_entry *mid)
20952090
}
20962091

20972092
queue_work(cifsiod_wq, &wdata->work);
2098-
mutex_lock(&server->srv_mutex);
20992093
DeleteMidQEntry(mid);
2100-
mutex_unlock(&server->srv_mutex);
21012094
add_credits(tcon->ses->server, 1, 0);
21022095
}
21032096

@@ -6076,11 +6069,13 @@ ssize_t
60766069
CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
60776070
const unsigned char *searchName, const unsigned char *ea_name,
60786071
char *EAData, size_t buf_size,
6079-
const struct nls_table *nls_codepage, int remap)
6072+
struct cifs_sb_info *cifs_sb)
60806073
{
60816074
/* BB assumes one setup word */
60826075
TRANSACTION2_QPI_REQ *pSMB = NULL;
60836076
TRANSACTION2_QPI_RSP *pSMBr = NULL;
6077+
int remap = cifs_remap(cifs_sb);
6078+
struct nls_table *nls_codepage = cifs_sb->local_nls;
60846079
int rc = 0;
60856080
int bytes_returned;
60866081
int list_len;

fs/cifs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ cifs_relock_file(struct cifsFileInfo *cfile)
582582
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
583583
int rc = 0;
584584

585-
down_read(&cinode->lock_sem);
585+
down_read_nested(&cinode->lock_sem, SINGLE_DEPTH_NESTING);
586586
if (cinode->can_cache_brlcks) {
587587
/* can cache locks - no need to relock */
588588
up_read(&cinode->lock_sem);

fs/cifs/inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,7 @@ static int cifs_sfu_mode(struct cifs_fattr *fattr, const unsigned char *path,
563563

564564
rc = tcon->ses->server->ops->query_all_EAs(xid, tcon, path,
565565
"SETFILEBITS", ea_value, 4 /* size of buf */,
566-
cifs_sb->local_nls,
567-
cifs_remap(cifs_sb));
566+
cifs_sb);
568567
cifs_put_tlink(tlink);
569568
if (rc < 0)
570569
return (int)rc;

fs/cifs/smb2pdu.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,15 +1240,19 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
12401240
goto tcon_exit;
12411241
}
12421242

1243-
if (rsp->ShareType & SMB2_SHARE_TYPE_DISK)
1243+
switch (rsp->ShareType) {
1244+
case SMB2_SHARE_TYPE_DISK:
12441245
cifs_dbg(FYI, "connection to disk share\n");
1245-
else if (rsp->ShareType & SMB2_SHARE_TYPE_PIPE) {
1246+
break;
1247+
case SMB2_SHARE_TYPE_PIPE:
12461248
tcon->ipc = true;
12471249
cifs_dbg(FYI, "connection to pipe share\n");
1248-
} else if (rsp->ShareType & SMB2_SHARE_TYPE_PRINT) {
1249-
tcon->print = true;
1250+
break;
1251+
case SMB2_SHARE_TYPE_PRINT:
1252+
tcon->ipc = true;
12501253
cifs_dbg(FYI, "connection to printer\n");
1251-
} else {
1254+
break;
1255+
default:
12521256
cifs_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
12531257
rc = -EOPNOTSUPP;
12541258
goto tcon_error_exit;
@@ -2173,9 +2177,7 @@ smb2_echo_callback(struct mid_q_entry *mid)
21732177
if (mid->mid_state == MID_RESPONSE_RECEIVED)
21742178
credits_received = le16_to_cpu(rsp->hdr.sync_hdr.CreditRequest);
21752179

2176-
mutex_lock(&server->srv_mutex);
21772180
DeleteMidQEntry(mid);
2178-
mutex_unlock(&server->srv_mutex);
21792181
add_credits(server, credits_received, CIFS_ECHO_OP);
21802182
}
21812183

@@ -2433,9 +2435,7 @@ smb2_readv_callback(struct mid_q_entry *mid)
24332435
cifs_stats_fail_inc(tcon, SMB2_READ_HE);
24342436

24352437
queue_work(cifsiod_wq, &rdata->work);
2436-
mutex_lock(&server->srv_mutex);
24372438
DeleteMidQEntry(mid);
2438-
mutex_unlock(&server->srv_mutex);
24392439
add_credits(server, credits_received, 0);
24402440
}
24412441

@@ -2594,7 +2594,6 @@ smb2_writev_callback(struct mid_q_entry *mid)
25942594
{
25952595
struct cifs_writedata *wdata = mid->callback_data;
25962596
struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
2597-
struct TCP_Server_Info *server = tcon->ses->server;
25982597
unsigned int written;
25992598
struct smb2_write_rsp *rsp = (struct smb2_write_rsp *)mid->resp_buf;
26002599
unsigned int credits_received = 1;
@@ -2634,9 +2633,7 @@ smb2_writev_callback(struct mid_q_entry *mid)
26342633
cifs_stats_fail_inc(tcon, SMB2_WRITE_HE);
26352634

26362635
queue_work(cifsiod_wq, &wdata->work);
2637-
mutex_lock(&server->srv_mutex);
26382636
DeleteMidQEntry(mid);
2639-
mutex_unlock(&server->srv_mutex);
26402637
add_credits(tcon->ses->server, credits_received, 0);
26412638
}
26422639

fs/cifs/transport.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
9494
now = jiffies;
9595
/* commands taking longer than one second are indications that
9696
something is wrong, unless it is quite a slow link or server */
97-
if ((now - midEntry->when_alloc) > HZ) {
97+
if (time_after(now, midEntry->when_alloc + HZ)) {
9898
if ((cifsFYI & CIFS_TIMER) && (midEntry->command != command)) {
9999
pr_debug(" CIFS slow rsp: cmd %d mid %llu",
100100
midEntry->command, midEntry->mid);
@@ -613,9 +613,7 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
613613
}
614614
spin_unlock(&GlobalMid_Lock);
615615

616-
mutex_lock(&server->srv_mutex);
617616
DeleteMidQEntry(mid);
618-
mutex_unlock(&server->srv_mutex);
619617
return rc;
620618
}
621619

fs/cifs/xattr.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
235235

236236
if (pTcon->ses->server->ops->query_all_EAs)
237237
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
238-
full_path, name, value, size,
239-
cifs_sb->local_nls, cifs_remap(cifs_sb));
238+
full_path, name, value, size, cifs_sb);
240239
break;
241240

242241
case XATTR_CIFS_ACL: {
@@ -336,8 +335,7 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)
336335

337336
if (pTcon->ses->server->ops->query_all_EAs)
338337
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
339-
full_path, NULL, data, buf_size,
340-
cifs_sb->local_nls, cifs_remap(cifs_sb));
338+
full_path, NULL, data, buf_size, cifs_sb);
341339
list_ea_exit:
342340
kfree(full_path);
343341
free_xid(xid);

0 commit comments

Comments
 (0)