diff options
author | Pavel Shilovsky <pshilovsky@etersoft.ru> | 2012-09-19 09:22:43 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-09-24 22:46:33 -0400 |
commit | f7ba7fe685bc3ed8fd0687870e68b2567d17357f (patch) | |
tree | 364ff08cf616cc740467d44d5026a05ce9d0c33c /fs/cifs/smb2pdu.c | |
parent | 027e8eec31d8141a6231f772e10ccae60c9d5c13 (diff) |
CIFS: Add brlock support for SMB2
Signed-off-by: Pavel Shilovsky <pshilovsky@etersoft.ru>
Diffstat (limited to 'fs/cifs/smb2pdu.c')
-rw-r--r-- | fs/cifs/smb2pdu.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 1b447612200e..d3e1cfca3379 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -2047,3 +2047,62 @@ qinf_exit: | |||
2047 | free_rsp_buf(resp_buftype, iov.iov_base); | 2047 | free_rsp_buf(resp_buftype, iov.iov_base); |
2048 | return rc; | 2048 | return rc; |
2049 | } | 2049 | } |
2050 | |||
2051 | int | ||
2052 | smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon, | ||
2053 | const __u64 persist_fid, const __u64 volatile_fid, const __u32 pid, | ||
2054 | const __u32 num_lock, struct smb2_lock_element *buf) | ||
2055 | { | ||
2056 | int rc = 0; | ||
2057 | struct smb2_lock_req *req = NULL; | ||
2058 | struct kvec iov[2]; | ||
2059 | int resp_buf_type; | ||
2060 | unsigned int count; | ||
2061 | |||
2062 | cFYI(1, "smb2_lockv num lock %d", num_lock); | ||
2063 | |||
2064 | rc = small_smb2_init(SMB2_LOCK, tcon, (void **) &req); | ||
2065 | if (rc) | ||
2066 | return rc; | ||
2067 | |||
2068 | req->hdr.ProcessId = cpu_to_le32(pid); | ||
2069 | req->LockCount = cpu_to_le16(num_lock); | ||
2070 | |||
2071 | req->PersistentFileId = persist_fid; | ||
2072 | req->VolatileFileId = volatile_fid; | ||
2073 | |||
2074 | count = num_lock * sizeof(struct smb2_lock_element); | ||
2075 | inc_rfc1001_len(req, count - sizeof(struct smb2_lock_element)); | ||
2076 | |||
2077 | iov[0].iov_base = (char *)req; | ||
2078 | /* 4 for rfc1002 length field and count for all locks */ | ||
2079 | iov[0].iov_len = get_rfc1002_length(req) + 4 - count; | ||
2080 | iov[1].iov_base = (char *)buf; | ||
2081 | iov[1].iov_len = count; | ||
2082 | |||
2083 | cifs_stats_inc(&tcon->stats.cifs_stats.num_locks); | ||
2084 | rc = SendReceive2(xid, tcon->ses, iov, 2, &resp_buf_type, CIFS_NO_RESP); | ||
2085 | if (rc) { | ||
2086 | cFYI(1, "Send error in smb2_lockv = %d", rc); | ||
2087 | cifs_stats_fail_inc(tcon, SMB2_LOCK_HE); | ||
2088 | } | ||
2089 | |||
2090 | return rc; | ||
2091 | } | ||
2092 | |||
2093 | int | ||
2094 | SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon, | ||
2095 | const __u64 persist_fid, const __u64 volatile_fid, const __u32 pid, | ||
2096 | const __u64 length, const __u64 offset, const __u32 lock_flags, | ||
2097 | const bool wait) | ||
2098 | { | ||
2099 | struct smb2_lock_element lock; | ||
2100 | |||
2101 | lock.Offset = cpu_to_le64(offset); | ||
2102 | lock.Length = cpu_to_le64(length); | ||
2103 | lock.Flags = cpu_to_le32(lock_flags); | ||
2104 | if (!wait && lock_flags != SMB2_LOCKFLAG_UNLOCK) | ||
2105 | lock.Flags |= cpu_to_le32(SMB2_LOCKFLAG_FAIL_IMMEDIATELY); | ||
2106 | |||
2107 | return smb2_lockv(xid, tcon, persist_fid, volatile_fid, pid, 1, &lock); | ||
2108 | } | ||