Skip to content

Commit ad8b15f

Browse files
author
Steve French
committed
[CIFS] list entry can not return null
Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent 0510eeb commit ad8b15f

File tree

4 files changed

+61
-74
lines changed

4 files changed

+61
-74
lines changed

fs/cifs/cifs_debug.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,25 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
7979
spin_lock(&GlobalMid_Lock);
8080
list_for_each(tmp, &server->pending_mid_q) {
8181
mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
82-
if (mid_entry) {
83-
cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
84-
mid_entry->midState,
85-
(int)mid_entry->command,
86-
mid_entry->pid,
87-
mid_entry->tsk,
88-
mid_entry->mid));
82+
cERROR(1, ("State: %d Cmd: %d Pid: %d Tsk: %p Mid %d",
83+
mid_entry->midState,
84+
(int)mid_entry->command,
85+
mid_entry->pid,
86+
mid_entry->tsk,
87+
mid_entry->mid));
8988
#ifdef CONFIG_CIFS_STATS2
90-
cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
91-
mid_entry->largeBuf,
92-
mid_entry->resp_buf,
93-
mid_entry->when_received,
94-
jiffies));
89+
cERROR(1, ("IsLarge: %d buf: %p time rcv: %ld now: %ld",
90+
mid_entry->largeBuf,
91+
mid_entry->resp_buf,
92+
mid_entry->when_received,
93+
jiffies));
9594
#endif /* STATS2 */
96-
cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
97-
mid_entry->multiEnd));
98-
if (mid_entry->resp_buf) {
99-
cifs_dump_detail(mid_entry->resp_buf);
100-
cifs_dump_mem("existing buf: ",
101-
mid_entry->resp_buf, 62);
102-
}
95+
cERROR(1, ("IsMult: %d IsEnd: %d", mid_entry->multiRsp,
96+
mid_entry->multiEnd));
97+
if (mid_entry->resp_buf) {
98+
cifs_dump_detail(mid_entry->resp_buf);
99+
cifs_dump_mem("existing buf: ",
100+
mid_entry->resp_buf, 62);
103101
}
104102
}
105103
spin_unlock(&GlobalMid_Lock);
@@ -163,16 +161,13 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
163161
mid_entry = list_entry(tmp1, struct
164162
mid_q_entry,
165163
qhead);
166-
if (mid_entry) {
167-
seq_printf(m,
168-
"State: %d com: %d pid:"
169-
" %d tsk: %p mid %d\n",
170-
mid_entry->midState,
171-
(int)mid_entry->command,
172-
mid_entry->pid,
173-
mid_entry->tsk,
174-
mid_entry->mid);
175-
}
164+
seq_printf(m, "State: %d com: %d pid:"
165+
" %d tsk: %p mid %d\n",
166+
mid_entry->midState,
167+
(int)mid_entry->command,
168+
mid_entry->pid,
169+
mid_entry->tsk,
170+
mid_entry->mid);
176171
}
177172
spin_unlock(&GlobalMid_Lock);
178173
}

