aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2007-03-01 14:34:35 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2007-07-18 19:09:27 -0400
commite32b8ee27b486f682a6d13533cfe6549c8abcdef (patch)
tree2313014defb0f65b2922df766311e41a5e0dbb98 /fs
parentd2ab0b0c4c2570921a9ec1eff1e3a5143e05b231 (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/locks.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/fs/locks.c b/fs/locks.c
index 3c23fd261022..838ca542c556 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -458,22 +458,20 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl)
458} 458}
459 459
460/* Allocate a file_lock initialised to this type of lease */ 460/* Allocate a file_lock initialised to this type of lease */
461static int lease_alloc(struct file *filp, int type, struct file_lock **flp) 461static struct file_lock *lease_alloc(struct file *filp, int type)
462{ 462{
463 struct file_lock *fl = locks_alloc_lock(); 463 struct file_lock *fl = locks_alloc_lock();
464 int error = -ENOMEM; 464 int error = -ENOMEM;
465 465
466 if (fl == NULL) 466 if (fl == NULL)
467 goto out; 467 return ERR_PTR(error);
468 468
469 error = lease_init(filp, type, fl); 469 error = lease_init(filp, type, fl);
470 if (error) { 470 if (error) {
471 locks_free_lock(fl); 471 locks_free_lock(fl);
472 fl = NULL; 472 return ERR_PTR(error);
473 } 473 }
474out: 474 return fl;
475 *flp = fl;
476 return error;
477} 475}
478 476
479/* Check if two locks overlap each other. 477/* Check if two locks overlap each other.
@@ -1179,12 +1177,10 @@ int __break_lease(struct inode *inode, unsigned int mode)
1179 int error = 0, future; 1177 int error = 0, future;
1180 struct file_lock *new_fl, *flock; 1178 struct file_lock *new_fl, *flock;
1181 struct file_lock *fl; 1179 struct file_lock *fl;
1182 int alloc_err;
1183 unsigned long break_time; 1180 unsigned long break_time;
1184 int i_have_this_lease = 0; 1181 int i_have_this_lease = 0;
1185 1182
1186 alloc_err = lease_alloc(NULL, mode & FMODE_WRITE ? F_WRLCK : F_RDLCK, 1183 new_fl = lease_alloc(NULL, mode & FMODE_WRITE ? F_WRLCK : F_RDLCK);
1187 &new_fl);
1188 1184
1189 lock_kernel(); 1185 lock_kernel();
1190 1186
@@ -1212,8 +1208,9 @@ int __break_lease(struct inode *inode, unsigned int mode)
1212 goto out; 1208 goto out;
1213 } 1209 }
1214 1210
1215 if (alloc_err && !i_have_this_lease && ((mode & O_NONBLOCK) == 0)) { 1211 if (IS_ERR(new_fl) && !i_have_this_lease
1216 error = alloc_err; 1212 && ((mode & O_NONBLOCK) == 0)) {
1213 error = PTR_ERR(new_fl);
1217 goto out; 1214 goto out;
1218 } 1215 }
1219 1216
@@ -1260,7 +1257,7 @@ restart:
1260 1257
1261out: 1258out:
1262 unlock_kernel(); 1259 unlock_kernel();
1263 if (!alloc_err) 1260 if (!IS_ERR(new_fl))
1264 locks_free_lock(new_fl); 1261 locks_free_lock(new_fl);
1265 return error; 1262 return error;
1266} 1263}