diff options
-rw-r--r-- | fs/cifs/cifsfs.c | 33 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 10 | ||||
-rw-r--r-- | fs/cifs/file.c | 28 | ||||
-rw-r--r-- | fs/cifs/inode.c | 8 | ||||
-rw-r--r-- | fs/cifs/misc.c | 12 | ||||
-rw-r--r-- | fs/cifs/smb1ops.c | 4 | ||||
-rw-r--r-- | fs/cifs/smb2file.c | 20 | ||||
-rw-r--r-- | fs/cifs/smb2misc.c | 6 | ||||
-rw-r--r-- | fs/cifs/smb2ops.c | 4 |
9 files changed, 64 insertions, 61 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index d70e551f0bfb..ab88efe014a5 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -733,7 +733,7 @@ static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
733 | 733 | ||
734 | written = generic_file_aio_write(iocb, iov, nr_segs, pos); | 734 | written = generic_file_aio_write(iocb, iov, nr_segs, pos); |
735 | 735 | ||
736 | if (CIFS_I(inode)->clientCanCacheAll) | 736 | if (CIFS_CACHE_WRITE(CIFS_I(inode))) |
737 | return written; | 737 | return written; |
738 | 738 | ||
739 | rc = filemap_fdatawrite(inode->i_mapping); | 739 | rc = filemap_fdatawrite(inode->i_mapping); |
@@ -758,7 +758,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int whence) | |||
758 | * We need to be sure that all dirty pages are written and the | 758 | * We need to be sure that all dirty pages are written and the |
759 | * server has the newest file length. | 759 | * server has the newest file length. |
760 | */ | 760 | */ |
761 | if (!CIFS_I(inode)->clientCanCacheRead && inode->i_mapping && | 761 | if (!CIFS_CACHE_READ(CIFS_I(inode)) && inode->i_mapping && |
762 | inode->i_mapping->nrpages != 0) { | 762 | inode->i_mapping->nrpages != 0) { |
763 | rc = filemap_fdatawait(inode->i_mapping); | 763 | rc = filemap_fdatawait(inode->i_mapping); |
764 | if (rc) { | 764 | if (rc) { |
@@ -782,8 +782,10 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int whence) | |||
782 | 782 | ||
783 | static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) | 783 | static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) |
784 | { | 784 | { |
785 | /* note that this is called by vfs setlease with i_lock held | 785 | /* |
786 | to protect *lease from going away */ | 786 | * Note that this is called by vfs setlease with i_lock held to |
787 | * protect *lease from going away. | ||
788 | */ | ||
787 | struct inode *inode = file_inode(file); | 789 | struct inode *inode = file_inode(file); |
788 | struct cifsFileInfo *cfile = file->private_data; | 790 | struct cifsFileInfo *cfile = file->private_data; |
789 | 791 | ||
@@ -791,20 +793,19 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) | |||
791 | return -EINVAL; | 793 | return -EINVAL; |
792 | 794 | ||
793 | /* check if file is oplocked */ | 795 | /* check if file is oplocked */ |
794 | if (((arg == F_RDLCK) && | 796 | if (((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) || |
795 | (CIFS_I(inode)->clientCanCacheRead)) || | 797 | ((arg == F_WRLCK) && CIFS_CACHE_WRITE(CIFS_I(inode)))) |
796 | ((arg == F_WRLCK) && | ||
797 | (CIFS_I(inode)->clientCanCacheAll))) | ||
798 | return generic_setlease(file, arg, lease); | 798 | return generic_setlease(file, arg, lease); |
799 | else if (tlink_tcon(cfile->tlink)->local_lease && | 799 | else if (tlink_tcon(cfile->tlink)->local_lease && |
800 | !CIFS_I(inode)->clientCanCacheRead) | 800 | !CIFS_CACHE_READ(CIFS_I(inode))) |
801 | /* If the server claims to support oplock on this | 801 | /* |
802 | file, then we still need to check oplock even | 802 | * If the server claims to support oplock on this file, then we |
803 | if the local_lease mount option is set, but there | 803 | * still need to check oplock even if the local_lease mount |
804 | are servers which do not support oplock for which | 804 | * option is set, but there are servers which do not support |
805 | this mount option may be useful if the user | 805 | * oplock for which this mount option may be useful if the user |
806 | knows that the file won't be changed on the server | 806 | * knows that the file won't be changed on the server by anyone |
807 | by anyone else */ | 807 | * else. |
808 | */ | ||
808 | return generic_setlease(file, arg, lease); | 809 | return generic_setlease(file, arg, lease); |
809 | else | 810 | else |
810 | return -EAGAIN; | 811 | return -EAGAIN; |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 92798f74f0c3..fe739bd8246d 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -1031,6 +1031,13 @@ cifsFileInfo_get_locked(struct cifsFileInfo *cifs_file) | |||
1031 | struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file); | 1031 | struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file); |
1032 | void cifsFileInfo_put(struct cifsFileInfo *cifs_file); | 1032 | void cifsFileInfo_put(struct cifsFileInfo *cifs_file); |
1033 | 1033 | ||
1034 | #define CIFS_CACHE_READ_FLG 1 | ||
1035 | #define CIFS_CACHE_HANDLE_FLG 2 | ||
1036 | #define CIFS_CACHE_WRITE_FLG 4 | ||
1037 | |||
1038 | #define CIFS_CACHE_READ(cinode) (cinode->oplock & CIFS_CACHE_READ_FLG) | ||
1039 | #define CIFS_CACHE_WRITE(cinode) (cinode->oplock & CIFS_CACHE_WRITE_FLG) | ||
1040 | |||
1034 | /* | 1041 | /* |
1035 | * One of these for each file inode | 1042 | * One of these for each file inode |
1036 | */ | 1043 | */ |
@@ -1042,8 +1049,7 @@ struct cifsInodeInfo { | |||
1042 | /* BB add in lists for dirty pages i.e. write caching info for oplock */ | 1049 | /* BB add in lists for dirty pages i.e. write caching info for oplock */ |
1043 | struct list_head openFileList; | 1050 | struct list_head openFileList; |
1044 | __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ | 1051 | __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ |
1045 | bool clientCanCacheRead; /* read oplock */ | 1052 | unsigned int oplock; /* oplock/lease level we have */ |
1046 | bool clientCanCacheAll; /* read and writebehind oplock */ | ||
1047 | bool delete_pending; /* DELETE_ON_CLOSE is set */ | 1053 | bool delete_pending; /* DELETE_ON_CLOSE is set */ |
1048 | bool invalid_mapping; /* pagecache is invalid */ | 1054 | bool invalid_mapping; /* pagecache is invalid */ |
1049 | unsigned long time; /* jiffies of last update of inode */ | 1055 | unsigned long time; /* jiffies of last update of inode */ |
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 9d0dd952ad79..ad14d3c66b25 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -1524,12 +1524,12 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, | |||
1524 | * read won't conflict with non-overlapted locks due to | 1524 | * read won't conflict with non-overlapted locks due to |
1525 | * pagereading. | 1525 | * pagereading. |
1526 | */ | 1526 | */ |
1527 | if (!CIFS_I(inode)->clientCanCacheAll && | 1527 | if (!CIFS_CACHE_WRITE(CIFS_I(inode)) && |
1528 | CIFS_I(inode)->clientCanCacheRead) { | 1528 | CIFS_CACHE_READ(CIFS_I(inode))) { |
1529 | cifs_invalidate_mapping(inode); | 1529 | cifs_invalidate_mapping(inode); |
1530 | cifs_dbg(FYI, "Set no oplock for inode=%p due to mand locks\n", | 1530 | cifs_dbg(FYI, "Set no oplock for inode=%p due to mand locks\n", |
1531 | inode); | 1531 | inode); |
1532 | CIFS_I(inode)->clientCanCacheRead = false; | 1532 | CIFS_I(inode)->oplock = 0; |
1533 | } | 1533 | } |
1534 | 1534 | ||
1535 | rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, | 1535 | rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, |
@@ -2213,7 +2213,7 @@ int cifs_strict_fsync(struct file *file, loff_t start, loff_t end, | |||
2213 | cifs_dbg(FYI, "Sync file - name: %s datasync: 0x%x\n", | 2213 | cifs_dbg(FYI, "Sync file - name: %s datasync: 0x%x\n", |
2214 | file->f_path.dentry->d_name.name, datasync); | 2214 | file->f_path.dentry->d_name.name, datasync); |
2215 | 2215 | ||
2216 | if (!CIFS_I(inode)->clientCanCacheRead) { | 2216 | if (!CIFS_CACHE_READ(CIFS_I(inode))) { |
2217 | rc = cifs_invalidate_mapping(inode); | 2217 | rc = cifs_invalidate_mapping(inode); |
2218 | if (rc) { | 2218 | if (rc) { |
2219 | cifs_dbg(FYI, "rc: %d during invalidate phase\n", rc); | 2219 | cifs_dbg(FYI, "rc: %d during invalidate phase\n", rc); |
@@ -2577,7 +2577,7 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2577 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); | 2577 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); |
2578 | ssize_t written; | 2578 | ssize_t written; |
2579 | 2579 | ||
2580 | if (cinode->clientCanCacheAll) { | 2580 | if (CIFS_CACHE_WRITE(cinode)) { |
2581 | if (cap_unix(tcon->ses) && | 2581 | if (cap_unix(tcon->ses) && |
2582 | (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) | 2582 | (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) |
2583 | && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) | 2583 | && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) |
@@ -2591,7 +2591,7 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2591 | * these pages but not on the region from pos to ppos+len-1. | 2591 | * these pages but not on the region from pos to ppos+len-1. |
2592 | */ | 2592 | */ |
2593 | written = cifs_user_writev(iocb, iov, nr_segs, pos); | 2593 | written = cifs_user_writev(iocb, iov, nr_segs, pos); |
2594 | if (written > 0 && cinode->clientCanCacheRead) { | 2594 | if (written > 0 && CIFS_CACHE_READ(cinode)) { |
2595 | /* | 2595 | /* |
2596 | * Windows 7 server can delay breaking level2 oplock if a write | 2596 | * Windows 7 server can delay breaking level2 oplock if a write |
2597 | * request comes - break it on the client to prevent reading | 2597 | * request comes - break it on the client to prevent reading |
@@ -2600,7 +2600,7 @@ cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2600 | cifs_invalidate_mapping(inode); | 2600 | cifs_invalidate_mapping(inode); |
2601 | cifs_dbg(FYI, "Set no oplock for inode=%p after a write operation\n", | 2601 | cifs_dbg(FYI, "Set no oplock for inode=%p after a write operation\n", |
2602 | inode); | 2602 | inode); |
2603 | cinode->clientCanCacheRead = false; | 2603 | cinode->oplock = 0; |
2604 | } | 2604 | } |
2605 | return written; | 2605 | return written; |
2606 | } | 2606 | } |
@@ -2957,7 +2957,7 @@ cifs_strict_readv(struct kiocb *iocb, const struct iovec *iov, | |||
2957 | * on pages affected by this read but not on the region from pos to | 2957 | * on pages affected by this read but not on the region from pos to |
2958 | * pos+len-1. | 2958 | * pos+len-1. |
2959 | */ | 2959 | */ |
2960 | if (!cinode->clientCanCacheRead) | 2960 | if (!CIFS_CACHE_READ(cinode)) |
2961 | return cifs_user_readv(iocb, iov, nr_segs, pos); | 2961 | return cifs_user_readv(iocb, iov, nr_segs, pos); |
2962 | 2962 | ||
2963 | if (cap_unix(tcon->ses) && | 2963 | if (cap_unix(tcon->ses) && |
@@ -3093,7 +3093,7 @@ int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) | |||
3093 | 3093 | ||
3094 | xid = get_xid(); | 3094 | xid = get_xid(); |
3095 | 3095 | ||
3096 | if (!CIFS_I(inode)->clientCanCacheRead) { | 3096 | if (!CIFS_CACHE_READ(CIFS_I(inode))) { |
3097 | rc = cifs_invalidate_mapping(inode); | 3097 | rc = cifs_invalidate_mapping(inode); |
3098 | if (rc) | 3098 | if (rc) |
3099 | return rc; | 3099 | return rc; |
@@ -3526,7 +3526,7 @@ static int cifs_write_begin(struct file *file, struct address_space *mapping, | |||
3526 | * is, when the page lies beyond the EOF, or straddles the EOF | 3526 | * is, when the page lies beyond the EOF, or straddles the EOF |
3527 | * and the write will cover all of the existing data. | 3527 | * and the write will cover all of the existing data. |
3528 | */ | 3528 | */ |
3529 | if (CIFS_I(mapping->host)->clientCanCacheRead) { | 3529 | if (CIFS_CACHE_READ(CIFS_I(mapping->host))) { |
3530 | i_size = i_size_read(mapping->host); | 3530 | i_size = i_size_read(mapping->host); |
3531 | if (page_start >= i_size || | 3531 | if (page_start >= i_size || |
3532 | (offset == 0 && (pos + len) >= i_size)) { | 3532 | (offset == 0 && (pos + len) >= i_size)) { |
@@ -3609,20 +3609,20 @@ void cifs_oplock_break(struct work_struct *work) | |||
3609 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); | 3609 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); |
3610 | int rc = 0; | 3610 | int rc = 0; |
3611 | 3611 | ||
3612 | if (!cinode->clientCanCacheAll && cinode->clientCanCacheRead && | 3612 | if (!CIFS_CACHE_WRITE(cinode) && CIFS_CACHE_READ(cinode) && |
3613 | cifs_has_mand_locks(cinode)) { | 3613 | cifs_has_mand_locks(cinode)) { |
3614 | cifs_dbg(FYI, "Reset oplock to None for inode=%p due to mand locks\n", | 3614 | cifs_dbg(FYI, "Reset oplock to None for inode=%p due to mand locks\n", |
3615 | inode); | 3615 | inode); |
3616 | cinode->clientCanCacheRead = false; | 3616 | cinode->oplock = 0; |
3617 | } | 3617 | } |
3618 | 3618 | ||
3619 | if (inode && S_ISREG(inode->i_mode)) { | 3619 | if (inode && S_ISREG(inode->i_mode)) { |
3620 | if (cinode->clientCanCacheRead) | 3620 | if (CIFS_CACHE_READ(cinode)) |
3621 | break_lease(inode, O_RDONLY); | 3621 | break_lease(inode, O_RDONLY); |
3622 | else | 3622 | else |
3623 | break_lease(inode, O_WRONLY); | 3623 | break_lease(inode, O_WRONLY); |
3624 | rc = filemap_fdatawrite(inode->i_mapping); | 3624 | rc = filemap_fdatawrite(inode->i_mapping); |
3625 | if (cinode->clientCanCacheRead == 0) { | 3625 | if (!CIFS_CACHE_READ(cinode)) { |
3626 | rc = filemap_fdatawait(inode->i_mapping); | 3626 | rc = filemap_fdatawait(inode->i_mapping); |
3627 | mapping_set_error(inode->i_mapping, rc); | 3627 | mapping_set_error(inode->i_mapping, rc); |
3628 | cifs_invalidate_mapping(inode); | 3628 | cifs_invalidate_mapping(inode); |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index ec0f3423cdac..e3bb6477c83f 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -101,7 +101,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr) | |||
101 | } | 101 | } |
102 | 102 | ||
103 | /* don't bother with revalidation if we have an oplock */ | 103 | /* don't bother with revalidation if we have an oplock */ |
104 | if (cifs_i->clientCanCacheRead) { | 104 | if (CIFS_CACHE_READ(cifs_i)) { |
105 | cifs_dbg(FYI, "%s: inode %llu is oplocked\n", | 105 | cifs_dbg(FYI, "%s: inode %llu is oplocked\n", |
106 | __func__, cifs_i->uniqueid); | 106 | __func__, cifs_i->uniqueid); |
107 | return; | 107 | return; |
@@ -650,7 +650,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, | |||
650 | cifs_dbg(FYI, "Getting info on %s\n", full_path); | 650 | cifs_dbg(FYI, "Getting info on %s\n", full_path); |
651 | 651 | ||
652 | if ((data == NULL) && (*inode != NULL)) { | 652 | if ((data == NULL) && (*inode != NULL)) { |
653 | if (CIFS_I(*inode)->clientCanCacheRead) { | 653 | if (CIFS_CACHE_READ(CIFS_I(*inode))) { |
654 | cifs_dbg(FYI, "No need to revalidate cached inode sizes\n"); | 654 | cifs_dbg(FYI, "No need to revalidate cached inode sizes\n"); |
655 | goto cgii_exit; | 655 | goto cgii_exit; |
656 | } | 656 | } |
@@ -1661,7 +1661,7 @@ cifs_inode_needs_reval(struct inode *inode) | |||
1661 | struct cifsInodeInfo *cifs_i = CIFS_I(inode); | 1661 | struct cifsInodeInfo *cifs_i = CIFS_I(inode); |
1662 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | 1662 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
1663 | 1663 | ||
1664 | if (cifs_i->clientCanCacheRead) | 1664 | if (CIFS_CACHE_READ(cifs_i)) |
1665 | return false; | 1665 | return false; |
1666 | 1666 | ||
1667 | if (!lookupCacheEnabled) | 1667 | if (!lookupCacheEnabled) |
@@ -1804,7 +1804,7 @@ int cifs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1804 | * We need to be sure that all dirty pages are written and the server | 1804 | * We need to be sure that all dirty pages are written and the server |
1805 | * has actual ctime, mtime and file length. | 1805 | * has actual ctime, mtime and file length. |
1806 | */ | 1806 | */ |
1807 | if (!CIFS_I(inode)->clientCanCacheRead && inode->i_mapping && | 1807 | if (!CIFS_CACHE_READ(CIFS_I(inode)) && inode->i_mapping && |
1808 | inode->i_mapping->nrpages != 0) { | 1808 | inode->i_mapping->nrpages != 0) { |
1809 | rc = filemap_fdatawait(inode->i_mapping); | 1809 | rc = filemap_fdatawait(inode->i_mapping); |
1810 | if (rc) { | 1810 | if (rc) { |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 82a2b9fb528a..138a011633fe 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -546,19 +546,15 @@ void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock) | |||
546 | oplock &= 0xF; | 546 | oplock &= 0xF; |
547 | 547 | ||
548 | if (oplock == OPLOCK_EXCLUSIVE) { | 548 | if (oplock == OPLOCK_EXCLUSIVE) { |
549 | cinode->clientCanCacheAll = true; | 549 | cinode->oplock = CIFS_CACHE_WRITE_FLG | CIFS_CACHE_READ_FLG; |
550 | cinode->clientCanCacheRead = true; | ||
551 | cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n", | 550 | cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n", |
552 | &cinode->vfs_inode); | 551 | &cinode->vfs_inode); |
553 | } else if (oplock == OPLOCK_READ) { | 552 | } else if (oplock == OPLOCK_READ) { |
554 | cinode->clientCanCacheAll = false; | 553 | cinode->oplock = CIFS_CACHE_READ_FLG; |
555 | cinode->clientCanCacheRead = true; | ||
556 | cifs_dbg(FYI, "Level II Oplock granted on inode %p\n", | 554 | cifs_dbg(FYI, "Level II Oplock granted on inode %p\n", |
557 | &cinode->vfs_inode); | 555 | &cinode->vfs_inode); |
558 | } else { | 556 | } else |
559 | cinode->clientCanCacheAll = false; | 557 | cinode->oplock = 0; |
560 | cinode->clientCanCacheRead = false; | ||
561 | } | ||
562 | } | 558 | } |
563 | 559 | ||
564 | bool | 560 | bool |
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index 8fe19c973ee4..6fd0677915a0 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c | |||
@@ -700,7 +700,7 @@ cifs_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock) | |||
700 | struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); | 700 | struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); |
701 | cfile->fid.netfid = fid->netfid; | 701 | cfile->fid.netfid = fid->netfid; |
702 | cifs_set_oplock_level(cinode, oplock); | 702 | cifs_set_oplock_level(cinode, oplock); |
703 | cinode->can_cache_brlcks = cinode->clientCanCacheAll; | 703 | cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode); |
704 | } | 704 | } |
705 | 705 | ||
706 | static void | 706 | static void |
@@ -837,7 +837,7 @@ cifs_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid, | |||
837 | { | 837 | { |
838 | return CIFSSMBLock(0, tcon, fid->netfid, current->tgid, 0, 0, 0, 0, | 838 | return CIFSSMBLock(0, tcon, fid->netfid, current->tgid, 0, 0, 0, 0, |
839 | LOCKING_ANDX_OPLOCK_RELEASE, false, | 839 | LOCKING_ANDX_OPLOCK_RELEASE, false, |
840 | cinode->clientCanCacheRead ? 1 : 0); | 840 | CIFS_CACHE_READ(cinode) ? 1 : 0); |
841 | } | 841 | } |
842 | 842 | ||
843 | static int | 843 | static int |
diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index 020245d5c9a7..4564787dc7d7 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c | |||
@@ -40,21 +40,21 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock) | |||
40 | oplock &= 0xFF; | 40 | oplock &= 0xFF; |
41 | if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE) | 41 | if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE) |
42 | return; | 42 | return; |
43 | if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE || | 43 | if (oplock == SMB2_OPLOCK_LEVEL_BATCH) { |
44 | oplock == SMB2_OPLOCK_LEVEL_BATCH) { | 44 | cinode->oplock = CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG | |
45 | cinode->clientCanCacheAll = true; | 45 | CIFS_CACHE_HANDLE_FLG; |
46 | cinode->clientCanCacheRead = true; | 46 | cifs_dbg(FYI, "Batch Oplock granted on inode %p\n", |
47 | &cinode->vfs_inode); | ||
48 | } else if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) { | ||
49 | cinode->oplock = CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG; | ||
47 | cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n", | 50 | cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n", |
48 | &cinode->vfs_inode); | 51 | &cinode->vfs_inode); |
49 | } else if (oplock == SMB2_OPLOCK_LEVEL_II) { | 52 | } else if (oplock == SMB2_OPLOCK_LEVEL_II) { |
50 | cinode->clientCanCacheAll = false; | 53 | cinode->oplock = CIFS_CACHE_READ_FLG; |
51 | cinode->clientCanCacheRead = true; | ||
52 | cifs_dbg(FYI, "Level II Oplock granted on inode %p\n", | 54 | cifs_dbg(FYI, "Level II Oplock granted on inode %p\n", |
53 | &cinode->vfs_inode); | 55 | &cinode->vfs_inode); |
54 | } else { | 56 | } else |
55 | cinode->clientCanCacheAll = false; | 57 | cinode->oplock = 0; |
56 | cinode->clientCanCacheRead = false; | ||
57 | } | ||
58 | } | 58 | } |
59 | 59 | ||
60 | int | 60 | int |
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c index 314bd60f30ce..8d1a8898fd13 100644 --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c | |||
@@ -380,9 +380,9 @@ cifs_convert_path_to_utf16(const char *from, struct cifs_sb_info *cifs_sb) | |||
380 | __le32 | 380 | __le32 |
381 | smb2_get_lease_state(struct cifsInodeInfo *cinode) | 381 | smb2_get_lease_state(struct cifsInodeInfo *cinode) |
382 | { | 382 | { |
383 | if (cinode->clientCanCacheAll) | 383 | if (CIFS_CACHE_WRITE(cinode)) |
384 | return SMB2_LEASE_WRITE_CACHING | SMB2_LEASE_READ_CACHING; | 384 | return SMB2_LEASE_WRITE_CACHING | SMB2_LEASE_READ_CACHING; |
385 | else if (cinode->clientCanCacheRead) | 385 | else if (CIFS_CACHE_READ(cinode)) |
386 | return SMB2_LEASE_READ_CACHING; | 386 | return SMB2_LEASE_READ_CACHING; |
387 | return 0; | 387 | return 0; |
388 | } | 388 | } |
@@ -576,7 +576,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server) | |||
576 | cifs_dbg(FYI, "file id match, oplock break\n"); | 576 | cifs_dbg(FYI, "file id match, oplock break\n"); |
577 | cinode = CIFS_I(cfile->dentry->d_inode); | 577 | cinode = CIFS_I(cfile->dentry->d_inode); |
578 | 578 | ||
579 | if (!cinode->clientCanCacheAll && | 579 | if (!CIFS_CACHE_WRITE(cinode) && |
580 | rsp->OplockLevel == SMB2_OPLOCK_LEVEL_NONE) | 580 | rsp->OplockLevel == SMB2_OPLOCK_LEVEL_NONE) |
581 | cfile->oplock_break_cancelled = true; | 581 | cfile->oplock_break_cancelled = true; |
582 | else | 582 | else |
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 91b9e5422e9a..96c9d3da3f41 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c | |||
@@ -380,7 +380,7 @@ smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock) | |||
380 | cfile->fid.persistent_fid = fid->persistent_fid; | 380 | cfile->fid.persistent_fid = fid->persistent_fid; |
381 | cfile->fid.volatile_fid = fid->volatile_fid; | 381 | cfile->fid.volatile_fid = fid->volatile_fid; |
382 | smb2_set_oplock_level(cinode, oplock); | 382 | smb2_set_oplock_level(cinode, oplock); |
383 | cinode->can_cache_brlcks = cinode->clientCanCacheAll; | 383 | cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode); |
384 | } | 384 | } |
385 | 385 | ||
386 | static void | 386 | static void |
@@ -531,7 +531,7 @@ smb2_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid, | |||
531 | 531 | ||
532 | return SMB2_oplock_break(0, tcon, fid->persistent_fid, | 532 | return SMB2_oplock_break(0, tcon, fid->persistent_fid, |
533 | fid->volatile_fid, | 533 | fid->volatile_fid, |
534 | cinode->clientCanCacheRead ? 1 : 0); | 534 | CIFS_CACHE_READ(cinode) ? 1 : 0); |
535 | } | 535 | } |
536 | 536 | ||
537 | static int | 537 | static int |