aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2005-12-02 16:32:45 -0500
committerSteve French <sfrench@us.ibm.com>2005-12-02 16:32:45 -0500
commit84afc29b185334f489975a003b128e1b15e24a54 (patch)
treeab9544be46e3c52fcf799bb9bbf14c0db7b94b37 /fs/cifs
parentbf8206791750854bc6668266b694e8fe2cacb924 (diff)
[CIFS] Readpages and readir performance improvements - eliminate extra
memcpy. Part 1 Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/CHANGES3
-rw-r--r--fs/cifs/cifsencrypt.c55
-rw-r--r--fs/cifs/cifsproto.h6
-rw-r--r--fs/cifs/cifssmb.c5
-rw-r--r--fs/cifs/file.c6
-rw-r--r--fs/cifs/transport.c19
6 files changed, 71 insertions, 23 deletions
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 8bef2f3a4130..1d2137561c55 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,6 +1,7 @@
1Version 1.40 1Version 1.40
2------------ 2------------
3Use fsuid (fsgid) more consistently instead of uid (gid). 3Use fsuid (fsgid) more consistently instead of uid (gid). Improve performance
4of readpages by eliminating one extra memcpy.
4 5
5Version 1.39 6Version 1.39
6------------ 7------------
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index fe2bb7c4c912..a2c24858d40f 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * fs/cifs/cifsencrypt.c 2 * fs/cifs/cifsencrypt.c
3 * 3 *
4 * Copyright (C) International Business Machines Corp., 2003 4 * Copyright (C) International Business Machines Corp., 2005
5 * Author(s): Steve French (sfrench@us.ibm.com) 5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 6 *
7 * This library is free software; you can redistribute it and/or modify 7 * This library is free software; you can redistribute it and/or modify
@@ -82,6 +82,59 @@ int cifs_sign_smb(struct smb_hdr * cifs_pdu, struct TCP_Server_Info * server,
82 return rc; 82 return rc;
83} 83}
84 84
85static int cifs_calc_signature2(const struct kvec * iov, int n_vec,
86 const char * key, char * signature)
87{
88 struct MD5Context context;
89
90 if((iov == NULL) || (signature == NULL))
91 return -EINVAL;
92
93 MD5Init(&context);
94 MD5Update(&context,key,CIFS_SESSION_KEY_SIZE+16);
95
96/* MD5Update(&context,cifs_pdu->Protocol,cifs_pdu->smb_buf_length); */ /* BB FIXME BB */
97
98 MD5Final(signature,&context);
99
100 return -EOPNOTSUPP;
101/* return 0; */
102}
103
104
105int cifs_sign_smb2(struct kvec * iov, int n_vec, struct TCP_Server_Info *server,
106 __u32 * pexpected_response_sequence_number)
107{
108 int rc = 0;
109 char smb_signature[20];
110 struct smb_hdr * cifs_pdu = iov[0].iov_base;
111
112 if((cifs_pdu == NULL) || (server == NULL))
113 return -EINVAL;
114
115 if((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) == 0)
116 return rc;
117
118 spin_lock(&GlobalMid_Lock);
119 cifs_pdu->Signature.Sequence.SequenceNumber =
120 cpu_to_le32(server->sequence_number);
121 cifs_pdu->Signature.Sequence.Reserved = 0;
122
123 *pexpected_response_sequence_number = server->sequence_number++;
124 server->sequence_number++;
125 spin_unlock(&GlobalMid_Lock);
126
127 rc = cifs_calc_signature2(iov, n_vec, server->mac_signing_key,
128 smb_signature);
129 if(rc)
130 memset(cifs_pdu->Signature.SecuritySignature, 0, 8);
131 else
132 memcpy(cifs_pdu->Signature.SecuritySignature, smb_signature, 8);
133
134 return rc;
135
136}
137
85int cifs_verify_signature(struct smb_hdr * cifs_pdu, const char * mac_key, 138int cifs_verify_signature(struct smb_hdr * cifs_pdu, const char * mac_key,
86 __u32 expected_sequence_number) 139 __u32 expected_sequence_number)
87{ 140{
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 1b73f4f4c5ce..c058f8a45b2b 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -48,7 +48,7 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *,
48 struct smb_hdr * /* out */ , 48 struct smb_hdr * /* out */ ,
49 int * /* bytes returned */ , const int long_op); 49 int * /* bytes returned */ , const int long_op);
50extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *, 50extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *,
51 struct kvec *, int /* nvec */, 51 struct kvec *, int /* nvec to send */,
52 int * /* bytes returned */ , const int long_op); 52 int * /* bytes returned */ , const int long_op);
53extern int checkSMBhdr(struct smb_hdr *smb, __u16 mid); 53extern int checkSMBhdr(struct smb_hdr *smb, __u16 mid);
54extern int checkSMB(struct smb_hdr *smb, __u16 mid, int length); 54extern int checkSMB(struct smb_hdr *smb, __u16 mid, int length);
@@ -237,12 +237,10 @@ extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
237 const __u64 lseek, unsigned int *nbytes, 237 const __u64 lseek, unsigned int *nbytes,
238 const char *buf, const char __user *ubuf, 238 const char *buf, const char __user *ubuf,
239 const int long_op); 239 const int long_op);
240#ifdef CONFIG_CIFS_EXPERIMENTAL
241extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, 240extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
242 const int netfid, const unsigned int count, 241 const int netfid, const unsigned int count,
243 const __u64 offset, unsigned int *nbytes, 242 const __u64 offset, unsigned int *nbytes,
244 struct kvec *iov, const int nvec, const int long_op); 243 struct kvec *iov, const int nvec, const int long_op);
245#endif /* CONFIG_CIFS_EXPERIMENTAL */
246extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, 244extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
247 const unsigned char *searchName, __u64 * inode_number, 245 const unsigned char *searchName, __u64 * inode_number,
248 const struct nls_table *nls_codepage, 246 const struct nls_table *nls_codepage,
@@ -269,6 +267,8 @@ extern void tconInfoFree(struct cifsTconInfo *);
269extern int cifs_reconnect(struct TCP_Server_Info *server); 267extern int cifs_reconnect(struct TCP_Server_Info *server);
270 268
271extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *,__u32 *); 269extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *,__u32 *);
270extern int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *,
271 __u32 *);
272extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key, 272extern int cifs_verify_signature(struct smb_hdr *, const char * mac_key,
273 __u32 expected_sequence_number); 273 __u32 expected_sequence_number);
274extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass); 274extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 6867e556d37e..3565d3bf2e32 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1155,7 +1155,6 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
1155 return rc; 1155 return rc;
1156} 1156}
1157 1157
1158#ifdef CONFIG_CIFS_EXPERIMENTAL
1159int 1158int
1160CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, 1159CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1161 const int netfid, const unsigned int count, 1160 const int netfid, const unsigned int count,
@@ -1223,7 +1222,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1223 *nbytes = le16_to_cpu(pSMBr->CountHigh); 1222 *nbytes = le16_to_cpu(pSMBr->CountHigh);
1224 *nbytes = (*nbytes) << 16; 1223 *nbytes = (*nbytes) << 16;
1225 *nbytes += le16_to_cpu(pSMBr->Count); 1224 *nbytes += le16_to_cpu(pSMBr->Count);
1226 } 1225 }
1227 1226
1228 cifs_small_buf_release(pSMB); 1227 cifs_small_buf_release(pSMB);
1229 1228
@@ -1234,8 +1233,6 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
1234} 1233}
1235 1234
1236 1235
1237#endif /* CIFS_EXPERIMENTAL */
1238
1239int 1236int
1240CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, 1237CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1241 const __u16 smb_file_id, const __u64 len, 1238 const __u16 smb_file_id, const __u64 len,
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 14a1c72ced92..b67be3d8c019 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -870,7 +870,6 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
870 if (rc != 0) 870 if (rc != 0)
871 break; 871 break;
872 } 872 }
873#ifdef CONFIG_CIFS_EXPERIMENTAL
874 /* BB FIXME We can not sign across two buffers yet */ 873 /* BB FIXME We can not sign across two buffers yet */
875 if((experimEnabled) && ((pTcon->ses->server->secMode & 874 if((experimEnabled) && ((pTcon->ses->server->secMode &
876 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) == 0)) { 875 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) == 0)) {
@@ -889,7 +888,6 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
889 iov, 1, long_op); 888 iov, 1, long_op);
890 } else 889 } else
891 /* BB FIXME fixup indentation of line below */ 890 /* BB FIXME fixup indentation of line below */
892#endif
893 rc = CIFSSMBWrite(xid, pTcon, 891 rc = CIFSSMBWrite(xid, pTcon,
894 open_file->netfid, 892 open_file->netfid,
895 min_t(const int, cifs_sb->wsize, 893 min_t(const int, cifs_sb->wsize,
@@ -1026,7 +1024,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
1026 return rc; 1024 return rc;
1027} 1025}
1028 1026
1029#ifdef CONFIG_CIFS_EXPERIMENTAL
1030static int cifs_writepages(struct address_space *mapping, 1027static int cifs_writepages(struct address_space *mapping,
1031 struct writeback_control *wbc) 1028 struct writeback_control *wbc)
1032{ 1029{
@@ -1229,7 +1226,6 @@ retry:
1229 1226
1230 return rc; 1227 return rc;
1231} 1228}
1232#endif
1233 1229
1234static int cifs_writepage(struct page* page, struct writeback_control *wbc) 1230static int cifs_writepage(struct page* page, struct writeback_control *wbc)
1235{ 1231{
@@ -1875,9 +1871,7 @@ struct address_space_operations cifs_addr_ops = {
1875 .readpage = cifs_readpage, 1871 .readpage = cifs_readpage,
1876 .readpages = cifs_readpages, 1872 .readpages = cifs_readpages,
1877 .writepage = cifs_writepage, 1873 .writepage = cifs_writepage,
1878#ifdef CONFIG_CIFS_EXPERIMENTAL
1879 .writepages = cifs_writepages, 1874 .writepages = cifs_writepages,
1880#endif
1881 .prepare_write = cifs_prepare_write, 1875 .prepare_write = cifs_prepare_write,
1882 .commit_write = cifs_commit_write, 1876 .commit_write = cifs_commit_write,
1883 .set_page_dirty = __set_page_dirty_nobuffers, 1877 .set_page_dirty = __set_page_dirty_nobuffers,
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index f8871196098c..0abfbf4e4a49 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -206,7 +206,6 @@ smb_send(struct socket *ssocket, struct smb_hdr *smb_buffer,
206 return rc; 206 return rc;
207} 207}
208 208
209#ifdef CONFIG_CIFS_EXPERIMENTAL
210static int 209static int
211smb_send2(struct socket *ssocket, struct kvec *iov, int n_vec, 210smb_send2(struct socket *ssocket, struct kvec *iov, int n_vec,
212 struct sockaddr *sin) 211 struct sockaddr *sin)
@@ -392,8 +391,7 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
392 return -ENOMEM; 391 return -ENOMEM;
393 } 392 }
394 393
395/* BB FIXME */ 394 rc = cifs_sign_smb2(iov, n_vec, ses->server, &midQ->sequence_number);
396/* rc = cifs_sign_smb2(iov, n_vec, ses->server, &midQ->sequence_number); */
397 395
398 midQ->midState = MID_REQUEST_SUBMITTED; 396 midQ->midState = MID_REQUEST_SUBMITTED;
399#ifdef CONFIG_CIFS_STATS2 397#ifdef CONFIG_CIFS_STATS2
@@ -492,11 +490,17 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
492 490
493 if (midQ->resp_buf && 491 if (midQ->resp_buf &&
494 (midQ->midState == MID_RESPONSE_RECEIVED)) { 492 (midQ->midState == MID_RESPONSE_RECEIVED)) {
493
495 in_buf->smb_buf_length = receive_len; 494 in_buf->smb_buf_length = receive_len;
496 /* BB verify that length would not overrun small buf */ 495 if(receive_len > 500) {
497 memcpy((char *)in_buf + 4, 496 /* use multiple buffers on way out */
498 (char *)midQ->resp_buf + 4, 497 } else {
499 receive_len); 498 memcpy((char *)in_buf + 4,
499 (char *)midQ->resp_buf + 4,
500 receive_len);
501 iov[0].iov_len = receive_len + 4;
502 iov[1].iov_len = 0;
503 }
500 504
501 dump_smb(in_buf, 80); 505 dump_smb(in_buf, 80);
502 /* convert the length into a more usable form */ 506 /* convert the length into a more usable form */
@@ -549,7 +553,6 @@ out_unlock2:
549 553
550 return rc; 554 return rc;
551} 555}
552#endif /* CIFS_EXPERIMENTAL */
553 556
554int 557int
555SendReceive(const unsigned int xid, struct cifsSesInfo *ses, 558SendReceive(const unsigned int xid, struct cifsSesInfo *ses,