提交 32b9aaf1 编写于 作者: P Pavel Shilovsky 提交者: Steve French

CIFS: Make cifs_push_locks send as many locks at once as possible

that reduces a traffic and increases a performance.
Signed-off-by: NPavel Shilovsky <piastry@etersoft.ru>
Acked-by: NJeff Layton <jlayton@redhat.com>
Signed-off-by: NSteve French <smfrench@gmail.com>
上级 9ee305b7
...@@ -829,6 +829,11 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -829,6 +829,11 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
struct cifsLockInfo *li, *tmp; struct cifsLockInfo *li, *tmp;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
unsigned int num, max_num;
LOCKING_ANDX_RANGE *buf, *cur;
int types[] = {LOCKING_ANDX_LARGE_FILES,
LOCKING_ANDX_SHARED_LOCK | LOCKING_ANDX_LARGE_FILES};
int i;
xid = GetXid(); xid = GetXid();
tcon = tlink_tcon(cfile->tlink); tcon = tlink_tcon(cfile->tlink);
...@@ -840,17 +845,49 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) ...@@ -840,17 +845,49 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile)
return rc; return rc;
} }
list_for_each_entry_safe(li, tmp, &cinode->llist, llist) { max_num = (tcon->ses->server->maxBuf - sizeof(struct smb_hdr)) /
stored_rc = CIFSSMBLock(xid, tcon, cfile->netfid, sizeof(LOCKING_ANDX_RANGE);
li->pid, li->length, li->offset, buf = kzalloc(max_num * sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL);
0, 1, li->type, 0, 0); if (!buf) {
if (stored_rc) mutex_unlock(&cinode->lock_mutex);
rc = stored_rc; FreeXid(xid);
return rc;
}
for (i = 0; i < 2; i++) {
cur = buf;
num = 0;
list_for_each_entry_safe(li, tmp, &cinode->llist, llist) {
if (li->type != types[i])
continue;
cur->Pid = cpu_to_le16(li->pid);
cur->LengthLow = cpu_to_le32((u32)li->length);
cur->LengthHigh = cpu_to_le32((u32)(li->length>>32));
cur->OffsetLow = cpu_to_le32((u32)li->offset);
cur->OffsetHigh = cpu_to_le32((u32)(li->offset>>32));
if (++num == max_num) {
stored_rc = cifs_lockv(xid, tcon, cfile->netfid,
li->type, 0, num, buf);
if (stored_rc)
rc = stored_rc;
cur = buf;
num = 0;
} else
cur++;
}
if (num) {
stored_rc = cifs_lockv(xid, tcon, cfile->netfid,
types[i], 0, num, buf);
if (stored_rc)
rc = stored_rc;
}
} }
cinode->can_cache_brlcks = false; cinode->can_cache_brlcks = false;
mutex_unlock(&cinode->lock_mutex); mutex_unlock(&cinode->lock_mutex);
kfree(buf);
FreeXid(xid); FreeXid(xid);
return rc; return rc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册