Skip to content

Commit

Permalink
locks: consolidate NULL i_flctx checks in locks_remove_file
Browse files Browse the repository at this point in the history
We have each of the locks_remove_* variants doing this individually.
Have the caller do it instead, and have locks_remove_flock and
locks_remove_lease just assume that it's a valid pointer.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
  • Loading branch information
Jeff Layton committed Jan 16, 2015
1 parent 9bd0f45 commit 3d8e560
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)

EXPORT_SYMBOL(locks_remove_posix);

/* The i_flctx must be valid when calling into here */
static void
locks_remove_flock(struct file *filp)
{
Expand All @@ -2413,7 +2414,7 @@ locks_remove_flock(struct file *filp)
};
struct file_lock_context *flctx = file_inode(filp)->i_flctx;

if (!flctx || list_empty(&flctx->flc_flock))
if (list_empty(&flctx->flc_flock))
return;

if (filp->f_op->flock)
Expand All @@ -2425,6 +2426,7 @@ locks_remove_flock(struct file *filp)
fl.fl_ops->fl_release_private(&fl);
}

/* The i_flctx must be valid when calling into here */
static void
locks_remove_lease(struct file *filp)
{
Expand All @@ -2433,7 +2435,7 @@ locks_remove_lease(struct file *filp)
struct file_lock *fl, *tmp;
LIST_HEAD(dispose);

if (!ctx || list_empty(&ctx->flc_lease))
if (list_empty(&ctx->flc_lease))
return;

spin_lock(&ctx->flc_lock);
Expand All @@ -2448,6 +2450,9 @@ locks_remove_lease(struct file *filp)
*/
void locks_remove_file(struct file *filp)
{
if (!file_inode(filp)->i_flctx)
return;

/* remove any OFD locks */
locks_remove_posix(filp, filp);

Expand Down

0 comments on commit 3d8e560

Please sign in to comment.