@@ -534,7 +534,6 @@ void _cifsFileInfo_put(struct cifsFileInfo *cifs_file,
cancel_work_sync(&cifs_file->oplock_break) : false;
if (!tcon->need_reconnect && !cifs_file->invalidHandle) {
- struct TCP_Server_Info *server = tcon->ses->server;
unsigned int xid;
xid = get_xid();
@@ -1787,6 +1786,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
struct TCP_Server_Info *server = tcon->ses->server;
struct inode *inode = d_inode(cfile->dentry);
+ struct cifsLockInfo *lock_info;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (posix_lck) {
@@ -1811,48 +1811,44 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
goto out;
}
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
- if (lock) {
- struct cifsLockInfo *lock;
-
- lock = cifs_lock_init(flock->fl_start, length, type,
- flock->fl_flags);
- if (!lock)
- return -ENOMEM;
+ if (unlock) {
+ rc = server->ops->mand_unlock_range(cfile, flock, xid);
+ goto out;
+ }
- rc = cifs_lock_add_if(cfile, lock, wait_flag);
- if (rc < 0) {
- kfree(lock);
- return rc;
- }
- if (!rc)
- goto out;
+ /* lock == true */
+ lock_info = cifs_lock_init(flock->fl_start, length, type, flock->fl_flags);
+ if (!lock_info)
+ return -ENOMEM;
- /*
- * Windows 7 server can delay breaking lease from read to None
- * if we set a byte-range lock on a file - break it explicitly
- * before sending the lock to the server to be sure the next
- * read won't conflict with non-overlapted locks due to
- * pagereading.
- */
- if (!CIFS_CACHE_WRITE(CIFS_I(inode)) &&
- CIFS_CACHE_READ(CIFS_I(inode))) {
- cifs_zap_mapping(inode);
- cifs_dbg(FYI, "Set no oplock for inode=%p due to mand locks\n",
- inode);
- CIFS_I(inode)->oplock = 0;
- }
+ rc = cifs_lock_add_if(cfile, lock_info, wait_flag);
+ if (rc < 0) {
+ kfree(lock_info);
+ return rc;
+ }
+ if (!rc)
+ goto out;
- rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length,
- type, 1, 0, wait_flag);
- if (rc) {
- kfree(lock);
- return rc;
- }
+ /*
+ * Windows 7 server can delay breaking lease from read to None
+ * if we set a byte-range lock on a file - break it explicitly
+ * before sending the lock to the server to be sure the next
+ * read won't conflict with non-overlapted locks due to
+ * pagereading.
+ */
+ if (!CIFS_CACHE_WRITE(CIFS_I(inode)) && CIFS_CACHE_READ(CIFS_I(inode))) {
+ cifs_zap_mapping(inode);
+ cifs_dbg(FYI, "Set no oplock for inode=%p due to mand locks\n", inode);
+ CIFS_I(inode)->oplock = 0;
+ }
- cifs_lock_add(cfile, lock);
- } else if (unlock)
- rc = server->ops->mand_unlock_range(cfile, flock, xid);
+ rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type, 1, 0, wait_flag);
+ if (rc) {
+ kfree(lock_info);
+ return rc;
+ }
+ cifs_lock_add(cfile, lock_info);
out:
if ((flock->fl_flags & FL_POSIX) || (flock->fl_flags & FL_FLOCK)) {
/*
@@ -26,18 +26,6 @@
#include "cifsproto.h"
#include "../smbfs_common/md4.h"
-#ifndef false
-#define false 0
-#endif
-#ifndef true
-#define true 1
-#endif
-
-/* following came from the other byteorder.h to avoid include conflicts */
-#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
-#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
-#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((__u16)(val)))
-
/* produce a md4 message digest from data of length n bytes */
static int
mdfour(unsigned char *md4_hash, unsigned char *link_str, int link_len)