diff options
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifs_unicode.c | 4 | ||||
-rw-r--r-- | fs/cifs/file.c | 86 |
2 files changed, 28 insertions, 62 deletions
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c index d2a8b2941fc2..793c4b95c164 100644 --- a/fs/cifs/cifs_unicode.c +++ b/fs/cifs/cifs_unicode.c | |||
@@ -74,8 +74,8 @@ cifs_strtoUCS(__le16 * to, const char *from, int len, | |||
74 | charlen = codepage->char2uni(from, len, &wchar_to[i]); | 74 | charlen = codepage->char2uni(from, len, &wchar_to[i]); |
75 | if (charlen < 1) { | 75 | if (charlen < 1) { |
76 | cERROR(1, | 76 | cERROR(1, |
77 | ("cifs_strtoUCS: char2uni returned %d", | 77 | ("strtoUCS: char2uni of %d returned %d", |
78 | charlen)); | 78 | (int)*from, charlen)); |
79 | /* A question mark */ | 79 | /* A question mark */ |
80 | to[i] = cpu_to_le16(0x003f); | 80 | to[i] = cpu_to_le16(0x003f); |
81 | charlen = 1; | 81 | charlen = 1; |
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 914b449f202e..467cf89c039f 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -338,8 +338,7 @@ static int cifs_relock_file(struct cifsFileInfo *cifsFile) | |||
338 | return rc; | 338 | return rc; |
339 | } | 339 | } |
340 | 340 | ||
341 | static int cifs_reopen_file(struct inode *inode, struct file *file, | 341 | static int cifs_reopen_file(struct file *file, int can_flush) |
342 | int can_flush) | ||
343 | { | 342 | { |
344 | int rc = -EACCES; | 343 | int rc = -EACCES; |
345 | int xid, oplock; | 344 | int xid, oplock; |
@@ -347,13 +346,12 @@ static int cifs_reopen_file(struct inode *inode, struct file *file, | |||
347 | struct cifsTconInfo *pTcon; | 346 | struct cifsTconInfo *pTcon; |
348 | struct cifsFileInfo *pCifsFile; | 347 | struct cifsFileInfo *pCifsFile; |
349 | struct cifsInodeInfo *pCifsInode; | 348 | struct cifsInodeInfo *pCifsInode; |
349 | struct inode * inode; | ||
350 | char *full_path = NULL; | 350 | char *full_path = NULL; |
351 | int desiredAccess; | 351 | int desiredAccess; |
352 | int disposition = FILE_OPEN; | 352 | int disposition = FILE_OPEN; |
353 | __u16 netfid; | 353 | __u16 netfid; |
354 | 354 | ||
355 | if (inode == NULL) | ||
356 | return -EBADF; | ||
357 | if (file->private_data) { | 355 | if (file->private_data) { |
358 | pCifsFile = (struct cifsFileInfo *)file->private_data; | 356 | pCifsFile = (struct cifsFileInfo *)file->private_data; |
359 | } else | 357 | } else |
@@ -368,25 +366,37 @@ static int cifs_reopen_file(struct inode *inode, struct file *file, | |||
368 | } | 366 | } |
369 | 367 | ||
370 | if (file->f_path.dentry == NULL) { | 368 | if (file->f_path.dentry == NULL) { |
371 | up(&pCifsFile->fh_sem); | 369 | cERROR(1, ("no valid name if dentry freed")); |
372 | cFYI(1, ("failed file reopen, no valid name if dentry freed")); | 370 | dump_stack(); |
373 | FreeXid(xid); | 371 | rc = -EBADF; |
374 | return -EBADF; | 372 | goto reopen_error_exit; |
373 | } | ||
374 | |||
375 | inode = file->f_path.dentry->d_inode; | ||
376 | if(inode == NULL) { | ||
377 | cERROR(1, ("inode not valid")); | ||
378 | dump_stack(); | ||
379 | rc = -EBADF; | ||
380 | goto reopen_error_exit; | ||
375 | } | 381 | } |
382 | |||
376 | cifs_sb = CIFS_SB(inode->i_sb); | 383 | cifs_sb = CIFS_SB(inode->i_sb); |
377 | pTcon = cifs_sb->tcon; | 384 | pTcon = cifs_sb->tcon; |
385 | |||
378 | /* can not grab rename sem here because various ops, including | 386 | /* can not grab rename sem here because various ops, including |
379 | those that already have the rename sem can end up causing writepage | 387 | those that already have the rename sem can end up causing writepage |
380 | to get called and if the server was down that means we end up here, | 388 | to get called and if the server was down that means we end up here, |
381 | and we can never tell if the caller already has the rename_sem */ | 389 | and we can never tell if the caller already has the rename_sem */ |
382 | full_path = build_path_from_dentry(file->f_path.dentry); | 390 | full_path = build_path_from_dentry(file->f_path.dentry); |
383 | if (full_path == NULL) { | 391 | if (full_path == NULL) { |
392 | rc = -ENOMEM; | ||
393 | reopen_error_exit: | ||
384 | up(&pCifsFile->fh_sem); | 394 | up(&pCifsFile->fh_sem); |
385 | FreeXid(xid); | 395 | FreeXid(xid); |
386 | return -ENOMEM; | 396 | return rc; |
387 | } | 397 | } |
388 | 398 | ||
389 | cFYI(1, (" inode = 0x%p file flags are 0x%x for %s", | 399 | cFYI(1, ("inode = 0x%p file flags 0x%x for %s", |
390 | inode, file->f_flags,full_path)); | 400 | inode, file->f_flags,full_path)); |
391 | desiredAccess = cifs_convert_flags(file->f_flags); | 401 | desiredAccess = cifs_convert_flags(file->f_flags); |
392 | 402 | ||
@@ -401,13 +411,6 @@ static int cifs_reopen_file(struct inode *inode, struct file *file, | |||
401 | and server version of file size can be stale. If we knew for sure | 411 | and server version of file size can be stale. If we knew for sure |
402 | that inode was not dirty locally we could do this */ | 412 | that inode was not dirty locally we could do this */ |
403 | 413 | ||
404 | /* buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); | ||
405 | if (buf == 0) { | ||
406 | up(&pCifsFile->fh_sem); | ||
407 | kfree(full_path); | ||
408 | FreeXid(xid); | ||
409 | return -ENOMEM; | ||
410 | } */ | ||
411 | rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, | 414 | rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, desiredAccess, |
412 | CREATE_NOT_DIR, &netfid, &oplock, NULL, | 415 | CREATE_NOT_DIR, &netfid, &oplock, NULL, |
413 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & | 416 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & |
@@ -831,17 +834,11 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, | |||
831 | return -EBADF; | 834 | return -EBADF; |
832 | } | 835 | } |
833 | if (open_file->invalidHandle) { | 836 | if (open_file->invalidHandle) { |
834 | if ((file->f_path.dentry == NULL) || | ||
835 | (file->f_path.dentry->d_inode == NULL)) { | ||
836 | FreeXid(xid); | ||
837 | return total_written; | ||
838 | } | ||
839 | /* we could deadlock if we called | 837 | /* we could deadlock if we called |
840 | filemap_fdatawait from here so tell | 838 | filemap_fdatawait from here so tell |
841 | reopen_file not to flush data to server | 839 | reopen_file not to flush data to server |
842 | now */ | 840 | now */ |
843 | rc = cifs_reopen_file(file->f_path.dentry->d_inode, | 841 | rc = cifs_reopen_file(file, FALSE); |
844 | file, FALSE); | ||
845 | if (rc != 0) | 842 | if (rc != 0) |
846 | break; | 843 | break; |
847 | } | 844 | } |
@@ -941,8 +938,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, | |||
941 | filemap_fdatawait from here so tell | 938 | filemap_fdatawait from here so tell |
942 | reopen_file not to flush data to | 939 | reopen_file not to flush data to |
943 | server now */ | 940 | server now */ |
944 | rc = cifs_reopen_file(file->f_path.dentry->d_inode, | 941 | rc = cifs_reopen_file(file, FALSE); |
945 | file, FALSE); | ||
946 | if (rc != 0) | 942 | if (rc != 0) |
947 | break; | 943 | break; |
948 | } | 944 | } |
@@ -1031,8 +1027,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) | |||
1031 | read_unlock(&GlobalSMBSeslock); | 1027 | read_unlock(&GlobalSMBSeslock); |
1032 | if((open_file->invalidHandle) && | 1028 | if((open_file->invalidHandle) && |
1033 | (!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) { | 1029 | (!open_file->closePend) /* BB fixme -since the second clause can not be true remove it BB */) { |
1034 | rc = cifs_reopen_file(&cifs_inode->vfs_inode, | 1030 | rc = cifs_reopen_file(open_file->pfile, FALSE); |
1035 | open_file->pfile, FALSE); | ||
1036 | /* if it fails, try another handle - might be */ | 1031 | /* if it fails, try another handle - might be */ |
1037 | /* dangerous to hold up writepages with retry */ | 1032 | /* dangerous to hold up writepages with retry */ |
1038 | if(rc) { | 1033 | if(rc) { |
@@ -1379,32 +1374,6 @@ static int cifs_commit_write(struct file *file, struct page *page, | |||
1379 | spin_lock(&inode->i_lock); | 1374 | spin_lock(&inode->i_lock); |
1380 | if (position > inode->i_size) { | 1375 | if (position > inode->i_size) { |
1381 | i_size_write(inode, position); | 1376 | i_size_write(inode, position); |
1382 | /* if (file->private_data == NULL) { | ||
1383 | rc = -EBADF; | ||
1384 | } else { | ||
1385 | open_file = (struct cifsFileInfo *)file->private_data; | ||
1386 | cifs_sb = CIFS_SB(inode->i_sb); | ||
1387 | rc = -EAGAIN; | ||
1388 | while (rc == -EAGAIN) { | ||
1389 | if ((open_file->invalidHandle) && | ||
1390 | (!open_file->closePend)) { | ||
1391 | rc = cifs_reopen_file( | ||
1392 | file->f_path.dentry->d_inode, file); | ||
1393 | if (rc != 0) | ||
1394 | break; | ||
1395 | } | ||
1396 | if (!open_file->closePend) { | ||
1397 | rc = CIFSSMBSetFileSize(xid, | ||
1398 | cifs_sb->tcon, position, | ||
1399 | open_file->netfid, | ||
1400 | open_file->pid, FALSE); | ||
1401 | } else { | ||
1402 | rc = -EBADF; | ||
1403 | break; | ||
1404 | } | ||
1405 | } | ||
1406 | cFYI(1, (" SetEOF (commit write) rc = %d", rc)); | ||
1407 | } */ | ||
1408 | } | 1377 | } |
1409 | spin_unlock(&inode->i_lock); | 1378 | spin_unlock(&inode->i_lock); |
1410 | if (!PageUptodate(page)) { | 1379 | if (!PageUptodate(page)) { |
@@ -1548,8 +1517,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, | |||
1548 | int buf_type = CIFS_NO_BUFFER; | 1517 | int buf_type = CIFS_NO_BUFFER; |
1549 | if ((open_file->invalidHandle) && | 1518 | if ((open_file->invalidHandle) && |
1550 | (!open_file->closePend)) { | 1519 | (!open_file->closePend)) { |
1551 | rc = cifs_reopen_file(file->f_path.dentry->d_inode, | 1520 | rc = cifs_reopen_file(file, TRUE); |
1552 | file, TRUE); | ||
1553 | if (rc != 0) | 1521 | if (rc != 0) |
1554 | break; | 1522 | break; |
1555 | } | 1523 | } |
@@ -1635,8 +1603,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, | |||
1635 | while (rc == -EAGAIN) { | 1603 | while (rc == -EAGAIN) { |
1636 | if ((open_file->invalidHandle) && | 1604 | if ((open_file->invalidHandle) && |
1637 | (!open_file->closePend)) { | 1605 | (!open_file->closePend)) { |
1638 | rc = cifs_reopen_file(file->f_path.dentry->d_inode, | 1606 | rc = cifs_reopen_file(file, TRUE); |
1639 | file, TRUE); | ||
1640 | if (rc != 0) | 1607 | if (rc != 0) |
1641 | break; | 1608 | break; |
1642 | } | 1609 | } |
@@ -1792,8 +1759,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, | |||
1792 | while (rc == -EAGAIN) { | 1759 | while (rc == -EAGAIN) { |
1793 | if ((open_file->invalidHandle) && | 1760 | if ((open_file->invalidHandle) && |
1794 | (!open_file->closePend)) { | 1761 | (!open_file->closePend)) { |
1795 | rc = cifs_reopen_file(file->f_path.dentry->d_inode, | 1762 | rc = cifs_reopen_file(file, TRUE); |
1796 | file, TRUE); | ||
1797 | if (rc != 0) | 1763 | if (rc != 0) |
1798 | break; | 1764 | break; |
1799 | } | 1765 | } |