Skip to content

Commit

Permalink
Merge git://git.samba.org/sfrench/cifs-2.6
Browse files Browse the repository at this point in the history
* git://git.samba.org/sfrench/cifs-2.6:
  cifs: check for NULL last_entry before calling cifs_save_resume_key
  cifs: attempt to freeze while looping on a receive attempt
  cifs: Fix sparse warning when calling cifs_strtoUCS
  CIFS: Add descriptions to the brlock cache functions
  • Loading branch information
torvalds committed Dec 9, 2011
2 parents a776878 + 7023676 commit 8def5f5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
2 changes: 2 additions & 0 deletions fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ cifs_readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig,
smb_msg.msg_controllen = 0;

for (total_read = 0; to_read; total_read += length, to_read -= length) {
try_to_freeze();

if (server_unresponsive(server)) {
total_read = -EAGAIN;
break;
Expand Down
26 changes: 26 additions & 0 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ cifs_find_lock_conflict(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock,
lock->type, lock->netfid, conf_lock);
}

/*
* Check if there is another lock that prevents us to set the lock (mandatory
* style). If such a lock exists, update the flock structure with its
* properties. Otherwise, set the flock type to F_UNLCK if we can cache brlocks
* or leave it the same if we can't. Returns 0 if we don't need to request to
* the server or 1 otherwise.
*/
static int
cifs_lock_test(struct cifsInodeInfo *cinode, __u64 offset, __u64 length,
__u8 type, __u16 netfid, struct file_lock *flock)
Expand Down Expand Up @@ -739,6 +746,12 @@ cifs_lock_add(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock)
mutex_unlock(&cinode->lock_mutex);
}

/*
* Set the byte-range lock (mandatory style). Returns:
* 1) 0, if we set the lock and don't need to request to the server;
* 2) 1, if no locks prevent us but we need to request to the server;
* 3) -EACCESS, if there is a lock that prevents us and wait is false.
*/
static int
cifs_lock_add_if(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock,
bool wait)
Expand Down Expand Up @@ -778,6 +791,13 @@ cifs_lock_add_if(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock,
return rc;
}

/*
* Check if there is another lock that prevents us to set the lock (posix
* style). If such a lock exists, update the flock structure with its
* properties. Otherwise, set the flock type to F_UNLCK if we can cache brlocks
* or leave it the same if we can't. Returns 0 if we don't need to request to
* the server or 1 otherwise.
*/
static int
cifs_posix_lock_test(struct file *file, struct file_lock *flock)
{
Expand All @@ -800,6 +820,12 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock)
return rc;
}

/*
* Set the byte-range lock (posix style). Returns:
* 1) 0, if we set the lock and don't need to request to the server;
* 2) 1, if we need to request to the server;
* 3) <0, if the error occurs while setting the lock.
*/
static int
cifs_posix_lock_set(struct file *file, struct file_lock *flock)
{
Expand Down
10 changes: 8 additions & 2 deletions fs/cifs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,15 +554,21 @@ static int find_cifs_entry(const int xid, struct cifs_tcon *pTcon,
rc);
return rc;
}
cifs_save_resume_key(cifsFile->srch_inf.last_entry, cifsFile);
/* FindFirst/Next set last_entry to NULL on malformed reply */
if (cifsFile->srch_inf.last_entry)
cifs_save_resume_key(cifsFile->srch_inf.last_entry,
cifsFile);
}

while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
(rc == 0) && !cifsFile->srch_inf.endOfSearch) {
cFYI(1, "calling findnext2");
rc = CIFSFindNext(xid, pTcon, cifsFile->netfid,
&cifsFile->srch_inf);
cifs_save_resume_key(cifsFile->srch_inf.last_entry, cifsFile);
/* FindFirst/Next set last_entry to NULL on malformed reply */
if (cifsFile->srch_inf.last_entry)
cifs_save_resume_key(cifsFile->srch_inf.last_entry,
cifsFile);
if (rc)
return -ENOENT;
}
Expand Down
6 changes: 3 additions & 3 deletions fs/cifs/smbencrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16,
{
int rc;
int len;
__u16 wpwd[129];
__le16 wpwd[129];

/* Password cannot be longer than 128 characters */
if (passwd) /* Password must be converted to NT unicode */
Expand All @@ -219,8 +219,8 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16,
*wpwd = 0; /* Ensure string is null terminated */
}

rc = mdfour(p16, (unsigned char *) wpwd, len * sizeof(__u16));
memset(wpwd, 0, 129 * sizeof(__u16));
rc = mdfour(p16, (unsigned char *) wpwd, len * sizeof(__le16));
memset(wpwd, 0, 129 * sizeof(__le16));

return rc;
}
Expand Down

0 comments on commit 8def5f5

Please sign in to comment.