Skip to content

Commit c6ea21e

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: cifs: prevent infinite recursion in cifs_reconnect_tcon cifs: set backing_dev_info on new S_ISREG inodes
2 parents f4a3330 + f569599 commit c6ea21e

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

fs/cifs/cifssmb.c

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static int
232232
small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
233233
void **request_buf)
234234
{
235-
int rc = 0;
235+
int rc;
236236

237237
rc = cifs_reconnect_tcon(tcon, smb_command);
238238
if (rc)
@@ -250,7 +250,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
250250
if (tcon != NULL)
251251
cifs_stats_inc(&tcon->num_smbs_sent);
252252

253-
return rc;
253+
return 0;
254254
}
255255

256256
int
@@ -281,16 +281,9 @@ small_smb_init_no_tc(const int smb_command, const int wct,
281281

282282
/* If the return code is zero, this function must fill in request_buf pointer */
283283
static int
284-
smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
285-
void **request_buf /* returned */ ,
286-
void **response_buf /* returned */ )
284+
__smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
285+
void **request_buf, void **response_buf)
287286
{
288-
int rc = 0;
289-
290-
rc = cifs_reconnect_tcon(tcon, smb_command);
291-
if (rc)
292-
return rc;
293-
294287
*request_buf = cifs_buf_get();
295288
if (*request_buf == NULL) {
296289
/* BB should we add a retry in here if not a writepage? */
@@ -309,7 +302,31 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
309302
if (tcon != NULL)
310303
cifs_stats_inc(&tcon->num_smbs_sent);
311304

312-
return rc;
305+
return 0;
306+
}
307+
308+
/* If the return code is zero, this function must fill in request_buf pointer */
309+
static int
310+
smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
311+
void **request_buf, void **response_buf)
312+
{
313+
int rc;
314+
315+
rc = cifs_reconnect_tcon(tcon, smb_command);
316+
if (rc)
317+
return rc;
318+
319+
return __smb_init(smb_command, wct, tcon, request_buf, response_buf);
320+
}
321+
322+
static int
323+
smb_init_no_reconnect(int smb_command, int wct, struct cifsTconInfo *tcon,
324+
void **request_buf, void **response_buf)
325+
{
326+
if (tcon->ses->need_reconnect || tcon->need_reconnect)
327+
return -EHOSTDOWN;
328+
329+
return __smb_init(smb_command, wct, tcon, request_buf, response_buf);
313330
}
314331

315332
static int validate_t2(struct smb_t2_rsp *pSMB)
@@ -4534,8 +4551,8 @@ CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon)
45344551

45354552
cFYI(1, "In QFSUnixInfo");
45364553
QFSUnixRetry:
4537-
rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
4538-
(void **) &pSMBr);
4554+
rc = smb_init_no_reconnect(SMB_COM_TRANSACTION2, 15, tcon,
4555+
(void **) &pSMB, (void **) &pSMBr);
45394556
if (rc)
45404557
return rc;
45414558

@@ -4604,8 +4621,8 @@ CIFSSMBSetFSUnixInfo(const int xid, struct cifsTconInfo *tcon, __u64 cap)
46044621
cFYI(1, "In SETFSUnixInfo");
46054622
SETFSUnixRetry:
46064623
/* BB switch to small buf init to save memory */
4607-
rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
4608-
(void **) &pSMBr);
4624+
rc = smb_init_no_reconnect(SMB_COM_TRANSACTION2, 15, tcon,
4625+
(void **) &pSMB, (void **) &pSMBr);
46094626
if (rc)
46104627
return rc;
46114628

fs/cifs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,8 @@ cifs_iget(struct super_block *sb, struct cifs_fattr *fattr)
801801
inode->i_flags |= S_NOATIME | S_NOCMTIME;
802802
if (inode->i_state & I_NEW) {
803803
inode->i_ino = hash;
804+
if (S_ISREG(inode->i_mode))
805+
inode->i_data.backing_dev_info = sb->s_bdi;
804806
#ifdef CONFIG_CIFS_FSCACHE
805807
/* initialize per-inode cache cookie pointer */
806808
CIFS_I(inode)->fscache = NULL;

0 commit comments

Comments
 (0)