diff options
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/file.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 74f12877493a..c1a86764bbf7 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -1113,11 +1113,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) | |||
1113 | return rc; | 1113 | return rc; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | /* copied from fs/locks.c with a name change */ | ||
1117 | #define cifs_for_each_lock(inode, lockp) \ | ||
1118 | for (lockp = &inode->i_flock; *lockp != NULL; \ | ||
1119 | lockp = &(*lockp)->fl_next) | ||
1120 | |||
1121 | struct lock_to_push { | 1116 | struct lock_to_push { |
1122 | struct list_head llist; | 1117 | struct list_head llist; |
1123 | __u64 offset; | 1118 | __u64 offset; |
@@ -1132,8 +1127,9 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) | |||
1132 | { | 1127 | { |
1133 | struct inode *inode = cfile->dentry->d_inode; | 1128 | struct inode *inode = cfile->dentry->d_inode; |
1134 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); | 1129 | struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); |
1135 | struct file_lock *flock, **before; | 1130 | struct file_lock *flock; |
1136 | unsigned int count = 0, i = 0; | 1131 | struct file_lock_context *flctx = inode->i_flctx; |
1132 | unsigned int i; | ||
1137 | int rc = 0, xid, type; | 1133 | int rc = 0, xid, type; |
1138 | struct list_head locks_to_send, *el; | 1134 | struct list_head locks_to_send, *el; |
1139 | struct lock_to_push *lck, *tmp; | 1135 | struct lock_to_push *lck, *tmp; |
@@ -1141,21 +1137,17 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) | |||
1141 | 1137 | ||
1142 | xid = get_xid(); | 1138 | xid = get_xid(); |
1143 | 1139 | ||
1144 | spin_lock(&inode->i_lock); | 1140 | if (!flctx) |
1145 | cifs_for_each_lock(inode, before) { | 1141 | goto out; |
1146 | if ((*before)->fl_flags & FL_POSIX) | ||
1147 | count++; | ||
1148 | } | ||
1149 | spin_unlock(&inode->i_lock); | ||
1150 | 1142 | ||
1151 | INIT_LIST_HEAD(&locks_to_send); | 1143 | INIT_LIST_HEAD(&locks_to_send); |
1152 | 1144 | ||
1153 | /* | 1145 | /* |
1154 | * Allocating count locks is enough because no FL_POSIX locks can be | 1146 | * Allocating flc_posix_cnt locks is enough because no FL_POSIX locks |
1155 | * added to the list while we are holding cinode->lock_sem that | 1147 | * can be added to the list while we are holding cinode->lock_sem that |
1156 | * protects locking operations of this inode. | 1148 | * protects locking operations of this inode. |
1157 | */ | 1149 | */ |
1158 | for (; i < count; i++) { | 1150 | for (i = 0; i < flctx->flc_posix_cnt; i++) { |
1159 | lck = kmalloc(sizeof(struct lock_to_push), GFP_KERNEL); | 1151 | lck = kmalloc(sizeof(struct lock_to_push), GFP_KERNEL); |
1160 | if (!lck) { | 1152 | if (!lck) { |
1161 | rc = -ENOMEM; | 1153 | rc = -ENOMEM; |
@@ -1165,11 +1157,8 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) | |||
1165 | } | 1157 | } |
1166 | 1158 | ||
1167 | el = locks_to_send.next; | 1159 | el = locks_to_send.next; |
1168 | spin_lock(&inode->i_lock); | 1160 | spin_lock(&flctx->flc_lock); |
1169 | cifs_for_each_lock(inode, before) { | 1161 | list_for_each_entry(flock, &flctx->flc_posix, fl_list) { |
1170 | flock = *before; | ||
1171 | if ((flock->fl_flags & FL_POSIX) == 0) | ||
1172 | continue; | ||
1173 | if (el == &locks_to_send) { | 1162 | if (el == &locks_to_send) { |
1174 | /* | 1163 | /* |
1175 | * The list ended. We don't have enough allocated | 1164 | * The list ended. We don't have enough allocated |
@@ -1189,9 +1178,8 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) | |||
1189 | lck->length = length; | 1178 | lck->length = length; |
1190 | lck->type = type; | 1179 | lck->type = type; |
1191 | lck->offset = flock->fl_start; | 1180 | lck->offset = flock->fl_start; |
1192 | el = el->next; | ||
1193 | } | 1181 | } |
1194 | spin_unlock(&inode->i_lock); | 1182 | spin_unlock(&flctx->flc_lock); |
1195 | 1183 | ||
1196 | list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) { | 1184 | list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) { |
1197 | int stored_rc; | 1185 | int stored_rc; |