920
920
for (lockp = &inode->i_flock; *lockp != NULL; \
921
921
lockp = &(*lockp)->fl_next)
923
struct lock_to_push {
924
struct list_head llist;
924
933
cifs_push_posix_locks(struct cifsFileInfo *cfile)
926
935
struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
927
936
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
928
937
struct file_lock *flock, **before;
929
struct cifsLockInfo *lck, *tmp;
938
unsigned int count = 0, i = 0;
930
939
int rc = 0, xid, type;
940
struct list_head locks_to_send, *el;
941
struct lock_to_push *lck, *tmp;
932
struct list_head locks_to_send;
954
cifs_for_each_lock(cfile->dentry->d_inode, before) {
955
if ((*before)->fl_flags & FL_POSIX)
943
960
INIT_LIST_HEAD(&locks_to_send);
963
* Allocating count locks is enough because no locks can be added to
964
* the list while we are holding cinode->lock_mutex that protects
965
* locking operations of this inode.
967
for (; i < count; i++) {
968
lck = kmalloc(sizeof(struct lock_to_push), GFP_KERNEL);
973
list_add_tail(&lck->llist, &locks_to_send);
977
el = locks_to_send.next;
946
979
cifs_for_each_lock(cfile->dentry->d_inode, before) {
980
if (el == &locks_to_send) {
981
/* something is really wrong */
982
cERROR(1, "Can't push all brlocks!");
986
if ((flock->fl_flags & FL_POSIX) == 0)
948
988
length = 1 + flock->fl_end - flock->fl_start;
949
989
if (flock->fl_type == F_RDLCK || flock->fl_type == F_SHLCK)
950
990
type = CIFS_RDLCK;
952
992
type = CIFS_WRLCK;
954
lck = cifs_lock_init(flock->fl_start, length, type,
993
lck = list_entry(el, struct lock_to_push, llist);
960
994
lck->pid = flock->fl_pid;
962
list_add_tail(&lck->llist, &locks_to_send);
995
lck->netfid = cfile->netfid;
996
lck->length = length;
998
lck->offset = flock->fl_start;
966
1002
unlock_flocks();
968
1004
list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) {
982
1019
cinode->can_cache_brlcks = false;
983
1020
mutex_unlock(&cinode->lock_mutex);
1025
list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) {
1026
list_del(&lck->llist);