diff options
author | Pavel Shilovsky <piastry@etersoft.ru> | 2011-10-22 07:33:32 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2011-10-24 14:11:55 -0400 |
commit | 32b9aaf1a53b3c8d435f86339b01b3968520cb0a (patch) | |
tree | 713a791846285e1f06cd9b2a9e714bd72e3a1e0e /fs/cifs/file.c | |
parent | 9ee305b70e09f5132c9723780ce10e69710b8bca (diff) |
CIFS: Make cifs_push_locks send as many locks at once as possible
that reduces a traffic and increases a performance.
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 569184e6ee01..ea096ce5d4f7 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -829,6 +829,11 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) | |||
829 | struct cifsLockInfo *li, *tmp; | 829 | struct cifsLockInfo *li, *tmp; |
830 | struct cifs_tcon *tcon; | 830 | struct cifs_tcon *tcon; |
831 | struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); | 831 | struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); |
832 | unsigned int num, max_num; | ||
833 | LOCKING_ANDX_RANGE *buf, *cur; | ||
834 | int types[] = {LOCKING_ANDX_LARGE_FILES, | ||
835 | LOCKING_ANDX_SHARED_LOCK | LOCKING_ANDX_LARGE_FILES}; | ||
836 | int i; | ||
832 | 837 | ||
833 | xid = GetXid(); | 838 | xid = GetXid(); |
834 | tcon = tlink_tcon(cfile->tlink); | 839 | tcon = tlink_tcon(cfile->tlink); |
@@ -840,17 +845,49 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) | |||
840 | return rc; | 845 | return rc; |
841 | } | 846 | } |
842 | 847 | ||
843 | list_for_each_entry_safe(li, tmp, &cinode->llist, llist) { | 848 | max_num = (tcon->ses->server->maxBuf - sizeof(struct smb_hdr)) / |
844 | stored_rc = CIFSSMBLock(xid, tcon, cfile->netfid, | 849 | sizeof(LOCKING_ANDX_RANGE); |
845 | li->pid, li->length, li->offset, | 850 | buf = kzalloc(max_num * sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL); |
846 | 0, 1, li->type, 0, 0); | 851 | if (!buf) { |
847 | if (stored_rc) | 852 | mutex_unlock(&cinode->lock_mutex); |
848 | rc = stored_rc; | 853 | FreeXid(xid); |
854 | return rc; | ||
855 | } | ||
856 | |||
857 | for (i = 0; i < 2; i++) { | ||
858 | cur = buf; | ||
859 | num = 0; | ||
860 | list_for_each_entry_safe(li, tmp, &cinode->llist, llist) { | ||
861 | if (li->type != types[i]) | ||
862 | continue; | ||
863 | cur->Pid = cpu_to_le16(li->pid); | ||
864 | cur->LengthLow = cpu_to_le32((u32)li->length); | ||
865 | cur->LengthHigh = cpu_to_le32((u32)(li->length>>32)); | ||
866 | cur->OffsetLow = cpu_to_le32((u32)li->offset); | ||
867 | cur->OffsetHigh = cpu_to_le32((u32)(li->offset>>32)); | ||
868 | if (++num == max_num) { | ||
869 | stored_rc = cifs_lockv(xid, tcon, cfile->netfid, | ||
870 | li->type, 0, num, buf); | ||
871 | if (stored_rc) | ||
872 | rc = stored_rc; | ||
873 | cur = buf; | ||
874 | num = 0; | ||
875 | } else | ||
876 | cur++; | ||
877 | } | ||
878 | |||
879 | if (num) { | ||
880 | stored_rc = cifs_lockv(xid, tcon, cfile->netfid, | ||
881 | types[i], 0, num, buf); | ||
882 | if (stored_rc) | ||
883 | rc = stored_rc; | ||
884 | } | ||
849 | } | 885 | } |
850 | 886 | ||
851 | cinode->can_cache_brlcks = false; | 887 | cinode->can_cache_brlcks = false; |
852 | mutex_unlock(&cinode->lock_mutex); | 888 | mutex_unlock(&cinode->lock_mutex); |
853 | 889 | ||
890 | kfree(buf); | ||
854 | FreeXid(xid); | 891 | FreeXid(xid); |
855 | return rc; | 892 | return rc; |
856 | } | 893 | } |