Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a88b4707 authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French
Browse files

CIFS: Cleanup byte-range locking code style



Reorder parms of cifs_lock_init, trivially simplify getlk code and
remove extra {} in cifs_lock_add_if.

Cc: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarJeff Layton <jlayton@samba.org>
Signed-off-by: default avatarPavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 161ebf9f
Loading
Loading
Loading
Loading
+19 −24
Original line number Original line Diff line number Diff line
@@ -645,20 +645,20 @@ int cifs_closedir(struct inode *inode, struct file *file)
}
}


static struct cifsLockInfo *
static struct cifsLockInfo *
cifs_lock_init(__u64 len, __u64 offset, __u8 type, __u16 netfid)
cifs_lock_init(__u64 offset, __u64 length, __u8 type, __u16 netfid)
{
{
	struct cifsLockInfo *li =
	struct cifsLockInfo *lock =
		kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL);
		kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL);
	if (!li)
	if (!lock)
		return li;
		return lock;
	li->netfid = netfid;
	lock->offset = offset;
	li->offset = offset;
	lock->length = length;
	li->length = len;
	lock->type = type;
	li->type = type;
	lock->netfid = netfid;
	li->pid = current->tgid;
	lock->pid = current->tgid;
	INIT_LIST_HEAD(&li->blist);
	INIT_LIST_HEAD(&lock->blist);
	init_waitqueue_head(&li->block_q);
	init_waitqueue_head(&lock->block_q);
	return li;
	return lock;
}
}


static void
static void
@@ -770,11 +770,9 @@ cifs_lock_add_if(struct cifsInodeInfo *cinode, struct cifsLockInfo *lock,
					(lock->blist.next == &lock->blist));
					(lock->blist.next == &lock->blist));
		if (!rc)
		if (!rc)
			goto try_again;
			goto try_again;
		else {
		mutex_lock(&cinode->lock_mutex);
		mutex_lock(&cinode->lock_mutex);
		list_del_init(&lock->blist);
		list_del_init(&lock->blist);
	}
	}
	}


	mutex_unlock(&cinode->lock_mutex);
	mutex_unlock(&cinode->lock_mutex);
	return rc;
	return rc;
@@ -927,7 +925,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
		else
		else
			type = CIFS_WRLCK;
			type = CIFS_WRLCK;


		lck = cifs_lock_init(length, flock->fl_start, type,
		lck = cifs_lock_init(flock->fl_start, length, type,
				     cfile->netfid);
				     cfile->netfid);
		if (!lck) {
		if (!lck) {
			rc = -ENOMEM;
			rc = -ENOMEM;
@@ -1064,14 +1062,12 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u8 type,
		if (rc != 0)
		if (rc != 0)
			cERROR(1, "Error unlocking previously locked "
			cERROR(1, "Error unlocking previously locked "
				   "range %d during test of lock", rc);
				   "range %d during test of lock", rc);
		rc = 0;
		return 0;
		return rc;
	}
	}


	if (type & LOCKING_ANDX_SHARED_LOCK) {
	if (type & LOCKING_ANDX_SHARED_LOCK) {
		flock->fl_type = F_WRLCK;
		flock->fl_type = F_WRLCK;
		rc = 0;
		return 0;
		return rc;
	}
	}


	rc = CIFSSMBLock(xid, tcon, netfid, current->tgid, length,
	rc = CIFSSMBLock(xid, tcon, netfid, current->tgid, length,
@@ -1089,8 +1085,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u8 type,
	} else
	} else
		flock->fl_type = F_WRLCK;
		flock->fl_type = F_WRLCK;


	rc = 0;
	return 0;
	return rc;
}
}


static void
static void
@@ -1250,7 +1245,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u8 type,
	if (lock) {
	if (lock) {
		struct cifsLockInfo *lock;
		struct cifsLockInfo *lock;


		lock = cifs_lock_init(length, flock->fl_start, type, netfid);
		lock = cifs_lock_init(flock->fl_start, length, type, netfid);
		if (!lock)
		if (!lock)
			return -ENOMEM;
			return -ENOMEM;