mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
locks: clean up lease_alloc()
Return the newly allocated structure as the return value instead of using a struct ** parameter. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
parent
d2ab0b0c4c
commit
e32b8ee27b
1 changed files with 9 additions and 12 deletions
21
fs/locks.c
21
fs/locks.c
|
@ -458,22 +458,20 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a file_lock initialised to this type of lease */
|
/* Allocate a file_lock initialised to this type of lease */
|
||||||
static int lease_alloc(struct file *filp, int type, struct file_lock **flp)
|
static struct file_lock *lease_alloc(struct file *filp, int type)
|
||||||
{
|
{
|
||||||
struct file_lock *fl = locks_alloc_lock();
|
struct file_lock *fl = locks_alloc_lock();
|
||||||
int error = -ENOMEM;
|
int error = -ENOMEM;
|
||||||
|
|
||||||
if (fl == NULL)
|
if (fl == NULL)
|
||||||
goto out;
|
return ERR_PTR(error);
|
||||||
|
|
||||||
error = lease_init(filp, type, fl);
|
error = lease_init(filp, type, fl);
|
||||||
if (error) {
|
if (error) {
|
||||||
locks_free_lock(fl);
|
locks_free_lock(fl);
|
||||||
fl = NULL;
|
return ERR_PTR(error);
|
||||||
}
|
}
|
||||||
out:
|
return fl;
|
||||||
*flp = fl;
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if two locks overlap each other.
|
/* Check if two locks overlap each other.
|
||||||
|
@ -1179,12 +1177,10 @@ int __break_lease(struct inode *inode, unsigned int mode)
|
||||||
int error = 0, future;
|
int error = 0, future;
|
||||||
struct file_lock *new_fl, *flock;
|
struct file_lock *new_fl, *flock;
|
||||||
struct file_lock *fl;
|
struct file_lock *fl;
|
||||||
int alloc_err;
|
|
||||||
unsigned long break_time;
|
unsigned long break_time;
|
||||||
int i_have_this_lease = 0;
|
int i_have_this_lease = 0;
|
||||||
|
|
||||||
alloc_err = lease_alloc(NULL, mode & FMODE_WRITE ? F_WRLCK : F_RDLCK,
|
new_fl = lease_alloc(NULL, mode & FMODE_WRITE ? F_WRLCK : F_RDLCK);
|
||||||
&new_fl);
|
|
||||||
|
|
||||||
lock_kernel();
|
lock_kernel();
|
||||||
|
|
||||||
|
@ -1212,8 +1208,9 @@ int __break_lease(struct inode *inode, unsigned int mode)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alloc_err && !i_have_this_lease && ((mode & O_NONBLOCK) == 0)) {
|
if (IS_ERR(new_fl) && !i_have_this_lease
|
||||||
error = alloc_err;
|
&& ((mode & O_NONBLOCK) == 0)) {
|
||||||
|
error = PTR_ERR(new_fl);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1260,7 +1257,7 @@ restart:
|
||||||
|
|
||||||
out:
|
out:
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
if (!alloc_err)
|
if (!IS_ERR(new_fl))
|
||||||
locks_free_lock(new_fl);
|
locks_free_lock(new_fl);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue