aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/misc.c
diff options
context:
space:
mode:
authorPavel Shilovsky <piastryyy@gmail.com>2010-11-02 05:00:42 -0400
committerSteve French <sfrench@us.ibm.com>2010-11-02 14:40:54 -0400
commite66673e39ac9d4749bd9676dd1caf928095409f5 (patch)
treef16191d689910a4f939992d8836e575195633116 /fs/cifs/misc.c
parentce2f6fb8bd8c1e85f288033020dfc31c9fc2be94 (diff)
CIFS: Add cifs_set_oplock_level
Simplify many places when we need to set oplock level on an inode. Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/misc.c')
-rw-r--r--fs/cifs/misc.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index c4e296fe3518..d3b9ddebc17e 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -569,10 +569,9 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
569 569
570 cFYI(1, "file id match, oplock break"); 570 cFYI(1, "file id match, oplock break");
571 pCifsInode = CIFS_I(netfile->dentry->d_inode); 571 pCifsInode = CIFS_I(netfile->dentry->d_inode);
572 pCifsInode->clientCanCacheAll = false;
573 if (pSMB->OplockLevel == 0)
574 pCifsInode->clientCanCacheRead = false;
575 572
573 cifs_set_oplock_level(netfile->dentry->d_inode,
574 pSMB->OplockLevel);
576 /* 575 /*
577 * cifs_oplock_break_put() can't be called 576 * cifs_oplock_break_put() can't be called
578 * from here. Get reference after queueing 577 * from here. Get reference after queueing
@@ -722,3 +721,21 @@ cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
722 cifs_sb_master_tcon(cifs_sb)->treeName); 721 cifs_sb_master_tcon(cifs_sb)->treeName);
723 } 722 }
724} 723}
724
725void cifs_set_oplock_level(struct inode *inode, __u32 oplock)
726{
727 struct cifsInodeInfo *cinode = CIFS_I(inode);
728
729 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
730 cinode->clientCanCacheAll = true;
731 cinode->clientCanCacheRead = true;
732 cFYI(1, "Exclusive Oplock granted on inode %p", inode);
733 } else if ((oplock & 0xF) == OPLOCK_READ) {
734 cinode->clientCanCacheAll = false;
735 cinode->clientCanCacheRead = true;
736 cFYI(1, "Level II Oplock granted on inode %p", inode);
737 } else {
738 cinode->clientCanCacheAll = false;
739 cinode->clientCanCacheRead = false;
740 }
741}