fs/cifs/cifsfs.c

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -930,52 +930,48 @@ static int cifs_oplock_thread(void *dummyarg)
930930
schedule_timeout(39*HZ);
931931
} else {
932932
oplock_item = list_entry(GlobalOplock_Q.next,
933-
struct oplock_q_entry, qhead);
934-
if (oplock_item) {
935-
cFYI(1, ("found oplock item to write out"));
936-
pTcon = oplock_item->tcon;
937-
inode = oplock_item->pinode;
938-
netfid = oplock_item->netfid;
939-
spin_unlock(&GlobalMid_Lock);
940-
DeleteOplockQEntry(oplock_item);
941-
/* can not grab inode sem here since it would
933+
struct oplock_q_entry, qhead);
934+
cFYI(1, ("found oplock item to write out"));
935+
pTcon = oplock_item->tcon;
936+
inode = oplock_item->pinode;
937+
netfid = oplock_item->netfid;
938+
spin_unlock(&GlobalMid_Lock);
939+
DeleteOplockQEntry(oplock_item);
940+
/* can not grab inode sem here since it would
942941
deadlock when oplock received on delete
943942
since vfs_unlink holds the i_mutex across
944943
the call */
945-
/* mutex_lock(&inode->i_mutex);*/
946-
if (S_ISREG(inode->i_mode)) {
947-
rc =
948-
filemap_fdatawrite(inode->i_mapping);
949-
if (CIFS_I(inode)->clientCanCacheRead
950-
== 0) {
951-
waitrc = filemap_fdatawait(inode->i_mapping);
952-
invalidate_remote_inode(inode);
953-
}
954-
if (rc == 0)
955-
rc = waitrc;
956-
} else
957-
rc = 0;
958-
/* mutex_unlock(&inode->i_mutex);*/
959-
if (rc)
960-
CIFS_I(inode)->write_behind_rc = rc;
961-
cFYI(1, ("Oplock flush inode %p rc %d",
962-
inode, rc));
944+
/* mutex_lock(&inode->i_mutex);*/
945+
if (S_ISREG(inode->i_mode)) {
946+
rc = filemap_fdatawrite(inode->i_mapping);
947+
if (CIFS_I(inode)->clientCanCacheRead == 0) {
948+
waitrc = filemap_fdatawait(
949+
inode->i_mapping);
950+
invalidate_remote_inode(inode);
951+
}
952+
if (rc == 0)
953+
rc = waitrc;
954+
} else
955+
rc = 0;
956+
/* mutex_unlock(&inode->i_mutex);*/
957+
if (rc)
958+
CIFS_I(inode)->write_behind_rc = rc;
959+
cFYI(1, ("Oplock flush inode %p rc %d",
960+
inode, rc));
963961

964962
/* releasing stale oplock after recent reconnect
965963
of smb session using a now incorrect file
966964
handle is not a data integrity issue but do
967965
not bother sending an oplock release if session
968966
to server still is disconnected since oplock
969967
already released by the server in that case */
970-
if (pTcon->tidStatus != CifsNeedReconnect) {
971-
rc = CIFSSMBLock(0, pTcon, netfid,
972-
0 /* len */ , 0 /* offset */, 0,
973-
0, LOCKING_ANDX_OPLOCK_RELEASE,
974-
false /* wait flag */);
975-
cFYI(1, ("Oplock release rc = %d", rc));
976-
}
977-
} else
978-
spin_unlock(&GlobalMid_Lock);
968+
if (pTcon->tidStatus != CifsNeedReconnect) {
969+
rc = CIFSSMBLock(0, pTcon, netfid,
970+
0 /* len */ , 0 /* offset */, 0,
971+
0, LOCKING_ANDX_OPLOCK_RELEASE,
972+
false /* wait flag */);
973+
cFYI(1, ("Oplock release rc = %d", rc));
974+
}
979975
set_current_state(TASK_INTERRUPTIBLE);
980976
schedule_timeout(1); /* yield in case q were corrupt */
981977
}
@@ -1001,8 +997,7 @@ static int cifs_dnotify_thread(void *dummyarg)
1001997
list_for_each(tmp, &GlobalSMBSessionList) {
1002998
ses = list_entry(tmp, struct cifsSesInfo,
1003999
cifsSessionList);
1004-
if (ses && ses->server &&
1005-
atomic_read(&ses->server->inFlight))
1000+
if (ses->server && atomic_read(&ses->server->inFlight))
10061001
wake_up_all(&ses->server->response_q);
10071002
}
10081003
read_unlock(&GlobalSMBSeslock);

fs/cifs/cifssmb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
128128
write_lock(&GlobalSMBSeslock);
129129
list_for_each_safe(tmp, tmp1, &pTcon->openFileList) {
130130
open_file = list_entry(tmp, struct cifsFileInfo, tlist);
131-
if (open_file)
132-
open_file->invalidHandle = true;
131+
open_file->invalidHandle = true;
133132
}
134133
write_unlock(&GlobalSMBSeslock);
135134
/* BB Add call to invalidate_inodes(sb) for all superblocks mounted

fs/cifs/connect.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
151151
}
152152
list_for_each(tmp, &GlobalTreeConnectionList) {
153153
tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
154-
if ((tcon) && (tcon->ses) && (tcon->ses->server == server))
154+
if ((tcon->ses) && (tcon->ses->server == server))
155155
tcon->tidStatus = CifsNeedReconnect;
156156
}
157157
read_unlock(&GlobalSMBSeslock);
@@ -173,14 +173,12 @@ cifs_reconnect(struct TCP_Server_Info *server)
173173
mid_entry = list_entry(tmp, struct
174174
mid_q_entry,
175175
qhead);
176-
if (mid_entry) {
177-
if (mid_entry->midState == MID_REQUEST_SUBMITTED) {
176+
if (mid_entry->midState == MID_REQUEST_SUBMITTED) {
178177
/* Mark other intransit requests as needing
179178
retry so we do not immediately mark the
180179
session bad again (ie after we reconnect
181180
below) as they timeout too */
182-
mid_entry->midState = MID_RETRY_NEEDED;
183-
}
181+
mid_entry->midState = MID_RETRY_NEEDED;
184182
}
185183
}
186184
spin_unlock(&GlobalMid_Lock);

0 commit comments

Comments
 (0)