aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2017-04-09 22:08:53 -0400
committerSteve French <smfrench@gmail.com>2017-04-28 08:56:33 -0400
commita6f74e80f271b19ea709cbda55e8eb67e9ffccf2 (patch)
tree8ceb1cee86f26fb69c14d4d9e5d2478359f546e2
parent7d0c234fd2e1c9ca3fa032696c0c58b1b74a9e0b (diff)
cifs: don't check for failure from mempool_alloc()
mempool_alloc() cannot fail if the gfp flags allow it to sleep, and both GFP_FS allows for sleeping. So these tests of the return value from mempool_alloc() cannot be needed. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve French <smfrench@gmail.com>
-rw-r--r--fs/cifs/misc.c14
-rw-r--r--fs/cifs/smb2transport.c30
-rw-r--r--fs/cifs/transport.c32
3 files changed, 32 insertions, 44 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index d3fb11529ed9..843787850435 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -167,13 +167,11 @@ cifs_buf_get(void)
167 167
168 /* clear the first few header bytes */ 168 /* clear the first few header bytes */
169 /* for most paths, more is cleared in header_assemble */ 169 /* for most paths, more is cleared in header_assemble */
170 if (ret_buf) { 170 memset(ret_buf, 0, buf_size + 3);
171 memset(ret_buf, 0, buf_size + 3); 171 atomic_inc(&bufAllocCount);
172 atomic_inc(&bufAllocCount);
173#ifdef CONFIG_CIFS_STATS2 172#ifdef CONFIG_CIFS_STATS2
174 atomic_inc(&totBufAllocCount); 173 atomic_inc(&totBufAllocCount);
175#endif /* CONFIG_CIFS_STATS2 */ 174#endif /* CONFIG_CIFS_STATS2 */
176 }
177 175
178 return ret_buf; 176 return ret_buf;
179} 177}
@@ -201,15 +199,13 @@ cifs_small_buf_get(void)
201 albeit slightly larger than necessary and maxbuffersize 199 albeit slightly larger than necessary and maxbuffersize
202 defaults to this and can not be bigger */ 200 defaults to this and can not be bigger */
203 ret_buf = mempool_alloc(cifs_sm_req_poolp, GFP_NOFS); 201 ret_buf = mempool_alloc(cifs_sm_req_poolp, GFP_NOFS);
204 if (ret_buf) {
205 /* No need to clear memory here, cleared in header assemble */ 202 /* No need to clear memory here, cleared in header assemble */
206 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/ 203 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
207 atomic_inc(&smBufAllocCount); 204 atomic_inc(&smBufAllocCount);
208#ifdef CONFIG_CIFS_STATS2 205#ifdef CONFIG_CIFS_STATS2
209 atomic_inc(&totSmBufAllocCount); 206 atomic_inc(&totSmBufAllocCount);
210#endif /* CONFIG_CIFS_STATS2 */ 207#endif /* CONFIG_CIFS_STATS2 */
211 208
212 }
213 return ret_buf; 209 return ret_buf;
214} 210}
215 211
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index 506b67fc93d9..c69ec96e92ac 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -538,23 +538,19 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
538 } 538 }
539 539
540 temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS); 540 temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS);
541 if (temp == NULL) 541 memset(temp, 0, sizeof(struct mid_q_entry));
542 return temp; 542 temp->mid = le64_to_cpu(shdr->MessageId);
543 else { 543 temp->pid = current->pid;
544 memset(temp, 0, sizeof(struct mid_q_entry)); 544 temp->command = shdr->Command; /* Always LE */
545 temp->mid = le64_to_cpu(shdr->MessageId); 545 temp->when_alloc = jiffies;
546 temp->pid = current->pid; 546 temp->server = server;
547 temp->command = shdr->Command; /* Always LE */ 547
548 temp->when_alloc = jiffies; 548 /*
549 temp->server = server; 549 * The default is for the mid to be synchronous, so the
550 550 * default callback just wakes up the current task.
551 /* 551 */
552 * The default is for the mid to be synchronous, so the 552 temp->callback = cifs_wake_up_task;
553 * default callback just wakes up the current task. 553 temp->callback_data = current;
554 */
555 temp->callback = cifs_wake_up_task;
556 temp->callback_data = current;
557 }
558 554
559 atomic_inc(&midCount); 555 atomic_inc(&midCount);
560 temp->mid_state = MID_REQUEST_ALLOCATED; 556 temp->mid_state = MID_REQUEST_ALLOCATED;
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index f6e13a977fc8..4d64b5b8fc9c 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -55,26 +55,22 @@ AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
55 } 55 }
56 56
57 temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS); 57 temp = mempool_alloc(cifs_mid_poolp, GFP_NOFS);
58 if (temp == NULL) 58 memset(temp, 0, sizeof(struct mid_q_entry));
59 return temp; 59 temp->mid = get_mid(smb_buffer);
60 else { 60 temp->pid = current->pid;
61 memset(temp, 0, sizeof(struct mid_q_entry)); 61 temp->command = cpu_to_le16(smb_buffer->Command);
62 temp->mid = get_mid(smb_buffer); 62 cifs_dbg(FYI, "For smb_command %d\n", smb_buffer->Command);
63 temp->pid = current->pid;
64 temp->command = cpu_to_le16(smb_buffer->Command);
65 cifs_dbg(FYI, "For smb_command %d\n", smb_buffer->Command);
66 /* do_gettimeofday(&temp->when_sent);*/ /* easier to use jiffies */ 63 /* do_gettimeofday(&temp->when_sent);*/ /* easier to use jiffies */
67 /* when mid allocated can be before when sent */ 64 /* when mid allocated can be before when sent */
68 temp->when_alloc = jiffies; 65 temp->when_alloc = jiffies;
69 temp->server = server; 66 temp->server = server;
70 67
71 /* 68 /*
72 * The default is for the mid to be synchronous, so the 69 * The default is for the mid to be synchronous, so the
73 * default callback just wakes up the current task. 70 * default callback just wakes up the current task.
74 */ 71 */
75 temp->callback = cifs_wake_up_task; 72 temp->callback = cifs_wake_up_task;
76 temp->callback_data = current; 73 temp->callback_data = current;
77 }
78 74
79 atomic_inc(&midCount); 75 atomic_inc(&midCount);
80 temp->mid_state = MID_REQUEST_ALLOCATED; 76 temp->mid_state = MID_REQUEST_ALLOCATED;