Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6:
  [[CIFS] Pass truncate open flag through on file open in case setattr fails
  [CIFS] Fix typos in previous fix
  [CIFS] endian fix for new POSIX byte range lock support
  [CIFS] fix memory leak in cifs session info struct on reconnect
  [CIFS] ACPI suspend oops
  [CIFS] Do not limit the length of share names (was 100 for whole UNC name)
  [CIFS] Fix new POSIX Locking for setting lock_type correctly on unlock
  • Loading branch information
Linus Torvalds committed May 30, 2006
2 parents d1b3f96 + 55aa2e0 commit 2c56554
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 20 deletions.
7 changes: 7 additions & 0 deletions fs/cifs/CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 1.43
------------
POSIX locking to servers which support CIFS POSIX Extensions
(disabled by default controlled by proc/fs/cifs/Experimental).
Handle conversion of long share names (especially Asian languages)
to Unicode during mount.

Version 1.42
------------
Fix slow oplock break when mounted to different servers at the same time and
Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifsfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
extern int cifs_ioctl (struct inode * inode, struct file * filep,
unsigned int command, unsigned long arg);
#define CIFS_VERSION "1.42"
#define CIFS_VERSION "1.43"
#endif /* _CIFSFS_H */
2 changes: 1 addition & 1 deletion fs/cifs/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
const int waitFlag);
extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const int get_flag,
const __u64 len, const __u64 offset,
const __u64 len, struct file_lock *,
const __u16 lock_type, const int waitFlag);
extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon);
extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses);
Expand Down
40 changes: 35 additions & 5 deletions fs/cifs/cifssmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,8 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
int
CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const int get_flag, const __u64 len,
const __u64 lkoffset, const __u16 lock_type, const int waitFlag)
struct file_lock *pLockData, const __u16 lock_type,
const int waitFlag)
{
struct smb_com_transaction2_sfi_req *pSMB = NULL;
struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
Expand All @@ -1366,6 +1367,10 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
__u16 params, param_offset, offset, byte_count, count;

cFYI(1, ("Posix Lock"));

if(pLockData == NULL)
return EINVAL;

rc = small_smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB);

if (rc)
Expand Down Expand Up @@ -1404,10 +1409,10 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,

parm_data->lock_type = cpu_to_le16(lock_type);
if(waitFlag)
parm_data->lock_flags = 1;
parm_data->lock_flags = cpu_to_le16(1);
parm_data->pid = cpu_to_le32(current->tgid);
parm_data->start = lkoffset;
parm_data->length = len; /* normalize negative numbers */
parm_data->start = cpu_to_le64(pLockData->fl_start);
parm_data->length = cpu_to_le64(len); /* normalize negative numbers */

pSMB->DataOffset = cpu_to_le16(offset);
pSMB->Fid = smb_file_id;
Expand All @@ -1419,8 +1424,33 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) {
cFYI(1, ("Send error in Posix Lock = %d", rc));
}
} else if (get_flag) {
/* lock structure can be returned on get */
__u16 data_offset;
__u16 data_count;
rc = validate_t2((struct smb_t2_rsp *)pSMBr);

if (rc || (pSMBr->ByteCount < sizeof(struct cifs_posix_lock))) {
rc = -EIO; /* bad smb */
goto plk_err_exit;
}
if(pLockData == NULL) {
rc = -EINVAL;
goto plk_err_exit;
}
data_offset = le16_to_cpu(pSMBr->t2.DataOffset);
data_count = le16_to_cpu(pSMBr->t2.DataCount);
if(data_count < sizeof(struct cifs_posix_lock)) {
rc = -EIO;
goto plk_err_exit;
}
parm_data = (struct cifs_posix_lock *)
((char *)&pSMBr->hdr.Protocol + data_offset);
if(parm_data->lock_type == cpu_to_le16(CIFS_UNLCK))
pLockData->fl_type = F_UNLCK;
}

plk_err_exit:
if (pSMB)
cifs_small_buf_release(pSMB);

Expand Down
Loading

0 comments on commit 2c56554

Please sign in to comment.