Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.samba.org/sfrench/cifs-2.6

* git://git.samba.org/sfrench/cifs-2.6:
CIFS: Cleanup byte-range locking code style
CIFS: Simplify setlk error handling for mandatory locking

+50 -55
+50 -55
fs/cifs/file.c
··· 645 645 } 646 646 647 647 static struct cifsLockInfo * 648 - cifs_lock_init(__u64 len, __u64 offset, __u8 type, __u16 netfid) 648 + cifs_lock_init(__u64 offset, __u64 length, __u8 type, __u16 netfid) 649 649 { 650 - struct cifsLockInfo *li = 650 + struct cifsLockInfo *lock = 651 651 kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL); 652 - if (!li) 653 - return li; 654 - li->netfid = netfid; 655 - li->offset = offset; 656 - li->length = len; 657 - li->type = type; 658 - li->pid = current->tgid; 659 - INIT_LIST_HEAD(&li->blist); 660 - init_waitqueue_head(&li->block_q); 661 - return li; 652 + if (!lock) 653 + return lock; 654 + lock->offset = offset; 655 + lock->length = length; 656 + lock->type = type; 657 + lock->netfid = netfid; 658 + lock->pid = current->tgid; 659 + INIT_LIST_HEAD(&lock->blist); 660 + init_waitqueue_head(&lock->block_q); 661 + return lock; 662 662 } 663 663 664 664 static void ··· 672 672 } 673 673 674 674 static bool 675 - cifs_find_lock_conflict(struct cifsInodeInfo *cinode, __u64 offset, 675 + __cifs_find_lock_conflict(struct cifsInodeInfo *cinode, __u64 offset, 676 676 __u64 length, __u8 type, __u16 netfid, 677 677 struct cifsLockInfo **conf_lock) 678 678 { ··· 694 694 return false; 695 695 } 696 696 697 + static bool 698 + cifs_find_lock_conflict(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock, 699 + struct cifsLockInfo **conf_lock) 700 + { 701 + return __cifs_find_lock_conflict(cinode, lock->offset, lock->length, 702 + lock->type, lock->netfid, conf_lock); 703 + } 704 + 697 705 static int 698 706 cifs_lock_test(struct cifsInodeInfo *cinode, __u64 offset, __u64 length, 699 707 __u8 type, __u16 netfid, struct file_lock *flock) ··· 712 704 713 705 mutex_lock(&cinode->lock_mutex); 714 706 715 - exist = cifs_find_lock_conflict(cinode, offset, length, type, netfid, 716 - &conf_lock); 707 + exist = __cifs_find_lock_conflict(cinode, offset, length, type, netfid, 708 + &conf_lock); 717 709 if (exist) { 718 710 flock->fl_start = conf_lock->offset; 719 711 flock->fl_end = conf_lock->offset + conf_lock->length - 1; ··· 731 723 return rc; 732 724 } 733 725 734 - static int 735 - cifs_lock_add(struct cifsInodeInfo *cinode, __u64 len, __u64 offset, 736 - __u8 type, __u16 netfid) 726 + static void 727 + cifs_lock_add(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock) 737 728 { 738 - struct cifsLockInfo *li; 739 - 740 - li = cifs_lock_init(len, offset, type, netfid); 741 - if (!li) 742 - return -ENOMEM; 743 - 744 729 mutex_lock(&cinode->lock_mutex); 745 - list_add_tail(&li->llist, &cinode->llist); 730 + list_add_tail(&lock->llist, &cinode->llist); 746 731 mutex_unlock(&cinode->lock_mutex); 747 - return 0; 748 732 } 749 733 750 734 static int 751 - cifs_lock_add_if(struct cifsInodeInfo *cinode, __u64 offset, __u64 length, 752 - __u8 type, __u16 netfid, bool wait) 735 + cifs_lock_add_if(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock, 736 + bool wait) 753 737 { 754 - struct cifsLockInfo *lock, *conf_lock; 738 + struct cifsLockInfo *conf_lock; 755 739 bool exist; 756 740 int rc = 0; 757 - 758 - lock = cifs_lock_init(length, offset, type, netfid); 759 - if (!lock) 760 - return -ENOMEM; 761 741 762 742 try_again: 763 743 exist = false; 764 744 mutex_lock(&cinode->lock_mutex); 765 745 766 - exist = cifs_find_lock_conflict(cinode, offset, length, type, netfid, 767 - &conf_lock); 746 + exist = cifs_find_lock_conflict(cinode, lock, &conf_lock); 768 747 if (!exist && cinode->can_cache_brlcks) { 769 748 list_add_tail(&lock->llist, &cinode->llist); 770 749 mutex_unlock(&cinode->lock_mutex); ··· 770 775 (lock->blist.next == &lock->blist)); 771 776 if (!rc) 772 777 goto try_again; 773 - else { 774 - mutex_lock(&cinode->lock_mutex); 775 - list_del_init(&lock->blist); 776 - } 778 + mutex_lock(&cinode->lock_mutex); 779 + list_del_init(&lock->blist); 777 780 } 778 781 779 - kfree(lock); 780 782 mutex_unlock(&cinode->lock_mutex); 781 783 return rc; 782 784 } ··· 925 933 else 926 934 type = CIFS_WRLCK; 927 935 928 - lck = cifs_lock_init(length, flock->fl_start, type, 936 + lck = cifs_lock_init(flock->fl_start, length, type, 929 937 cfile->netfid); 930 938 if (!lck) { 931 939 rc = -ENOMEM; ··· 1062 1070 if (rc != 0) 1063 1071 cERROR(1, "Error unlocking previously locked " 1064 1072 "range %d during test of lock", rc); 1065 - rc = 0; 1066 - return rc; 1073 + return 0; 1067 1074 } 1068 1075 1069 1076 if (type & LOCKING_ANDX_SHARED_LOCK) { 1070 1077 flock->fl_type = F_WRLCK; 1071 - rc = 0; 1072 - return rc; 1078 + return 0; 1073 1079 } 1074 1080 1075 1081 rc = CIFSSMBLock(xid, tcon, netfid, current->tgid, length, ··· 1085 1095 } else 1086 1096 flock->fl_type = F_WRLCK; 1087 1097 1088 - rc = 0; 1089 - return rc; 1098 + return 0; 1090 1099 } 1091 1100 1092 1101 static void ··· 1243 1254 } 1244 1255 1245 1256 if (lock) { 1246 - rc = cifs_lock_add_if(cinode, flock->fl_start, length, 1247 - type, netfid, wait_flag); 1257 + struct cifsLockInfo *lock; 1258 + 1259 + lock = cifs_lock_init(flock->fl_start, length, type, netfid); 1260 + if (!lock) 1261 + return -ENOMEM; 1262 + 1263 + rc = cifs_lock_add_if(cinode, lock, wait_flag); 1248 1264 if (rc < 0) 1249 - return rc; 1250 - else if (!rc) 1265 + kfree(lock); 1266 + if (rc <= 0) 1251 1267 goto out; 1252 1268 1253 1269 rc = CIFSSMBLock(xid, tcon, netfid, current->tgid, length, 1254 1270 flock->fl_start, 0, 1, type, wait_flag, 0); 1255 - if (rc == 0) { 1256 - /* For Windows locks we must store them. */ 1257 - rc = cifs_lock_add(cinode, length, flock->fl_start, 1258 - type, netfid); 1271 + if (rc) { 1272 + kfree(lock); 1273 + goto out; 1259 1274 } 1275 + 1276 + cifs_lock_add(cinode, lock); 1260 1277 } else if (unlock) 1261 1278 rc = cifs_unlock_range(cfile, flock, xid); 1262 1279